[U-Boot] [PATCH 2/2] musb: sunxi: Implement dfu_usb_get_reset()
Albert ARIBAUD
albert.u.boot at aribaud.net
Sun Oct 25 14:22:53 CET 2015
Hello Ian,
On Sun, 25 Oct 2015 12:40:45 +0000, Ian Campbell
<ijc+uboot at hellion.org.uk> wrote:
> On Sun, 2015-10-25 at 12:46 +0100, Albert ARIBAUD wrote:
> > > > +static u8 last_int_usb;
> > > > +
> > > > +bool dfu_usb_get_reset(void)
> > > > +{
> > > > + return !!(last_int_usb & MUSB_INTR_RESET);
> > >
> > > The !! is not needed.
> >
> > Except if you want to be sure that you return 0 or 1 rather than 0 or
> > (1 << something).
>
> Doesn't the bool return type already cause that to happen? (from the
> PoV of the caller at least)
When all is said and done, a C bool is a C int, and anyway C does not
perform value conversion (except for size and possibly sign extension)
on type casts.
So no, types, bool or otherwise, do not cause any implicit '!!' to
happen.
What happens is, wherever C expects a boolean value ('if', 'while'...)
it considers 0 to be false and anything else to be true. But that's
independent of the value's alleged type.
> Ian.
Amicalement,
--
Albert.
More information about the U-Boot
mailing list