[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7201: unportable integer expression in src/install.c

From: Paul Eggert
Subject: bug#7201: unportable integer expression in src/install.c
Date: Tue, 12 Oct 2010 12:39:27 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100915 Thunderbird/3.0.8

Solaris 10 cc issues this warning:

"install.c", line 189: warning: initializer does not fit or is out of range: 

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. */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]