[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fixes various warnings from clang++ (issue 5477051)
From: |
graham |
Subject: |
Fixes various warnings from clang++ (issue 5477051) |
Date: |
Fri, 09 Dec 2011 14:21:09 +0000 |
Reviewers: ,
Message:
A few minor fixes; I think they're all ok, but I can't claim any deep
understanding of the code in question.
Regtests were unchanged.
Description:
Fixes various warnings from clang++
These changes leave the regtests unchanged.
This is a branch with a series of commits; 1 commit per file.
Avoid redefining struct String_convert to class.
Avoid comparison of unsigned < 0
PyArg_ParseTuple (args, "s#|i", &track, &track_size, ...
returns the length as an int:
http://docs.python.org/c-api/arg.html#PyArg_ParseTuple
Avoid implicit sign conversion
Remove default comparison for binary search
clang++ complains about this, and we never rely on the default
comparison in our code.
/home/gperciva/src/lilypond/flower/include/std-vector.hh:197:36:
error: 'T' does
not refer to a value
Compare less = less<T> (),
^
/home/gperciva/src/lilypond/flower/include/std-vector.hh:193:19:
note: declared
here
template<typename T, typename Compare>
^
/home/gperciva/src/lilypond/flower/include/std-vector.hh:197:40:
error:
expected expression
Compare less = less<T> (),
Avoid conversion changing signedness
/home/gperciva/src/lilypond/flower/file-cookie.cc:45:50: error: implicit
conversion changes signedness: 'int' to 'size_t' (aka 'unsigned
long')
[-Werror,-Wsign-conversion]
return Memory_out_stream::writer (file, buf, i);
~~~~~~~~~~~~~~~~~ ^
Please review this at http://codereview.appspot.com/5477051/
Affected files:
M flower/file-cookie.cc
M flower/getopt-long.cc
M flower/include/flower-proto.hh
M flower/include/std-vector.hh
M python/midi.c
Index: flower/file-cookie.cc
diff --git a/flower/file-cookie.cc b/flower/file-cookie.cc
index
90aa5c908d0906e320d61116f8525b52db0b484a..762acb1c065d210f92bc3ba0bf1c1087810f3a6c
100644
--- a/flower/file-cookie.cc
+++ b/flower/file-cookie.cc
@@ -39,10 +39,10 @@ extern "C" {
static char buf[65536];
int i = vsnprintf (buf, sizeof (buf), format, ap);
- if (i == -1 || (unsigned) i > sizeof (buf))
+ if (i < 0 || (unsigned) i > sizeof (buf))
assert (false);
va_end (ap);
- return Memory_out_stream::writer (file, buf, i);
+ return Memory_out_stream::writer (file, buf, (unsigned)i);
}
ssize_t
Index: flower/getopt-long.cc
diff --git a/flower/getopt-long.cc b/flower/getopt-long.cc
index
dbabcbcf08111e6ea5f9193b925296193b2e9f42..2ade561cce3f9209584825ae41b592737822d4cc
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, '=');
- size_t searchlen = (endopt) ? endopt - optnm : strlen (optnm);
+ size_t searchlen = (endopt) ? (size_t) (endopt - optnm) : strlen (optnm);
found_option_ = 0;
for (int i = 0; i < table_len_; i++)
@@ -314,9 +314,9 @@ Long_option_init::table_string (Long_option_init *l)
{
string tabstr = "";
- int wid = 0;
+ size_t wid = 0;
for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
- wid = max (int (wid), int (l[i].str_for_help ().length ()));
+ wid = max (wid, l[i].str_for_help ().length ());
for (int i = 0; l[i].shortname_char_ || l[i].longname_str0_; i++)
{
Index: flower/include/flower-proto.hh
diff --git a/flower/include/flower-proto.hh b/flower/include/flower-proto.hh
index
7cdd7d9bf4fe2ff88f83c81b28e53df614f85838..e66c9905626be39e9a03f542ee7f4a73f18be38c
100644
--- a/flower/include/flower-proto.hh
+++ b/flower/include/flower-proto.hh
@@ -24,12 +24,12 @@ char const *flower_version_str0 ();
typedef unsigned char Byte;
typedef long long I64;
-struct String_convert;
+class String_convert;
#include "std-string.hh"
-using namespace std;
#include "real.hh"
+using namespace std;
template<class T> struct Interval_t;
template<class T> struct PQueue;
Index: flower/include/std-vector.hh
diff --git a/flower/include/std-vector.hh b/flower/include/std-vector.hh
index
48b34f12ed90ddc6a777a5c9d03ce2ded9bff6cb..020403aea12bac1cf285028807a830a03e4dc60c
100644
--- a/flower/include/std-vector.hh
+++ b/flower/include/std-vector.hh
@@ -194,7 +194,7 @@ template<typename T, typename Compare>
vsize
binary_search (vector<T> const &v,
T const &key,
- Compare less = less<T> (),
+ Compare less,
vsize b = 0, vsize e = VPOS)
{
vsize lb = lower_bound (v, key, less, b, e);
Index: python/midi.c
diff --git a/python/midi.c b/python/midi.c
index
187268b78efc105fe44dfdeee9c345ea781a3c05..0a8599d0e203d90d22f7e3539c8e4067799ec4d0
100644
--- a/python/midi.c
+++ b/python/midi.c
@@ -356,7 +356,7 @@ static PyObject *
pymidi_parse_track (PyObject *self, PyObject *args)
{
unsigned char *track, *track_end;
- unsigned long track_size;
+ int track_size;
int clocks_max;
debug_print ("%s", "\n");
@@ -398,9 +398,11 @@ midi_parse (unsigned char **midi,unsigned char
*midi_end, int clocks_max)
division = get_number (midi, *midi + 2, 2) * 4;
+ /*
if (division < 0)
- /* return midi_error (cannot handle non-metrical time"); */
+ return midi_error (cannot handle non-metrical time");
;
+ */
*midi += header_len - 6;
pymidi = PyList_New (0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Fixes various warnings from clang++ (issue 5477051),
graham <=