]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Remove all signed divisions
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 26 Oct 2013 00:57:37 +0000 (02:57 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 26 Oct 2013 00:59:23 +0000 (02:59 +0200)
grub-core/gfxmenu/gui_circular_progress.c
grub-core/gfxmenu/gui_list.c
grub-core/gfxmenu/gui_progress_bar.c
grub-core/lib/libgcrypt/mpi/longlong.h
grub-core/lib/libgcrypt/mpi/mpi-pow.c
grub-core/lib/libgcrypt/mpi/mpih-div.c
grub-core/normal/datetime.c
grub-core/term/tparm.c
include/grub/gui.h

index 284a75a5e2547b838df6e7fd37be4a983aef1235..400df2671ec5aac679e6f11efdc3bc073046324d 100644 (file)
@@ -36,8 +36,8 @@ struct grub_gui_circular_progress
   int visible;
   int start;
   int end;
-  int value;
-  int num_ticks;
+  unsigned value;
+  unsigned num_ticks;
   int start_angle;
   int ticks_disappear;
   char *theme_dir;
@@ -238,7 +238,12 @@ parse_angle (const char *value)
       /* Unicode symbol of degrees (a circle, U+b0). Put here in UTF-8 to
         avoid potential problem with text file reesncoding  */
       || grub_strcmp (ptr, "\xc2\xb0") == 0)
-    angle = (angle * 64 + 45) / 90;
+    {
+      if (angle >= 0)
+       angle = ((unsigned) angle * 64 + 45) / 90;
+      else
+       angle = -((unsigned) -angle * 64 + 45) / 90;
+    }
   return angle;
 }
 
index 5f7f47a436714bdae08438dd49002f00ba6d9267..6a0c0f8ab029e45e1e12e268cad53047c047fd5f 100644 (file)
@@ -271,14 +271,14 @@ draw_scrollbar (list_impl_t self,
       tracklen += thumb_vertical_pad;
       tracktop -= thumb->get_top_pad (thumb);
     }
-  int thumby = tracktop + tracklen * (value - min) / (max - min);
-  int thumbheight = tracklen * extent / (max - min) + 1;
+  int thumby = tracktop + tracklen * (value - min) / (unsigned) (max - min);
+  int thumbheight = tracklen * extent / (unsigned) (max - min) + 1;
   /* Rare occasion: too many entries or too low height. */
   if (thumbheight < thumb_vertical_pad)
     {
       thumbheight = thumb_vertical_pad;
       thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min)
-                           / (max - extent));
+                           / (unsigned)(max - extent));
     }
   int thumbx = frame->get_left_pad (frame);
   int thumbwidth = scrollbar_width - frame_horizontal_pad;
index 588f23f1022b998666b6f4d81210f7e8c284d9cb..8f6221e9cc1c7816f1e1c6b3076349d9aad918f9 100644 (file)
@@ -170,7 +170,7 @@ draw_pixmap_bar (grub_gui_progress_bar_t self)
     hlheight -= hl_v_pad;
 
   barwidth = (tracklen * (self->value - self->start) 
-             / (self->end - self->start));
+             / (unsigned) (self->end - self->start));
 
   if (barwidth >= hl_h_pad)
     {
index 5dba7931a49b6d939a6553218b28ae508fc25130..8aeb60e1ce97d77db38daae5b0111e867cfe104c 100644 (file)
@@ -170,7 +170,7 @@ MA 02111-1307, USA. */
     (pl) = __m0 * __m1;                                                \
   } while (0)
 #define UMUL_TIME 46
-#ifndef LONGLONG_STANDALONE
+#if 0
 #define udiv_qrnnd(q, r, n1, n0, d) \
   do { UDItype __r;                                                    \
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
@@ -353,7 +353,7 @@ extern UDItype __udiv_qrnnd ();
 #define UMUL_TIME 40
 #define UDIV_TIME 80
 #endif
-#ifndef LONGLONG_STANDALONE
+#if 0
 #define udiv_qrnnd(q, r, n1, n0, d) \
   do { USItype __r;                                                    \
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
@@ -1294,7 +1294,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
 #define UMUL_TIME 39           /* 39 instructions */
 #endif
 #ifndef udiv_qrnnd
-#ifndef LONGLONG_STANDALONE
+#if 0
 #define udiv_qrnnd(q, r, n1, n0, d) \
   do { USItype __r;                                                    \
     (q) = __udiv_qrnnd (&__r, (n1), (n0), (d));                        \
index 33bbebe32bbab6282e5c529a325ff39d91c7736a..e73632570c83f65d5b178a54c751ea994530ae61 100644 (file)
@@ -75,9 +75,6 @@ gcry_mpi_powm (gcry_mpi_t res,
   rp = res->d;
   ep = expo->d;
 
-  if (!msize)
-    msize = 1 / msize;     /* Provoke a signal.  */
-
   if (!esize)
     {
       /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 depending
index 224b8108672e101722c01078df25c5cba2200d6a..ef9bf5955ab290a71bd43e9e25760a99f169c32f 100644 (file)
@@ -214,7 +214,7 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
       case 0:
        /* We are asked to divide by zero, so go ahead and do it!  (To make
           the compiler not remove this statement, return the value.)  */
-       return 1 / dsize;
+       return 0;//1 / dsize;
 
       case 1:
        {
index 2b0faca90a92978e8db5ab2ef31f9d9dbe205daa..dcbca79e847f3bb547f04995e5e74b57e6d104d2 100644 (file)
@@ -40,7 +40,8 @@ grub_get_weekday (struct grub_datetime *datetime)
   y = datetime->year - a;
   m = datetime->month + 12 * a - 2;
 
-  return (datetime->day + y + y / 4 - y / 100 + y / 400 + (31 * m / 12)) % 7;
+  return ((unsigned)(datetime->day + y + y / 4 - y / 100 + y / 400
+                    + (31 * m / 12))) % 7;
 }
 
 const char *
index 8c1c288a0bb1c579fe61ecedf2abd43c39a4f321..33cf04e039887c37bf1f06571179a781a3eb8487 100644 (file)
@@ -614,13 +614,13 @@ tparam_internal(const char *string, va_list ap)
            case '/':
                y = npop();
                x = npop();
-               npush(y ? (x / y) : 0);
+               npush(y ? ((unsigned) x / (unsigned) y) : 0);
                break;
 
            case 'm':
                y = npop();
                x = npop();
-               npush(y ? (x % y) : 0);
+               npush(y ? ((unsigned) x % (unsigned) y) : 0);
                break;
 
            case 'A':
index 6f818627e55640be25435a9a52933b08df18fb28..de402b77657526f52345224986b67a66afd28600 100644 (file)
@@ -123,13 +123,27 @@ typedef signed grub_fixed_signed_t;
 static inline signed
 grub_fixed_sfs_divide (signed a, grub_fixed_signed_t b)
 {
-  return (a * GRUB_FIXED_1) / b;
+  if (b < 0)
+    {
+      b = -b;
+      a = -a;
+    }
+  if (a < 0)
+    return -((unsigned) a * GRUB_FIXED_1) / (unsigned) b;
+  return ((unsigned) a * GRUB_FIXED_1) / (unsigned) b;
 }
 
 static inline grub_fixed_signed_t
 grub_fixed_fsf_divide (grub_fixed_signed_t a, signed b)
 {
-  return a / b;
+  if (b < 0)
+    {
+      b = -b;
+      a = -a;
+    }
+  if (a < 0)
+    return -(unsigned) a / (unsigned) b;
+  return (unsigned) a / (unsigned) b;
 }
 
 static inline signed