Fix -pedantic warnings.
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Tue, 5 Aug 2014 08:11:35 +0000 (10:11 +0200)
committerMathis Rosenhauer <rosenhauer@dkrz.de>
Wed, 6 Aug 2014 11:39:08 +0000 (13:39 +0200)
src/aec.c
src/decode.c
src/encode.c

index 2ac5fb4..14d9569 100644 (file)
--- a/src/aec.c
+++ b/src/aec.c
@@ -58,7 +58,7 @@
 
 #define CHUNK 10485760
 
-int get_param(int *param, int *iarg, char *argv[])
+int get_param(unsigned int *param, int *iarg, char *argv[])
 {
     if (strlen(argv[*iarg]) == 2) {
         (*iarg)++;
@@ -78,7 +78,8 @@ int main(int argc, char *argv[])
     unsigned char *in;
     unsigned char *out;
     size_t total_out;
-    int chunk, status;
+    unsigned int chunk;
+    int status;
     int input_avail, output_avail;
     char *infn, *outfn;
     FILE *infp, *outfp;
index eea6542..f636c3a 100644 (file)
@@ -82,7 +82,7 @@
                 state->last_out = *state->rsi_buffer;                   \
                                                                         \
                 if (strm->flags & AEC_DATA_SIGNED) {                    \
-                    m = 1ULL << (strm->bits_per_sample - 1);            \
+                    m = UINT64_C(1) << (strm->bits_per_sample - 1);     \
                     /* Reference samples have to be sign extended */    \
                     state->last_out = (state->last_out ^ m) - m;        \
                 }                                                       \
@@ -251,7 +251,7 @@ static inline uint32_t direct_get(struct aec_stream *strm, int n)
         fill_acc(strm);
 
     state->bitp -= n;
-    return (state->acc >> state->bitp) & ((1ULL << n) - 1);
+    return (state->acc >> state->bitp) & ((UINT64_C(1) << n) - 1);
 }
 
 static inline uint32_t direct_get_fs(struct aec_stream *strm)
@@ -271,7 +271,7 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
 #endif
     struct internal_state *state = strm->state;
 
-    state->acc &= ((1ULL << state->bitp) - 1);
+    state->acc &= ((UINT64_C(1) << state->bitp) - 1);
 
     while (state->acc == 0) {
         fs += state->bitp;
@@ -289,7 +289,7 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
     state->bitp = lz;
 #else
     state->bitp--;
-    while ((state->acc & (1ULL << state->bitp)) == 0) {
+    while ((state->acc & (UINT64_C(1) << state->bitp)) == 0) {
         state->bitp--;
         fs++;
     }
@@ -313,7 +313,7 @@ static inline uint32_t bits_ask(struct aec_stream *strm, int n)
 static inline uint32_t bits_get(struct aec_stream *strm, int n)
 {
     return (strm->state->acc >> (strm->state->bitp - n))
-        & ((1ULL << n) - 1);
+        & ((UINT64_C(1) << n) - 1);
 }
 
 static inline void bits_drop(struct aec_stream *strm, int n)
@@ -325,7 +325,7 @@ static inline uint32_t fs_ask(struct aec_stream *strm)
 {
     if (bits_ask(strm, 1) == 0)
         return 0;
-    while ((strm->state->acc & (1ULL << (strm->state->bitp - 1))) == 0) {
+    while ((strm->state->acc & (UINT64_C(1) << (strm->state->bitp - 1))) == 0) {
         if (strm->state->bitp == 1) {
             if (strm->avail_in == 0)
                 return 0;
@@ -703,11 +703,11 @@ int aec_decode_init(struct aec_stream *strm)
     }
 
     if (strm->flags & AEC_DATA_SIGNED) {
-        state->xmin = -(1LL << (strm->bits_per_sample - 1));
-        state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
+        state->xmin = -(INT64_C(1) << (strm->bits_per_sample - 1));
+        state->xmax = (UINT64_C(1) << (strm->bits_per_sample - 1)) - 1;
     } else {
         state->xmin = 0;
-        state->xmax = (1ULL << strm->bits_per_sample) - 1;
+        state->xmax = (UINT64_C(1) << strm->bits_per_sample) - 1;
     }
 
     state->in_blklen = (strm->block_size * strm->bits_per_sample
index 0daadd8..8046326 100644 (file)
@@ -136,7 +136,7 @@ static inline void emitblock_fs(struct aec_stream *strm, int k, int ref)
             acc = 0;
             used -= 64;
         }
-        acc |= 1ULL << (63 - used);
+        acc |= UINT64_C(1) << (63 - used);
     }
 
     copy64(state->cds, acc);
@@ -154,7 +154,7 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
     struct internal_state *state = strm->state;
     uint32_t *in = state->block + ref;
     uint32_t *in_end = state->block + strm->block_size;
-    uint64_t mask = (1ULL << k) - 1;
+    uint64_t mask = (UINT64_C(1) << k) - 1;
     uint8_t *o = state->cds;
     int p = state->bits;
 
@@ -283,7 +283,7 @@ static void preprocess_signed(struct aec_stream *strm)
     struct internal_state *state = strm->state;
     uint32_t *restrict d = state->data_pp;
     int32_t *restrict x = (int32_t *)state->data_raw;
-    uint32_t m = 1ULL << (strm->bits_per_sample - 1);
+    uint32_t m = UINT64_C(1) << (strm->bits_per_sample - 1);
     int64_t xmax = state->xmax;
     int64_t xmin = state->xmin;
     uint32_t rsi = strm->rsi * strm->block_size - 1;
@@ -853,12 +853,12 @@ int aec_encode_init(struct aec_stream *strm)
     state->rsi_len = strm->rsi * strm->block_size * state->bytes_per_sample;
 
     if (strm->flags & AEC_DATA_SIGNED) {
-        state->xmin = -(1LL << (strm->bits_per_sample - 1));
-        state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
+        state->xmin = -(INT64_C(1) << (strm->bits_per_sample - 1));
+        state->xmax = (UINT64_C(1) << (strm->bits_per_sample - 1)) - 1;
         state->preprocess = preprocess_signed;
     } else {
         state->xmin = 0;
-        state->xmax = (1ULL << strm->bits_per_sample) - 1;
+        state->xmax = (UINT64_C(1) << strm->bits_per_sample) - 1;
         state->preprocess = preprocess_unsigned;
     }