From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Dan McMahill <dmcmahill@netbsd.org>
Subject: Re: [PATCH] diff: "S_IFREG | 0644" to "(S_IFREG | 0644)" to avoid warning
Date: Mon, 04 Oct 2010 10:54:55 -0700 [thread overview]
Message-ID: <7v8w2d972o.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <AANLkTimBzC7f7teH8Rriykg7o5kwX6mD2g2q-0yOXSiF@mail.gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Mon\, 4 Oct 2010 09\:47\:43 +0000")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Oh it's a bug in NetBSD, sorry for not being explicit about that:
>
> $ grep S_ISREG /usr/include/sys/stat.h
> #define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) /* regular file */
>
> $ grep S_ISREG /usr/include/linux/stat.h
> #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
>
> I.e. GCC sees `S_IFREG | 0644 & _S_IFMT' on NetBSD but `(S_IFREG |
> 0644) & _S_IFMT' on Linux.
>
> Since bitwise AND (&) has precedence over bitwise OR it's probably a
> logic error on NetBSD too, not just an annoying warning.
In that case, I'd prefer to work this around at the definition of
canon_mode(), like
/*
* extra ()-pair around S_ISREG() and friends to work around platform
* header with buggy definitions like
* #define S_ISREG(x) ((x & _S_IFMT) == _S_IFREG)
*/
#define canon_mode(mode) \
(S_ISREG((mode)) ? (S_IFREG | ce_permissions(mode)) : \
...
instead of contaminating the calling sites. Otherwise new calling sites
we will add in the future need to be aware of the same bug for no good
reason.
next prev parent reply other threads:[~2010-10-04 17:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 9:21 [PATCH] diff: "S_IFREG | 0644" to "(S_IFREG | 0644)" to avoid warning Ævar Arnfjörð Bjarmason
2010-10-04 9:35 ` Jonathan Nieder
2010-10-04 9:47 ` Ævar Arnfjörð Bjarmason
2010-10-04 17:54 ` Junio C Hamano [this message]
2010-10-04 18:10 ` [PATCH v2] cache.h: work around broken NetBSD system headers Ævar Arnfjörð Bjarmason
2010-10-04 9:42 ` [PATCH] diff: "S_IFREG | 0644" to "(S_IFREG | 0644)" to avoid warning Ævar Arnfjörð Bjarmason
2010-10-04 10:35 ` Jonathan Nieder
2010-10-04 10:50 ` Jonathan Nieder
2010-10-04 10:53 ` René Scharfe
2010-10-04 11:45 ` Matthieu Moy
2010-10-04 19:23 ` Junio C Hamano
2010-10-04 21:11 ` René Scharfe
2010-10-04 12:28 ` yj2133011
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=7v8w2d972o.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=dmcmahill@netbsd.org \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
/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).