lkml.org 
[lkml]   [2011]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [lm-sensors] [PATCH 3/3] hwmon: (jc42) do not allow writing to locked registers
    Guenter Roeck wrote:
    > On Wed, Feb 16, 2011 at 10:11:35AM -0500, Clemens Ladisch wrote:
    > > Guenter Roeck wrote:
    > > > On Wed, Feb 16, 2011 at 08:02:38AM -0500, Clemens Ladisch wrote:
    > > > > + readonly = config & JC42_CFG_TCRIT_LOCK;
    > > >
    > > > You are assigning a non-bool to a bool. I can see that recent C compilers
    > > > do the right thing, but I am not sure if that is always the case.
    > > > So I would prefer
    > > > readonly = !!(config & JC42_CFG_TCRIT_LOCK);
    > > >
    > > > Same for the assignments below. I can make that change if you are ok with it.
    > >
    > > I cannot imagine how a compiler could get this wrong even if it tried
    > > to, but if you think so, go ahead. :)
    >
    > I don't know. Maybe I am just paranoid. Using !! is how I usually see it done.

    Usually, !! is used to convert non-zero to the _integer_ 1. With
    a compiler that implements bool, this conversion is already implied.
    On older compilers, someone might be tempted to do "#define bool int",
    but this is not an issue with the compilers required by Linux.


    Regards,
    Clemens


    \
     
     \ /
      Last update: 2011-02-16 16:41    [W:0.043 / U:30.256 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site