Remove all signed divisions

This commit is contained in:
Vladimir Serbinenko committed 2013-10-26 02:59:23 +02:00
1 parent 5d20f9b0e7
commit 739b471725
9 files changed
+36 -19

No files matched your search

+8 -3
View 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;
}
+3 -3
View 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;
+1 -1
View 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)
{
+3 -3
View 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)); \
-3
View 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
+1 -1
View 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:
{
+2 -1
View 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 *
+2 -2
View 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':
+16 -2
View 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