Re: [notmuch] [PATCH] fix compiler warnings

Subject: Re: [notmuch] [PATCH] fix compiler warnings

Date: Sun, 22 Nov 2009 22:43:42 -0600

To: Carl Worth

Cc: notmuch@notmuchmail org, djcb@djcbsoftware.nl

From: Jeffrey Ollie


On Sun, Nov 22, 2009 at 9:22 PM, Carl Worth <cworth@cworth.org> wrote:
> On Sun, 22 Nov 2009 17:11:03 +0200, Dirk-Jan C. Binnema <djcb.bulk@gmail.com> wrote:
>>
>> -    write(2, msg, sizeof(msg)-1);
>> +    if (write(2, msg, sizeof(msg)-1) < 0) {
>> +         /* ignore...*/
>> +    }
>
> I don't like the gratuitous conditional here. It clutters the code and
> make is less clear. If we're just trying to squelch a warning about an
> unused return value from a function, then I think I'd rather see:
>
>        ssize_t ignored;
>
>        ignored = write (2, msg, sizeof (msg) - 1);

Isn't the usual method for ignoring return values casting to void?

(void) write (2, msg, sizeof (msg) - 1);

-- 
Jeff Ollie

Thread: