Re: (0 == foo), rather than (foo == 0)

From: Andreas Schwab (schwab_at_suse.de)
Date: 03/11/04

  • Next message: pinotj_at_club-internet.fr: "[i386] 2.6.4 + cdrtools-2.01a27 REPORT"
    To: mru@kth.se (Måns Rullgård)
    Date:	Thu, 11 Mar 2004 16:18:29 +0100
    
    

    mru@kth.se (Måns Rullgård) writes:

    > Stefan Smietanowski <stesmi@stesmi.com> writes:
    >
    >> Hi Linus.
    >>
    >>> The warning should be there whether there are parenthesis or not,
    >>> and it should state that you should have an explicit inequality
    >>> expression. So if you have
    >>> if (a = b) ...
    >>> and you really _mean_ that, then the way to write it sanely is to
    >>> just write it as
    >>> if ((a = b) != 0)
    >>> ...
    >>> which makes it much clearer what you're actually doing.
    >>
    >> Or actually change it to
    >>
    >> a = b;
    >> if (a)
    >
    > That doesn't work with while().

    But this works: while (a = b, a != 0).
    (not that it is any better readable :-) ).

    Andreas.

    -- 
    Andreas Schwab, SuSE Labs, schwab@suse.de
    SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
    Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
    "And now for something completely different."
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: pinotj_at_club-internet.fr: "[i386] 2.6.4 + cdrtools-2.01a27 REPORT"

    Relevant Pages

    • Re: 2.6.1 + XFS wierdness
      ... mru@kth.se (Måns Rullgård) writes: ... I don't think his description fits the FAQ. ... The XFS 0 problem should only happen to files that have been written ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH] Fix argument checking in sched_setaffinity
      ... On Sat, 4 Sep 2004, Paul Jackson wrote: ... > How is what Linus left more broken? ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • where is current kernel ?
      ... Is there currently a kernel tree that Linus is working? ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: Suspend with 2.6.0-test7-mm1
      ... Måns Rullgård wrote: ... > I theory I thought of, is that the system suspends before you have ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: printk and long long
      ... > Måns Rullgård wrote: ... >> can be either long or long long depending on machine? ... send the line "unsubscribe linux-kernel" in ... Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)