Browse Source

* dir.c (sort_size): Avoid any arithmetic except comparison on
file sizes - they may not fit "int" that the function returns.
Original patch by Bulia Byak <bulia@dr.com>

Pavel Roskin 22 years ago
parent
commit
8f02c8ee72
2 changed files with 10 additions and 4 deletions
  1. 6 0
      src/ChangeLog
  2. 4 4
      src/dir.c

+ 6 - 0
src/ChangeLog

@@ -1,3 +1,9 @@
+2003-01-20  Pavel Roskin  <proski@gnu.org>
+
+	* dir.c (sort_size): Avoid any arithmetic except comparison on
+	file sizes - they may not fit "int" that the function returns.
+	Original patch by Bulia Byak <bulia@dr.com>
+
 2003-01-20  Andrew V. Samoilov  <sav@bcs.zp.ua>
 
 	* profile.c (load): Handle corrupted section header.

+ 4 - 4
src/dir.c

@@ -220,10 +220,10 @@ sort_size (const file_entry *a, const file_entry *b)
     int ad = MY_ISDIR (a);
     int bd = MY_ISDIR (b);
 
-    if (ad == bd || mix_all_files)
-	return (b->buf.st_size - a->buf.st_size) * reverse;
-    else
-	return bd-ad;
+    if (ad != bd && !mix_all_files)
+	return bd - ad;
+
+    return (2 * (b->buf.st_size > a->buf.st_size) - 1) * reverse;
 }
 
 int