uuidd: reorder bulk time and random generation code

Write the data and response length values in same close to order they appear
in protocol.  This should make code a little easier to read.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2020-11-21 18:13:45 +00:00
parent 2049075a79
commit ea9416925c
No known key found for this signature in database
GPG Key ID: 0D46FEF7E61DBB46
1 changed files with 6 additions and 5 deletions

View File

@ -529,18 +529,19 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
num = (sizeof(reply_buf) - sizeof(num)) / UUID_LEN;
__uuid_generate_random((unsigned char *) reply_buf +
sizeof(num), &num);
reply_len = sizeof(num) + (UUID_LEN * num);
memcpy(reply_buf, &num, sizeof(num));
if (uuidd_cxt->debug) {
fprintf(stderr, P_("Generated %d UUID:\n",
"Generated %d UUIDs:\n", num), num);
for (i = 0, cp = reply_buf + sizeof(num);
i < num;
i++, cp += UUID_LEN) {
cp = reply_buf + sizeof(num)
for (i = 0; i < num; i++) {
uuid_unparse((unsigned char *)cp, str);
fprintf(stderr, "\t%s\n", str);
cp += UUID_LEN;
}
}
reply_len = (num * UUID_LEN) + sizeof(num);
memcpy(reply_buf, &num, sizeof(num));
break;
default:
if (uuidd_cxt->debug)