On 10/12/21 16:03, Eric Blake wrote:
> On Tue, Oct 12, 2021 at 12:36:26AM +0200, Laszlo Ersek wrote:
>> In order to shut up the compiler, just zero-initialize the buffer --
>> that's simpler than adding diagnostics pragmas. The "maybe-uninitialized"
>> warning is otherwise very useful, so keep it globally enabled (per
>> WARN_CFLAGS / WERROR_CFLAGS).
> ...
>
>> +++ b/lib/proto.c
>> @@ -433,7 +433,7 @@ send_file_cancellation (guestfs_h *g)
>> static int
>> send_file_complete (guestfs_h *g)
>> {
>> - char buf[1];
>> + char buf[1] = { '\0' };
>> return send_file_chunk (g, 0, buf, 0);
>
> If it were me writing this, I would have done this to shave typing:
>
> char c = '\0';
> return send_file_chunk (g, 0, &c, 0);
>
> or even abbreviated with:
>
> char c = 0;
>
> In fact, since send_file_chunk takes a const char *, we could get away
> with:
>
>
> return send_file_chunk (g, 0, "", 0);
>
> But your way is fine, too, and we aren't in a code golf competition.
>
I wanted to be as surgical as possible; the best would be to just pass
NULL (assuming xdr_bytes() coped with that, due to size==0 -- cue the
earlier debate whether memcpy() should accept NULL with n==0, given that
NULL is not a "pointer to an object").
Thanks
Laszlo
_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs