commit 22dc2cc19a3c1e127bc75565980dc7f172dcff52
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Fri Apr 8 16:22:14 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Fri Apr 8 16:22:14 2016 +0200
Fix warnings (that were not turned on by default)
Signed-off-by: Mattias Andrée <maandree_AT_kth.se>
diff --git a/src/internals.h b/src/internals.h
index 21404bd..bfe2e6f 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -16,6 +16,7 @@
#define FLOOR_BITS_TO_CHARS(bits) ZAHL_FLOOR_BITS_TO_CHARS(bits)
#define CEILING_BITS_TO_CHARS(bits) ZAHL_CEILING_BITS_TO_CHARS(bits)
#define BITS_IN_LAST_CHAR(bits) ZAHL_BITS_IN_LAST_CHAR(bits)
+#define TRUNCATE_TO_CHAR(bits) ZAHL_TRUNCATE_TO_CHAR(bits)
#if defined(__GNUC__)
# define O0 __attribute__((optimize("O0")))
_AT_@ -113,6 +114,8 @@ extern size_t libzahl_pool_alloc[sizeof(size_t) * 8];
#define zmemmove(d, s, n) memmove((d), (s), (n) * sizeof(zahl_char_t))
void libzahl_realloc(z_t a, size_t need);
+void zmul_impl(z_t a, z_t b, z_t c);
+void zsqr_impl(z_t a, z_t b);
static inline void
zmemcpy(zahl_char_t *restrict d, const zahl_char_t *restrict s, register size_t n)
diff --git a/src/zadd.c b/src/zadd.c
index b730b81..934d63e 100644
--- a/src/zadd.c
+++ b/src/zadd.c
_AT_@ -10,7 +10,7 @@ zadd_impl(z_t a, z_t b, size_t n)
for (i = 0; i < n; i++) {
tcarry = libzahl_add_overflow(a->chars + i, a->chars[i], b->chars[i]);
- carry = tcarry | libzahl_add_overflow(a->chars + i, a->chars[i], carry);
+ carry = tcarry | (zahl_char_t)libzahl_add_overflow(a->chars + i, a->chars[i], carry);
}
while (carry) {
carry = libzahl_add_overflow(a->chars + i, a->chars[i], 1);
diff --git a/src/zbset.c b/src/zbset.c
index cc7b2b0..3d93fd4 100644
--- a/src/zbset.c
+++ b/src/zbset.c
_AT_@ -23,14 +23,14 @@
void
-zbset_impl_set(z_t a, z_t b, size_t bit)
+zbset_impl_set(z_t a, size_t bit)
{
PROLOGUE(1);
a->chars[chars] |= mask;
}
void
-zbset_impl_clear(z_t a, z_t b, size_t bit)
+zbset_impl_clear(z_t a, size_t bit)
{
PROLOGUE(0);
a->chars[chars] &= ~mask;
_AT_@ -38,7 +38,7 @@ zbset_impl_clear(z_t a, z_t b, size_t bit)
}
void
-zbset_impl_flip(z_t a, z_t b, size_t bit)
+zbset_impl_flip(z_t a, size_t bit)
{
PROLOGUE(1);
a->chars[chars] ^= mask;
diff --git a/src/zpow.c b/src/zpow.c
index 84f4927..f0cbcd9 100644
--- a/src/zpow.c
+++ b/src/zpow.c
_AT_@ -5,9 +5,6 @@
#define tc libzahl_tmp_pow_c
-extern void zmul_impl(z_t a, z_t b, z_t c);
-extern void zsqr_impl(z_t a, z_t b);
-
void
zpow(z_t a, z_t b, z_t c)
{
diff --git a/src/zpowu.c b/src/zpowu.c
index cf879e0..9618010 100644
--- a/src/zpowu.c
+++ b/src/zpowu.c
_AT_@ -4,9 +4,6 @@
#define tb libzahl_tmp_pow_b
-extern void zmul_impl(z_t a, z_t b, z_t c);
-extern void zsqr_impl(z_t a, z_t b);
-
void
zpowu(z_t a, z_t b, unsigned long long int c)
{
diff --git a/src/zrand.c b/src/zrand.c
index 3d70452..f1913e1 100644
--- a/src/zrand.c
+++ b/src/zrand.c
_AT_@ -26,11 +26,11 @@ zrand_libc_rand(void *out, size_t n, void *statep)
if (!inited) {
inited = 1;
- srand((intptr_t)out | time(NULL));
+ srand((unsigned)((intptr_t)out | time(NULL)));
}
while (n--) {
- ri = rand();
+ ri = (unsigned)rand();
rd = (double)ri / ((double)RAND_MAX + 1);
#ifdef GOOD_RAND
rd *= 256 * 256;
_AT_@ -63,7 +63,7 @@ zrand_libc_rand48(void *out, size_t n, void *statep)
while (n--) {
r0 = lrand48() & 15;
r1 = lrand48() & 15;
- buf[n] = (r0 << 4) | r1;
+ buf[n] = (unsigned char)((r0 << 4) | r1);
}
(void) statep;
_AT_@ -79,7 +79,7 @@ zrand_libc_random(void *out, size_t n, void *statep)
if (!inited) {
inited = 1;
- srandom((intptr_t)out | time(NULL));
+ srandom((unsigned)((intptr_t)out | time(NULL)));
}
while (n--) {
diff --git a/src/zsqr.c b/src/zsqr.c
index c686348..0b0ff67 100644
--- a/src/zsqr.c
+++ b/src/zsqr.c
_AT_@ -11,8 +11,6 @@ zsqr_impl_single_char(z_t a, z_t b)
SET_SIGNUM(a, 1);
}
-extern void zmul_impl(z_t a, z_t b, z_t c);
-
void
zsqr_impl(z_t a, z_t b)
{
_AT_@ -43,7 +41,7 @@ zsqr_impl(z_t a, z_t b)
high->chars = auxchars + 1;
zsplit_unsigned_fast_small_auto(high, low, b, bits);
} else {
- bits &= ~(BITS_PER_CHAR - 1);
+ bits = TRUNCATE_TO_CHAR(bits);
zsplit_unsigned_fast_large_taint(high, low, b, bits);
}
diff --git a/src/zstr.c b/src/zstr.c
index f919dc8..cd237df 100644
--- a/src/zstr.c
+++ b/src/zstr.c
_AT_@ -22,16 +22,16 @@ sprintint_fix(char *buf, zahl_char_t v)
const char *partials = S2("");
uint16_t *buffer = (uint16_t *)(buf + 1);
- buffer[8] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[7] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[6] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[5] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[4] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[3] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[2] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[1] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- buffer[0] = *(uint16_t *)(partials + 2 * (v % 100)), v /= 100;
- *buf = '0' + v;
+ buffer[8] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[7] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[6] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[5] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[4] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[3] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[2] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[1] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ buffer[0] = *(const uint16_t *)(partials + 2 * (v % 100)), v /= 100;
+ *buf = (char)('0' + v);
buf[19] = 0;
}
_AT_@ -50,7 +50,7 @@ sprintint_min(char *buf, zahl_char_t v)
for (; buf[i] == '0'; i++);
cmemmove(buf, buf + i, j = 19 - i);
buf[j] = 0;
- return j;
+ return (size_t)j;
}
diff --git a/test.c b/test.c
index bcb6815..4e26734 100644
--- a/test.c
+++ b/test.c
_AT_@ -297,7 +297,7 @@ main(void)
zsetu(b, 0);
assert(zcmp(a, b), != 0);
n = zsave(a, buf);
- assert(n, > 0);
+ assert(n > 0, > 0);
assert_zu(zload(b, buf), n);
assert(zcmp(a, b), == 0);
diff --git a/zahl-inlines.h b/zahl-inlines.h
index 8ffa6cb..7c06270 100644
--- a/zahl-inlines.h
+++ b/zahl-inlines.h
_AT_@ -134,15 +134,15 @@ zcmpi(z_t a, int64_t b)
} else {
if (zsignum(a) < 0)
return -1;
- libzahl_tmp_cmp->chars[0] = b;
+ libzahl_tmp_cmp->chars[0] = (zahl_char_t)b;
return +zcmpmag(a, libzahl_tmp_cmp);
}
}
-void zbset_impl_set(z_t a, z_t b, size_t bit);
-void zbset_impl_clear(z_t a, z_t b, size_t bit);
-void zbset_impl_flip(z_t a, z_t b, size_t bit);
+void zbset_impl_set(z_t a, size_t bit);
+void zbset_impl_clear(z_t a, size_t bit);
+void zbset_impl_flip(z_t a, size_t bit);
ZAHL_INLINE void
zbset(z_t a, z_t b, size_t bit, int action)
_AT_@ -174,11 +174,11 @@ fallback:
#endif
if (action > 0)
- zbset_impl_set(a, b, bit);
+ zbset_impl_set(a, bit);
else if (action < 0)
- zbset_impl_flip(a, b, bit);
+ zbset_impl_flip(a, bit);
else
- zbset_impl_clear(a, b, bit);
+ zbset_impl_clear(a, bit);
}
diff --git a/zahl-internals.h b/zahl-internals.h
index 4d3389c..9ac29b2 100644
--- a/zahl-internals.h
+++ b/zahl-internals.h
_AT_@ -27,6 +27,7 @@
#define ZAHL_FLOOR_BITS_TO_CHARS(bits) ((bits) >> ZAHL_LB_BITS_PER_CHAR)
#define ZAHL_CEILING_BITS_TO_CHARS(bits) (((bits) + (ZAHL_BITS_PER_CHAR - 1)) >> ZAHL_LB_BITS_PER_CHAR)
#define ZAHL_BITS_IN_LAST_CHAR(bits) ((bits) & (ZAHL_BITS_PER_CHAR - 1))
+#define ZAHL_TRUNCATE_TO_CHAR(bits) ((bits) & ~(size_t)(ZAHL_BITS_PER_CHAR - 1))
#define ZAHL_SET_SIGNUM(a, signum) ((a)->sign = (signum))
Received on Fri Apr 08 2016 - 16:22:40 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 08 2016 - 16:24:14 CEST