From: Linus Torvalds <torvalds@osdl.org>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: linux-kernel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net
Subject: Re: [PATCH 1/4] NTFS: Fix sparse warnings that have crept in over time.
Date: Mon, 26 Sep 2005 07:57:09 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0509260746130.3308@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.60.0509261431270.32257@hermes-1.csi.cam.ac.uk>
On Mon, 26 Sep 2005, Anton Altaparmakov wrote:
>
> NTFS: Fix sparse warnings that have crept in over time.
I think this is wrong.
What was the warning that caused this (and the two other things that look
the same)?
> #define MK_MREF(m, s) ((MFT_REF)(((MFT_REF)(s) << 48) | \
> - ((MFT_REF)(m) & MFT_REF_MASK_CPU)))
> + ((MFT_REF)(m) & (u64)MFT_REF_MASK_CPU)))
Also, side note: how you defined "MFT_REF_MASK_CPU" is pretty debatable in
the first place:
typedef enum {
MFT_REF_MASK_CPU = 0x0000ffffffffffffULL,
MFT_REF_MASK_LE = const_cpu_to_le64(0x0000ffffffffffffULL),
} MFT_REF_CONSTS;
and this just _happens_ to work with gcc, but it's not real C.
The issue? "enum" is really an integer type. As in "int". Trying to put a
larger value than one that fits in "int" is not guaranteed to work.
There's another issue, namely that the type of the snum is not only of
undefined size (is it the same size as an "int"? Is it an "unsigned long
long"?) but the "endianness" of it is also now totally undefined. You have
two different endiannesses inside the _same_ enum. What is the type of the
enum?
You _really_ probably should use just
#define MFT_REF_MASK_CPU 0x0000ffffffffffffULL
#define MFT_REF_MASK_LE const_cpu_to_le64(MFT_REF_MASK_CPU)
instead. That way the type of that thing is well-defined.
Depending on what warning you're trying to shut up, that may well fix it
too. Because now "MFT_REF_MASK_CPU" is clearly a regular constant, while
MFT_REF_MASK_LE is clearly a little-endian constant. Before, they were of
the same enum type, which made it very unclear what the hell they were.
Linus
next prev parent reply other threads:[~2005-09-26 14:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-26 13:31 [2.6.14-rc2-git] NTFS: Even more bug fixes! Anton Altaparmakov
2005-09-26 13:32 ` [PATCH 1/4] NTFS: Fix sparse warnings that have crept in over time Anton Altaparmakov
2005-09-26 13:33 ` [PATCH 2/4] NTFS: Change ntfs_cluster_free() to require a write locked runlist on entry Anton Altaparmakov
2005-09-26 13:33 ` [PATCH 3/4] NTFS: Fix the definition of the CHKD ntfs record magic Anton Altaparmakov
2005-09-26 13:34 ` [PATCH 4/4] NTFS: More $LogFile handling fixes: when chkdsk has been run, it can leave the Anton Altaparmakov
2005-09-26 14:57 ` Linus Torvalds [this message]
2005-09-26 16:09 ` [PATCH 1/4] NTFS: Fix sparse warnings that have crept in over time Anton Altaparmakov
2005-09-26 16:41 ` Linus Torvalds
2005-09-26 16:46 ` Al Viro
2005-09-26 19:08 ` Anton Altaparmakov
2005-09-26 20:43 ` Linus Torvalds
2005-09-26 16:44 ` Al Viro
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=Pine.LNX.4.58.0509260746130.3308@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=aia21@cam.ac.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®