diff options
author | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-12-05 03:25:44 -0800 |
---|---|---|
committer | Graham Percival <graham@percival-music.ca> | 2011-12-05 03:25:44 -0800 |
commit | 863b09e94acb2b3e543cb68b096e8b40db1889f1 (patch) | |
tree | 6134c02ef49c8e93d538843cedb642ed0b27e5a9 /flower | |
parent | a4fb364a0058f701e4e25e799b5ddef511effd72 (diff) |
Fix almost all warnings in flower/ and many in lily/.
Most of the remaining warnings are about vsize -> int casting,
where I'll have to find a proper solution (we don't want to cast
all appearances of vsize to int explicitly, but rather use vsize
wherever possible).
Diffstat (limited to 'flower')
-rw-r--r-- | flower/cpu-timer.cc | 2 | ||||
-rw-r--r-- | flower/file-cookie.cc | 6 | ||||
-rw-r--r-- | flower/getopt-long.cc | 2 | ||||
-rw-r--r-- | flower/include/file-cookie.hh | 10 | ||||
-rw-r--r-- | flower/include/memory-stream.hh | 4 | ||||
-rw-r--r-- | flower/include/polynomial.hh | 2 | ||||
-rw-r--r-- | flower/include/string-convert.hh | 9 | ||||
-rw-r--r-- | flower/memory-stream.cc | 6 | ||||
-rw-r--r-- | flower/polynomial.cc | 20 | ||||
-rw-r--r-- | flower/std-string.cc | 2 | ||||
-rw-r--r-- | flower/string-convert.cc | 20 |
11 files changed, 46 insertions, 37 deletions
diff --git a/flower/cpu-timer.cc b/flower/cpu-timer.cc index a72d5fe7ba..bc95e4b45b 100644 --- a/flower/cpu-timer.cc +++ b/flower/cpu-timer.cc @@ -45,5 +45,5 @@ Real Cpu_timer::read () { clock_t stop = clock (); - return (stop - start_clock_) / Real (CLOCKS_PER_SEC); + return Real (stop - start_clock_) / Real (CLOCKS_PER_SEC); } diff --git a/flower/file-cookie.cc b/flower/file-cookie.cc index 39e76e3516..90aa5c908d 100644 --- a/flower/file-cookie.cc +++ b/flower/file-cookie.cc @@ -23,14 +23,14 @@ extern "C" { return (FILE *) cookie; } - int + ssize_t lily_cookie_fclose (void *file) { assert (is_memory_stream (file)); return Memory_out_stream::cleaner (file); } - int + ssize_t lily_cookie_fprintf (void *file, char const *format, ...) { assert (is_memory_stream (file)); @@ -45,7 +45,7 @@ extern "C" { return Memory_out_stream::writer (file, buf, i); } - int + ssize_t lily_cookie_putc (int c, void *file) { assert (is_memory_stream (file)); diff --git a/flower/getopt-long.cc b/flower/getopt-long.cc index 915509b272..dbabcbcf08 100644 --- a/flower/getopt-long.cc +++ b/flower/getopt-long.cc @@ -54,7 +54,7 @@ Getopt_long::parselong () assert (*optnm); char const *endopt = strchr (optnm, '='); - int searchlen = (endopt) ? endopt - optnm : strlen (optnm); + size_t searchlen = (endopt) ? endopt - optnm : strlen (optnm); found_option_ = 0; for (int i = 0; i < table_len_; i++) diff --git a/flower/include/file-cookie.hh b/flower/include/file-cookie.hh index 462ec6045b..6bdb236699 100644 --- a/flower/include/file-cookie.hh +++ b/flower/include/file-cookie.hh @@ -15,17 +15,17 @@ extern "C" { { ssize_t (*read) (void *, char *, size_t); ssize_t (*write) (void *, char const *, size_t); - int (*seek) (void *, off64_t *, int); - int (*close) (void *); + ssize_t (*seek) (void *, off64_t *, size_t); + ssize_t (*close) (void *); } lily_cookie_io_functions_t; void *lily_fopencookie (void *cookie, char const *modes, lily_cookie_io_functions_t io_funcs); - int lily_cookie_fclose (void *); - int lily_cookie_fprintf (void *file, char const *format, ...) + ssize_t lily_cookie_fclose (void *); + ssize_t lily_cookie_fprintf (void *file, char const *format, ...) __attribute__ ((format (printf, 2, 3))); - int lily_cookie_putc (int c, void *file); + ssize_t lily_cookie_putc (int c, void *file); #ifdef __cplusplus } /* extern "C" */ diff --git a/flower/include/memory-stream.hh b/flower/include/memory-stream.hh index b4114eccf5..9ebe922779 100644 --- a/flower/include/memory-stream.hh +++ b/flower/include/memory-stream.hh @@ -40,8 +40,8 @@ class Memory_out_stream public: static ssize_t reader (void *, char *, size_t); static ssize_t writer (void *, char const *, size_t); - static int seeker (void *, off64_t *, int); - static int cleaner (void *); + static ssize_t seeker (void *, off64_t *, size_t); + static ssize_t cleaner (void *); Memory_out_stream (); ~Memory_out_stream (); diff --git a/flower/include/polynomial.hh b/flower/include/polynomial.hh index c58cb93500..9563acf50c 100644 --- a/flower/include/polynomial.hh +++ b/flower/include/polynomial.hh @@ -32,7 +32,7 @@ struct Polynomial { /// degree of polynomial - int degree ()const; + ssize_t degree ()const; /// coefficients vector<Real> coefs_; diff --git a/flower/include/string-convert.hh b/flower/include/string-convert.hh index 55c14866a1..148005672e 100644 --- a/flower/include/string-convert.hh +++ b/flower/include/string-convert.hh @@ -19,7 +19,7 @@ class String_convert static int hex2nibble (Byte byte); static Byte nibble2hex_byte (Byte byte); public: - static string pad_to (string s, int length); + static string pad_to (string s, size_t length); static string bool_string (bool b); static string bin2dec (string bin_string); static string bin2hex (Byte bin_char); @@ -38,10 +38,11 @@ public: static string hex2bin (string str); static string int_string (int i, char const *fmt = 0); static string unsigned_string (unsigned); + static string unsigned_long_string (unsigned long); static string long_string (long); - static string int2hex (int i, int length_i, char ch); - static string unsigned2hex (unsigned u, ssize length, char ch); - static string int2dec (int i, int length_i, char ch); + static string int2hex (int i, size_t length_i, char ch); + static string unsigned2hex (unsigned u, size_t length, char ch); + static string int2dec (int i, size_t length_i, char ch); static string rational_string (Rational); static string pointer_string (void const *); static string precision_string (double x, int n); diff --git a/flower/memory-stream.cc b/flower/memory-stream.cc index c72eb53947..9d4c747ef5 100644 --- a/flower/memory-stream.cc +++ b/flower/memory-stream.cc @@ -39,7 +39,7 @@ Memory_out_stream::functions_ Memory_out_stream::cleaner }; -int +ssize_t Memory_out_stream::cleaner (void *cookie) { Memory_out_stream *stream = (Memory_out_stream *) cookie; @@ -122,10 +122,10 @@ Memory_out_stream::reader (void * /* cookie */, return 0; } -int +ssize_t Memory_out_stream::seeker (void *, off64_t *, - int) + size_t) { assert (false); return 0; diff --git a/flower/polynomial.cc b/flower/polynomial.cc index 05faf42097..d95258720d 100644 --- a/flower/polynomial.cc +++ b/flower/polynomial.cc @@ -49,11 +49,11 @@ Polynomial::multiply (const Polynomial &p1, const Polynomial &p2) { Polynomial dest; - int deg = p1.degree () + p2.degree (); - for (int i = 0; i <= deg; i++) + ssize_t deg = p1.degree () + p2.degree (); + for (ssize_t i = 0; i <= deg; i++) { dest.coefs_.push_back (0); - for (int j = 0; j <= i; j++) + for (ssize_t j = 0; j <= i; j++) if (i - j <= p2.degree () && j <= p1.degree ()) dest.coefs_.back () += p1.coefs_[j] * p2.coefs_[i - j]; } @@ -177,22 +177,22 @@ Polynomial::set_mod (const Polynomial &u, const Polynomial &v) if (v.lc () < 0.0) { - for (int k = u.degree () - v.degree () - 1; k >= 0; k -= 2) + for (ssize_t k = u.degree () - v.degree () - 1; k >= 0; k -= 2) coefs_[k] = -coefs_[k]; - for (int k = u.degree () - v.degree (); k >= 0; k--) - for (int j = v.degree () + k - 1; j >= k; j--) + for (ssize_t k = u.degree () - v.degree (); k >= 0; k--) + for (ssize_t j = v.degree () + k - 1; j >= k; j--) coefs_[j] = -coefs_[j] - coefs_[v.degree () + k] * v.coefs_[j - k]; } else { - for (int k = u.degree () - v.degree (); k >= 0; k--) - for (int j = v.degree () + k - 1; j >= k; j--) + for (ssize_t k = u.degree () - v.degree (); k >= 0; k--) + for (ssize_t j = v.degree () + k - 1; j >= k; j--) coefs_[j] -= coefs_[v.degree () + k] * v.coefs_[j - k]; } - int k = v.degree () - 1; + ssize_t k = v.degree () - 1; while (k >= 0 && coefs_[k] == 0.0) k--; @@ -328,7 +328,7 @@ Polynomial::lc () return coefs_.back (); } -int +ssize_t Polynomial::degree ()const { return coefs_.size () - 1; diff --git a/flower/std-string.cc b/flower/std-string.cc index 4243f675cb..dbfb0edd83 100644 --- a/flower/std-string.cc +++ b/flower/std-string.cc @@ -59,7 +59,7 @@ to_string (long b) string to_string (long unsigned b) { - return String_convert::unsigned_string (b); + return String_convert::unsigned_long_string (b); } string diff --git a/flower/string-convert.cc b/flower/string-convert.cc index d46426e8c6..68e6a0c0b8 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -158,7 +158,7 @@ String_convert::hex2nibble (Byte byte) // stupido. Should use int_string () string -String_convert::int2dec (int i, int length_i, char ch) +String_convert::int2dec (int i, size_t length_i, char ch) { char fill_char = ch; if (fill_char) @@ -168,12 +168,12 @@ String_convert::int2dec (int i, int length_i, char ch) string dec_string = to_string (i); // ugh - return to_string (fill_char, length_i - dec_string.length ()) + dec_string; + return to_string (fill_char, ssize_t (length_i - dec_string.length ())) + dec_string; } // stupido. Should use int_string () string -String_convert::unsigned2hex (unsigned u, ssize length, char fill_char) +String_convert::unsigned2hex (unsigned u, size_t length, char fill_char) { string str; if (!u) @@ -189,7 +189,7 @@ String_convert::unsigned2hex (unsigned u, ssize length, char fill_char) str += int_string (u, "%x"); // hmm. %lx vs. %x -> portability? #endif - str = to_string (fill_char, length - str.length ()) + str; + str = to_string (fill_char, ssize_t (length - str.length ())) + str; while ((str.length () > length) && (str[ 0 ] == 'f')) str = str.substr (2); @@ -197,7 +197,7 @@ String_convert::unsigned2hex (unsigned u, ssize length, char fill_char) } string -String_convert::int2hex (int i, int length_i, char fill_char) +String_convert::int2hex (int i, size_t length_i, char fill_char) { return unsigned2hex ((unsigned)i, length_i, fill_char); } @@ -344,7 +344,15 @@ String_convert::unsigned_string (unsigned u) } string -String_convert::pad_to (string s, int n) +String_convert::unsigned_long_string (unsigned long ul) +{ + char s[STRING_BUFFER_LEN]; + sprintf (s, "%lu", ul); + return s; +} + +string +String_convert::pad_to (string s, size_t n) { return s + string (max (int (n - s.length ()), 0), ' '); } |