GNU bug report logs -
#7201
unportable integer expression in src/install.c
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Tue, 12 Oct 2010 19:37:02 UTC
Severity: normal
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Sun, 17 Apr 2011 10:58:14 +0200
with message-id <871v11dzkp.fsf <at> rho.meyering.net>
and subject line Re: bug#7201: unportable integer expression in src/install.c
has caused the GNU bug report #7201,
regarding unportable integer expression in src/install.c
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
7201: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7201
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Solaris 10 cc issues this warning:
"install.c", line 189: warning: initializer does not fit or is out of range: -61952
and indeed the code in question relies on undefined
behavior, as it shoehorns what may be a large negative
number into a small int variable. Here's a patch
to src/install.c. Maybe you should remove the "const"
while you're at it, as it's not that helpful here?
--- src/install.c~ 2010-09-27 23:00:50.000000000 -0700
+++ src/install.c 2010-10-12 12:35:30.277787068 -0700
@@ -186,8 +186,8 @@ have_same_content (int a_fd, int b_fd)
static bool
extra_mode (mode_t input)
{
- const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
- return !! (input & mask);
+ const mode_t mask = S_IRWXUGO | S_IFMT;
+ return !! (input & ~ mask);
}
/* Return true if copy of file SRC_NAME to file DEST_NAME is necessary. */
[Message part 3 (message/rfc822, inline)]
Jim Meyering wrote:
> Paul Eggert wrote:
>> Solaris 10 cc issues this warning:
>>
>> "install.c", line 189: warning: initializer does not fit or is out
>> of range: -61952
>>
>> and indeed the code in question relies on undefined
>> behavior, as it shoehorns what may be a large negative
>> number into a small int variable. Here's a patch
>> to src/install.c. Maybe you should remove the "const"
>> while you're at it, as it's not that helpful here?
>>
>> --- src/install.c~ 2010-09-27 23:00:50.000000000 -0700
>> +++ src/install.c 2010-10-12 12:35:30.277787068 -0700
>> @@ -186,8 +186,8 @@ have_same_content (int a_fd, int b_fd)
>> static bool
>> extra_mode (mode_t input)
>> {
>> - const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
>> - return !! (input & mask);
>> + const mode_t mask = S_IRWXUGO | S_IFMT;
>> + return !! (input & ~ mask);
>
> Thanks! That looks sufficiently safe.
> You're welcome to commit/push that.
> Or I will do it for you tomorrow.
Applied long ago. Closing.
This bug report was last modified 14 years and 98 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.