Jim Meyering <[EMAIL PROTECTED]> wrote:
> So here's that same patch without the useless fseek:
>
> diff --git a/src/openvz_conf.c b/src/openvz_conf.c
> index a274223..2e7b153 100644
I've committed that change:
Rewrite openvzSetUUID.
* src/openvz_conf.c (openvzSetUUID): Rewrite to
I wrote:
...
> diff --git a/src/openvz_conf.c b/src/openvz_conf.c
...
> + FILE *fp = fopen(conf_file, "a");
> + if (fp == NULL)
> + return -1;
...
> + /* Record failure if fseek, fprintf or fclose fails,
> +and be careful always to close the stream. */
> + if (fseek(f
Jim Paris <[EMAIL PROTECTED]> wrote:
> Jim Meyering wrote:
>> +/* Record failure if any of these fails,
>> + and be careful always to close the stream. */
>> +if ((fseek(fp, 0, SEEK_END) < 0)
>> ++ (fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0);
>> ++ (fclose(fp) == EOF
Jim Meyering wrote:
> + /* Record failure if any of these fails,
> +and be careful always to close the stream. */
> + if ((fseek(fp, 0, SEEK_END) < 0)
> + + (fprintf(fp, "\n#UUID: %s\n", uuidstr) < 0);
> + + (fclose(fp) == EOF))
> + ret = -1;
I don't think
There were several unchecked syscalls in this function, along with the
at-least-theoretical risk of a file descriptor leak, so I rewrote this
function to avoid all that, using a stream rather than a bare file
descriptor.
Subject: [PATCH] Rewrite openvzSetUUID.
* src/openvz_conf.c (