Hi Greg,

On Sun, Jan 25, 2026 at 03:29:56PM +0100, Greg KH wrote:
> On Sun, Jan 25, 2026 at 02:49:16PM +0100, Alejandro Colomar via Mutt-dev 
> wrote:
> > On Sun, Jan 25, 2026 at 06:30:23PM +0800, Kevin J. McCarthy wrote:

[...]

> > > -   PREV->content->length = loc - PREV->content->offset - 1;
> > > +   PREV->content->length = loc - PREV->content->offset -
> > > +                                  (has_mbox_sep ? 1 : 0);
> > 
> > You may want to simplify as 
> > 
> >       PREV->content->length = loc - PREV->content->offset - !!has_mbox_sep;
> 
> Doing an integer operation on a boolean value is "tricky" for the C
> standard from what I recall.

!! returns an int, not a bool.  While '!!' is informally known as
"the cast-to-bool operator", a more appropriate name would be
"the cast-to-bool-then-int operator", and indeed, it is equivalent to

        (int)(bool) x;

Being an int, it shouldn't be tricky at all.

(Remember that ! was part of C89 --and K&R C, FWIW--, but _Bool was
 added in C99, so ! must necessarily return an int.)


Cheers,
Alex

> Or I may be totally wrong, but it's tricky
> to read and notice what is happening here.
> 
> The compiler should generate the same code either way.
> 
> Anyway, not a complaint, just a comment for when you have to look at
> this line of code in 10 years and remember what it is doing :)
> 
> thanks,
> 
> greg k-h

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to