]> git.eshelyaron.com Git - emacs.git/commitdiff
(Ffile_attributes): Copy some members of `struct stat' into int's to avoid
authorEli Zaretskii <eliz@gnu.org>
Fri, 12 Jan 2007 15:55:49 +0000 (15:55 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 12 Jan 2007 15:55:49 +0000 (15:55 +0000)
GCC warnings about limited range of short in arguments to FIXNUM_OVERFLOW_P.

src/ChangeLog
src/dired.c

index 77cf5b9cecd5253203954b803c4ee12f2d85263a..0f511e9dbffb343cd6f6cc58894ba388f77422de 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-12  Eli Zaretskii  <eliz@gnu.org>
+
+       * dired.c (Ffile_attributes): Copy some members of `struct stat'
+       into int's to avoid GCC warnings about limited range of short in
+       arguments to FIXNUM_OVERFLOW_P.
+
 2007-01-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
        * macmenu.c (HAVE_DIALOGS): Define if TARGET_API_MAC_CARBON.
index 7b8f978b20c2692f74aaa5a32ea75096530d456c..adb452d12d5d3dc2c16da98651f05d9f71cc1ced 100644 (file)
@@ -930,6 +930,7 @@ Elements of the attribute list are:
   char modes[10];
   Lisp_Object handler;
   struct gcpro gcpro1;
+  int uid, gid, ino;
 
   filename = Fexpand_file_name (filename, Qnil);
 
@@ -964,20 +965,26 @@ Elements of the attribute list are:
 #endif
     }
   values[1] = make_number (s.st_nlink);
+  /* When make_fixnum_or_float is called below with types that are
+     shorter than an int (e.g., `short'), GCC whines about comparison
+     being always false due to limited range of data type.  Fix by
+     copying s.st_uid and s.st_gid into int variables.  */
+  uid = s.st_uid;
+  gid = s.st_gid;
   if (NILP (id_format) || EQ (id_format, Qinteger))
     {
-      values[2] = make_fixnum_or_float (s.st_uid);
-      values[3] = make_fixnum_or_float (s.st_gid);
+      values[2] = make_fixnum_or_float (uid);
+      values[3] = make_fixnum_or_float (gid);
     }
   else
     {
       BLOCK_INPUT;
-      pw = (struct passwd *) getpwuid (s.st_uid);
+      pw = (struct passwd *) getpwuid (uid);
       values[2] = (pw ? build_string (pw->pw_name)
-                  : make_fixnum_or_float (s.st_uid));
-      gr = (struct group *) getgrgid (s.st_gid);
+                  : make_fixnum_or_float (uid));
+      gr = (struct group *) getgrgid (gid);
       values[3] = (gr ? build_string (gr->gr_name)
-                  : make_fixnum_or_float (s.st_gid));
+                  : make_fixnum_or_float (gid));
       UNBLOCK_INPUT;
     }
   values[4] = make_time (s.st_atime);
@@ -999,20 +1006,22 @@ Elements of the attribute list are:
   if (! NILP (dirname))
     encoded = ENCODE_FILE (dirname);
   if (! NILP (dirname) && stat (SDATA (encoded), &sdir) == 0)
-    values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil;
+    values[9] = (sdir.st_gid != gid) ? Qt : Qnil;
   else                                 /* if we can't tell, assume worst */
     values[9] = Qt;
 #else                                  /* file gid will be egid */
-  values[9] = (s.st_gid != getegid ()) ? Qt : Qnil;
+  values[9] = (gid != getegid ()) ? Qt : Qnil;
 #endif /* BSD4_2 (or BSD4_3) */
-  if (FIXNUM_OVERFLOW_P (s.st_ino))
+  /* Shut up GCC warnings in FIXNUM_OVERFLOW_P below.  */
+  ino = s.st_ino;
+  if (FIXNUM_OVERFLOW_P (ino))
     /* To allow inode numbers larger than VALBITS, separate the bottom
        16 bits.  */
-    values[10] = Fcons (make_number (s.st_ino >> 16),
-                       make_number (s.st_ino & 0xffff));
+    values[10] = Fcons (make_number (ino >> 16),
+                       make_number (ino & 0xffff));
   else
     /* But keep the most common cases as integers.  */
-    values[10] = make_number (s.st_ino);
+    values[10] = make_number (ino);
 
   /* Likewise for device.  */
   if (FIXNUM_OVERFLOW_P (s.st_dev))