* warning: comparison is always false due to limited range of data type
@ 2004-08-07 23:17 David Ford
2004-08-08 0:41 ` Paul Jackson
0 siblings, 1 reply; 8+ messages in thread
From: David Ford @ 2004-08-07 23:17 UTC (permalink / raw)
To: linux-kernel mailing list
[-- Attachment #1: Type: text/plain, Size: 946 bytes --]
2.6.8-rc3
CC fs/smbfs/inode.o
fs/smbfs/inode.c: In function `smb_fill_super':
fs/smbfs/inode.c:563: warning: comparison is always false due to limited
range of data type
fs/smbfs/inode.c:564: warning: comparison is always false due to limited
range of data type
559 mnt->ttl = SMB_TTL_DEFAULT;
560 if (ver == SMB_MOUNT_OLDVERSION) {
561 mnt->version = oldmnt->version;
562
563 SET_UID(mnt->uid, oldmnt->uid);
564 SET_GID(mnt->gid, oldmnt->gid);
565
566 mnt->file_mode = (oldmnt->file_mode & S_IRWXUGO)
| S_IFREG;
567 mnt->dir_mode = (oldmnt->dir_mode & S_IRWXUGO) |
S_IFDIR;
568
569 mnt->flags = (oldmnt->file_mode >> 9);
570 } else {
571 if (parse_options(mnt, raw_data))
572 goto out_bad_option;
573 }
[-- Attachment #2: david+challenge-response.vcf --]
[-- Type: text/x-vcard, Size: 183 bytes --]
begin:vcard
fn:David Ford
n:Ford;David
email;internet:david@blue-labs.org
title:Industrial Geek
tel;home:Ask please
tel;cell:(203) 650-3611
x-mozilla-html:TRUE
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: warning: comparison is always false due to limited range of data type
2004-08-07 23:17 warning: comparison is always false due to limited range of data type David Ford
@ 2004-08-08 0:41 ` Paul Jackson
2004-08-08 1:09 ` [OT] " David Ford
2004-08-08 14:21 ` Andi Kleen
0 siblings, 2 replies; 8+ messages in thread
From: Paul Jackson @ 2004-08-08 0:41 UTC (permalink / raw)
To: David Ford; +Cc: linux-kernel, Andi Kleen
david+challenge-response@blue-labs.org wrote:
> fs/smbfs/inode.c:563: warning: comparison is always false due to limited
> range of data type
> fs/smbfs/inode.c:564: warning: comparison is always false due to limited
> range of data type
You're lucky you're still on the cc list David - please don't use reply
addresses that require editing.
Adding Andi Kleen <ak@muc.de> to cc list - looks from the bk log that he
might have some interest in this.
fs/smbfs/inode.c
1.46 03/12/01 07:04:55 ak@muc.de[torvalds] +2 -2
UID16 fixes
bk diffs -r1.45..1.46 fs/smbfs/inode.c
===== fs/smbfs/inode.c 1.45 vs 1.46 =====
554,555c554,555
< mnt->uid = OLD_TO_NEW_UID(oldmnt->uid);
< mnt->gid = OLD_TO_NEW_GID(oldmnt->gid);
---
> SET_UID(mnt->uid, oldmnt->uid);
> SET_GID(mnt->gid, oldmnt->gid);
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
* [OT] Re: warning: comparison is always false due to limited range of data type
2004-08-08 0:41 ` Paul Jackson
@ 2004-08-08 1:09 ` David Ford
2004-08-08 1:52 ` Paul Jackson
2004-08-08 14:21 ` Andi Kleen
1 sibling, 1 reply; 8+ messages in thread
From: David Ford @ 2004-08-08 1:09 UTC (permalink / raw)
To: Paul Jackson; +Cc: linux-kernel, Andi Kleen
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
My email address works perfectly fine and is fully RFC legitimate. No
editing needed.
David
>You're lucky you're still on the cc list David - please don't use reply
>addresses that require editing.
>
>
[-- Attachment #2: david+challenge-response.vcf --]
[-- Type: text/x-vcard, Size: 183 bytes --]
begin:vcard
fn:David Ford
n:Ford;David
email;internet:david@blue-labs.org
title:Industrial Geek
tel;home:Ask please
tel;cell:(203) 650-3611
x-mozilla-html:TRUE
version:2.1
end:vcard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: warning: comparison is always false due to limited range of data type
2004-08-08 1:09 ` [OT] " David Ford
@ 2004-08-08 1:52 ` Paul Jackson
0 siblings, 0 replies; 8+ messages in thread
From: Paul Jackson @ 2004-08-08 1:52 UTC (permalink / raw)
To: David Ford; +Cc: linux-kernel, ak
> My email address works perfectly fine ...
Yes - it does. It faked me out there. Sorry.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: warning: comparison is always false due to limited range of data type
2004-08-08 0:41 ` Paul Jackson
2004-08-08 1:09 ` [OT] " David Ford
@ 2004-08-08 14:21 ` Andi Kleen
2004-08-09 2:37 ` Paul Jackson
1 sibling, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2004-08-08 14:21 UTC (permalink / raw)
To: Paul Jackson; +Cc: David Ford, linux-kernel
On Sat, Aug 07, 2004 at 05:41:33PM -0700, Paul Jackson wrote:
> david+challenge-response@blue-labs.org wrote:
> > fs/smbfs/inode.c:563: warning: comparison is always false due to limited
> > range of data type
> > fs/smbfs/inode.c:564: warning: comparison is always false due to limited
> > range of data type
>
> You're lucky you're still on the cc list David - please don't use reply
> addresses that require editing.
>
> Adding Andi Kleen <ak@muc.de> to cc list - looks from the bk log that he
> might have some interest in this.
Sorry, I forgot what I changed here. At least my original
changes didn't cause warnings as far as I know. Someone else please
take care of it.
-Andi
>
> fs/smbfs/inode.c
> 1.46 03/12/01 07:04:55 ak@muc.de[torvalds] +2 -2
> UID16 fixes
>
> bk diffs -r1.45..1.46 fs/smbfs/inode.c
> ===== fs/smbfs/inode.c 1.45 vs 1.46 =====
> 554,555c554,555
> < mnt->uid = OLD_TO_NEW_UID(oldmnt->uid);
> < mnt->gid = OLD_TO_NEW_GID(oldmnt->gid);
> ---
> > SET_UID(mnt->uid, oldmnt->uid);
> > SET_GID(mnt->gid, oldmnt->gid);
>
> --
> I won't rest till it's the best ...
> Programmer, Linux Scalability
> Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: warning: comparison is always false due to limited range of data type
2004-08-08 14:21 ` Andi Kleen
@ 2004-08-09 2:37 ` Paul Jackson
2004-08-09 21:42 ` Paul Jackson
0 siblings, 1 reply; 8+ messages in thread
From: Paul Jackson @ 2004-08-09 2:37 UTC (permalink / raw)
To: Andi Kleen; +Cc: david+challenge-response, linux-kernel
Andi wrote:
> Someone else please take care of it.
Let's give this a try. It fixes the warning in my i386 and ia64 trees.
Unfortunately, this patch uses the notorious "gcc warning suppression
by obfuscation" technique.
What seems to be going on is that the uid and gid convert macros in
include/linux/highuid.h:
#define __convert_uid(size, uid) \
(size >= sizeof(uid) ? (uid) : high2lowuid(uid))
only call high2lowuid in the case of trying to put a bigger (32 bit,
say) uid/gid in a smaller (16 bit, in this case) word. Gcc is smart
enough to see that the comparison in high2lowuid() macro is silly if
called with a 16 bit source uid, but not smart enough to understand
from the __convert_uid() logic that this is exactly the case that
high2lowuid() won't be called.
So replace the logical "<" operator with the bit op "&~". This
obfuscates things enough to shut gcc up.
Only build the half-dozen files that use SET_UID/SET_GID, on arch
i386 and ia64. Only the file fs/smbfs/inode.c showed the warning,
both arch's, and this patch fixed both. Untested further, past
staring at the code long enough to convince myself the change has
no actual affect on the code's results.
Index: 2.6.8-rc2-mm2/include/linux/highuid.h
===================================================================
--- 2.6.8-rc2-mm2.orig/include/linux/highuid.h 2004-08-04 19:27:48.000000000 -0700
+++ 2.6.8-rc2-mm2/include/linux/highuid.h 2004-08-08 19:03:47.000000000 -0700
@@ -44,8 +44,8 @@ extern void __bad_gid(void);
#ifdef CONFIG_UID16
/* prevent uid mod 65536 effect by returning a default value for high UIDs */
-#define high2lowuid(uid) ((uid) > 65535 ? (old_uid_t)overflowuid : (old_uid_t)(uid))
-#define high2lowgid(gid) ((gid) > 65535 ? (old_gid_t)overflowgid : (old_gid_t)(gid))
+#define high2lowuid(uid) ((uid) & ~0xFFFF ? (old_uid_t)overflowuid : (old_uid_t)(uid))
+#define high2lowgid(gid) ((gid) & ~0xFFFF ? (old_gid_t)overflowgid : (old_gid_t)(gid))
/*
* -1 is different in 16 bits than it is in 32 bits
* these macros are used by chown(), setreuid(), ...,
@@ -89,8 +89,8 @@ extern int fs_overflowgid;
* Since these macros are used in architectures that only need limited
* 16-bit UID back compatibility, we won't use old_uid_t and old_gid_t
*/
-#define fs_high2lowuid(uid) ((uid) > 65535 ? (uid16_t)fs_overflowuid : (uid16_t)(uid))
-#define fs_high2lowgid(gid) ((gid) > 65535 ? (gid16_t)fs_overflowgid : (gid16_t)(gid))
+#define fs_high2lowuid(uid) ((uid) & ~0xFFFF ? (uid16_t)fs_overflowuid : (uid16_t)(uid))
+#define fs_high2lowgid(gid) ((gid) & ~0xFFFF ? (gid16_t)fs_overflowgid : (gid16_t)(gid))
#define low_16_bits(x) ((x) & 0xFFFF)
#define high_16_bits(x) (((x) & 0xFFFF0000) >> 16)
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: warning: comparison is always false due to limited range of data type
2004-08-09 2:37 ` Paul Jackson
@ 2004-08-09 21:42 ` Paul Jackson
0 siblings, 0 replies; 8+ messages in thread
From: Paul Jackson @ 2004-08-09 21:42 UTC (permalink / raw)
To: Andrew Morton; +Cc: Paul Jackson, ak, david+challenge-response, linux-kernel
Andrew,
I forgot to mark this patch, the high2lowuid fix for __convert_uid,
to which I am replying now:
Signed-off-by: Paul Jackson <pj@sgi.com>
You're welcome to pick this patch up, so mark it and run with it.
But as you can see, I did little building and no testing. Nor
do I have any plans to do more.
So if you want more expertise, building, testing or assurances, then
you'll probably have to complain and ask (whom, I don't know) for more.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: warning: comparison is always false due to limited range of data type
[not found] ` <20040818225304.GF22559@bouh.is-a-geek.org>
@ 2004-08-18 23:14 ` Paul Jackson
0 siblings, 0 replies; 8+ messages in thread
From: Paul Jackson @ 2004-08-18 23:14 UTC (permalink / raw)
To: Samuel Thibault; +Cc: linux.kernel
Samuel wrote:
> Here is another approach. This should never warning, and should get
> optimized away as needed.
Yours looks like it has a better chance of not being broken by some
future gcc enhancement that can see through the obfuscation in mine.
I didn't actually try it, but yours looks good to me.
Thanks.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-08-18 23:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-07 23:17 warning: comparison is always false due to limited range of data type David Ford
2004-08-08 0:41 ` Paul Jackson
2004-08-08 1:09 ` [OT] " David Ford
2004-08-08 1:52 ` Paul Jackson
2004-08-08 14:21 ` Andi Kleen
2004-08-09 2:37 ` Paul Jackson
2004-08-09 21:42 ` Paul Jackson
[not found] <2qIDQ-7ZR-13@gated-at.bofh.it>
[not found] ` <2qK2T-oz-1@gated-at.bofh.it>
[not found] ` <2qWQx-Hi-7@gated-at.bofh.it>
[not found] ` <2r8oA-ks-1@gated-at.bofh.it>
[not found] ` <20040818225304.GF22559@bouh.is-a-geek.org>
2004-08-18 23:14 ` Paul Jackson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox