Whamcloud - gitweb
Fix e2p_percent() crash if percentage was zero.
authorTheodore Ts'o <tytso@mit.edu>
Fri, 29 Sep 2006 14:23:16 +0000 (10:23 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 29 Sep 2006 14:23:16 +0000 (10:23 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/e2p/ChangeLog
lib/e2p/percent.c

index 4883401..75e2cd3 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-29  Theodore Tso  <tytso@mit.edu>
+
+       * percent.c (e2p_percent): Fix bug which caused e2p_percent to
+               crash if the percentage was zero.
+
 2006-08-30  Theodore Tso  <tytso@mit.edu>
 
        * percent.c (e2p_percent): Add a new function which accurate and
index f4497b6..b8c936d 100644 (file)
@@ -19,6 +19,8 @@ unsigned int e2p_percent(int percent, unsigned int base)
 {
        unsigned int mask = ~((1 << (sizeof(unsigned int) - 1) * 8) - 1);
 
+       if (!percent)
+               return 0;
        if (100 % percent == 0)
                return base / (100 / percent);
        if (mask & base)