ternary vs double exclamation

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Sat Jan 3 23:20:29 EST 2015


On Sat, 03 Jan 2015 18:54:00 -0500, John de la Garza said:

> It should not be assumed that true will always be 1 as defined in
> include/linux/stddef.h, right?

No, I mean use an actual 'bool' type rather than 'int'.  Consider this from
kernel/softirq.c:

static inline bool lockdep_softirq_start(void)
{
        bool in_hardirq = false;

        if (trace_hardirq_context(current)) {
                in_hardirq = true;
                trace_hardirq_exit();
        }

        lockdep_softirq_enter();

        return in_hardirq;
}

However, this will require actual code analysis to make sure that it's
*really* being used as a boolean, not an int.  In particular, assignments
to/from the variable need to be audited for casting issues (and possibly
the correct rework is to convert *several* variables to bool at once).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150103/ae4843b6/attachment.bin 


More information about the Kernelnewbies mailing list