[lkml]   [2011]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
    On Tue, 2011-01-25 at 18:05 -0500, Devin Heitmueller wrote:
    > On Tue, Jan 25, 2011 at 5:54 PM, Peter Hüwe <> wrote:
    > > Hi Julia,
    > >
    > > thanks for your input.
    > > So do I understand you correctly if I say
    > > if(!x) is better than if(x==NULL) in any case?

    The machine code should be equivalent in size and speed.

    > > Or only for the kmalloc family?
    > >
    > > Do you remember the reason why !x should be preferred?
    > >
    > > In Documentation/CodingStyle , Chapter 7: Centralized exiting of functions
    > > there is a function fun with looks like this:
    > > int fun(int a)
    > > {
    > > int result = 0;
    > > char *buffer = kmalloc(SIZE);
    > >
    > > if (buffer == NULL)
    > > return -ENOMEM;

    > >
    > > --> So if (buffer == NULL) is in the official CodingStyle - maybe we should
    > > add a paragraph there as well ;)

    CodingStyle shouldn't specify anything on the matter. There is no
    overall, optimal choice for all contexts. Arguing either way is as
    pointless as the Lilliputians' little-end vs. big-end dispute.

    > To my knowledge, the current CodingStyle doesn't enforce a particular
    > standard in this regard, leaving it at the discretion of the author.

    Correct, it does not. I just checked CodingStyle and checkpatch

    > Whether to do (!foo) or (foo == NULL) is one of those debates people
    > have similar to whether to use tabs as whitespace. People have
    > differing opinions and there is no clearly "right" answer.

    It depends on one's measurement criteria for "optimizing" the written
    form of source code.

    I prefer more explicit statement of action is taking place over
    statements with fewer characters. It usually saves me time when
    revisiting code.

    More genrally I prefer any coding practice that saves me time when
    revisiting code. (Note the word "me" carries a lot of context with it.)

    Ambiguity and implicit behaviors ultimately waste my time.

    > Personally
    > I strongly prefer (foo == NULL) as it makes it blindingly obvious that
    > it's a pointer comparison, whereas (!foo) leaves you wondering whether
    > it's an integer or pointer comparison.

    Me too.

    > All that said, you shouldn't submit patches which arbitrarily change
    > from one format to the other. With regards to the proposed patch, you
    > should follow whatever style the author employed in the rest of the
    > file.

    That is another reasonable critereon in "optimizing" the written form of
    the source code. I tend to give it less weight though.


    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2011-01-26 01:35    [W:0.023 / U:39.956 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site