From: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
To: Bart Van Assche <bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>,
Christopher Li <sparse-55XgFHCVCFZAfugRpC6u6w@public.gmane.org>,
yi.zhu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ipw3945-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Harvey Harrison
<harvey.harrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Alexander Viro <viro-rfM+Q5joDG/XmaaqVzeoHQ@public.gmane.org>,
linux-sparse-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Josh Triplett <josh-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org>
Subject: Re: [PATCH 6/9] drivers/net/wireless/iwlwifi/iwl-4965.c: Correct use of ! and &
Date: Wed, 5 Mar 2008 13:36:42 +0100 [thread overview]
Message-ID: <20080305123641.GA2365@elte.hu> (raw)
In-Reply-To: <e2e108260803050430o317d3e0dyed50e86cc4569746-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
* Bart Van Assche <bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> If someone writes (!x & !y) instead of (!x && !y) because both x and y
> have to be evaluated, this means that both x and y have side effects.
> Please keep in mind that the C language does not specify whether x or
> y has to be evaluated first, so if x and y have to be evaluated in
> that order, an expression like (!x & !y) can be the cause of very
> subtle bugs. I prefer readability above brevity.
such expressions _must_ be written as:
ret1 = x();
ret2 = y();
if (ret1 && ret2)
...
any side-effects are totally un-obvious when they are in expressions and
someone doing cleanups later on could easily change the '&' to '&&' and
introduce a bug.
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-03-05 12:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.64.0802262143570.18200@ask.diku.dk>
[not found] ` <Pine.LNX.4.64.0802262143570.18200-QfmoRoYWmW9knbxzx/v8hQ@public.gmane.org>
2008-03-05 6:38 ` [PATCH 6/9] drivers/net/wireless/iwlwifi/iwl-4965.c: Correct use of ! and & Ingo Molnar
2008-03-05 6:49 ` Christopher Li
2008-03-05 7:02 ` Ingo Molnar
[not found] ` <20080305070201.GA32434-X9Un+BFzKDI@public.gmane.org>
2008-03-05 7:09 ` Harvey Harrison
2008-03-05 8:19 ` Ingo Molnar
[not found] ` <20080305081904.GA17789-X9Un+BFzKDI@public.gmane.org>
2008-03-05 12:13 ` Derek M Jones
2008-03-05 8:55 ` Julia Lawall
2008-03-05 12:20 ` Ingo Molnar
[not found] ` <20080305122010.GA999-X9Un+BFzKDI@public.gmane.org>
2008-03-05 12:30 ` Bart Van Assche
[not found] ` <e2e108260803050430o317d3e0dyed50e86cc4569746-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-03-05 12:36 ` Ingo Molnar [this message]
2008-03-05 12:35 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080305123641.GA2365@elte.hu \
--to=mingo-x9un+bfzkdi@public.gmane.org \
--cc=bart.vanassche-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=harvey.harrison-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ipw3945-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=josh-CC+yJ3UmIYqDUpFQwHEjaQ@public.gmane.org \
--cc=julia-dAYI7NvHqcQ@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sparse-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sparse-55XgFHCVCFZAfugRpC6u6w@public.gmane.org \
--cc=viro-rfM+Q5joDG/XmaaqVzeoHQ@public.gmane.org \
--cc=yi.zhu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).