From 3c22041ee8dd450ce446620eb559a07e34f44343 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Aug 2021 13:57:52 +0100 Subject: Add -Wpedantic --- lib/compileTimeFormatter.h | 22 +++++++++++----------- lib/mysql_types.cpp | 36 ++++++++++++++++++------------------ lib/rawDataReader.cpp | 8 +++++--- 3 files changed, 34 insertions(+), 32 deletions(-) (limited to 'lib') diff --git a/lib/compileTimeFormatter.h b/lib/compileTimeFormatter.h index 7d69d4b..341e229 100644 --- a/lib/compileTimeFormatter.h +++ b/lib/compileTimeFormatter.h @@ -99,15 +99,15 @@ namespace MyGrate { } }; -#define StreamWriterT(C...) \ +#define StreamWriterT(...) \ template \ - struct StreamWriter : \ - public StreamWriterBase + struct StreamWriter : \ + public StreamWriterBase -#define StreamWriterTP(P, C...) \ +#define StreamWriterTP(P, ...) \ template \ - struct StreamWriter : \ - public StreamWriterBase + struct StreamWriter : \ + public StreamWriterBase // Default stream writer formatter StreamWriterT('?') { @@ -300,7 +300,7 @@ namespace MyGrate { BASICCONV(BASE, OP, CONV); \ BASICCONV(short BASE, OP, 'h', CONV); \ BASICCONV(long BASE, OP, 'l', CONV); \ - BASICCONV(long long BASE, OP, 'l', 'l', CONV); + BASICCONV(long long BASE, OP, 'l', 'l', CONV) INTCONV(int, s << std::dec << p, 'i'); INTCONV(int, s << std::dec << p, 'd'); INTCONV(unsigned int, s << std::oct << p, 'o'); @@ -323,7 +323,7 @@ namespace MyGrate { // Floating point (a, A, e, E, f, F, g, G) #define FPCONV(BASE, OP, CONV) \ BASICCONV(BASE, OP, CONV); \ - BASICCONV(long BASE, OP, 'L', CONV); + BASICCONV(long BASE, OP, 'L', CONV) FPCONV(double, s << std::nouppercase << std::hexfloat << p, 'a'); FPCONV(double, s << std::uppercase << std::hexfloat << p, 'A'); FPCONV(double, s << std::nouppercase << std::scientific << p, 'e'); @@ -415,7 +415,7 @@ namespace MyGrate { StreamWriter::write(s, pn...); \ } \ }; - BOOST_PP_REPEAT(6, FMTWIDTH, void); + BOOST_PP_REPEAT(6, FMTWIDTH, void) #define FMTPRECISION(unused, d, data) \ template \ @@ -431,7 +431,7 @@ namespace MyGrate { StreamWriter::write(s, pn...); \ } \ }; - BOOST_PP_REPEAT(6, FMTPRECISION, void); + BOOST_PP_REPEAT(6, FMTPRECISION, void) #undef AUTON #undef NS #undef ISDIGIT @@ -467,7 +467,7 @@ namespace MyGrate { OP; \ StreamWriter::write(s, pn...); \ } \ - }; + } FLAGCONV(s << std::showbase, '#'); FLAGCONV(s << std::setfill('0'), '0'); FLAGCONV(s << std::left, '-'); diff --git a/lib/mysql_types.cpp b/lib/mysql_types.cpp index 4480d23..626e789 100644 --- a/lib/mysql_types.cpp +++ b/lib/mysql_types.cpp @@ -15,8 +15,8 @@ namespace MyGrate::MySQL { x = bswap_##B(x); \ return x; \ } - NTOH(32); - NTOH(64); + NTOH(32) + NTOH(64) typename Type::C Type::read(RawDataReader &, RawDataReader &) @@ -33,10 +33,10 @@ namespace MyGrate::MySQL { { \ return data.readValue::C>(); \ } - INTEGER_TYPE(MYSQL_TYPE_TINY); - INTEGER_TYPE(MYSQL_TYPE_SHORT); - INTEGER_TYPE(MYSQL_TYPE_LONG); - INTEGER_TYPE(MYSQL_TYPE_LONGLONG); + INTEGER_TYPE(MYSQL_TYPE_TINY) + INTEGER_TYPE(MYSQL_TYPE_SHORT) + INTEGER_TYPE(MYSQL_TYPE_LONG) + INTEGER_TYPE(MYSQL_TYPE_LONGLONG) #undef INTEGER_TYPE #define FLOAT_TYPE(ET) \ @@ -45,8 +45,8 @@ namespace MyGrate::MySQL { verify(sizeof(typename Type::C) == md.readValue(), "Invalid " #ET " size"); \ return data.readValue::C>(); \ } - FLOAT_TYPE(MYSQL_TYPE_FLOAT); - FLOAT_TYPE(MYSQL_TYPE_DOUBLE); + FLOAT_TYPE(MYSQL_TYPE_FLOAT) + FLOAT_TYPE(MYSQL_TYPE_DOUBLE) #undef FLOAT_TYPE typename Type::C @@ -66,8 +66,8 @@ namespace MyGrate::MySQL { { \ return data.readValue::C, l>(); \ } - INTEGER_TYPE(MYSQL_TYPE_INT24, false, 3); - INTEGER_TYPE(MYSQL_TYPE_INT24, true, 3); + INTEGER_TYPE(MYSQL_TYPE_INT24, false, 3) + INTEGER_TYPE(MYSQL_TYPE_INT24, true, 3) #undef INTEGER_TYPE typename Type::C @@ -92,10 +92,10 @@ namespace MyGrate::MySQL { { \ return readBlob(md, data); \ } - BLOB_TYPE(MYSQL_TYPE_TINY_BLOB); - BLOB_TYPE(MYSQL_TYPE_MEDIUM_BLOB); - BLOB_TYPE(MYSQL_TYPE_LONG_BLOB); - BLOB_TYPE(MYSQL_TYPE_GEOMETRY); // Ummm, pass this to the target to handle? + BLOB_TYPE(MYSQL_TYPE_TINY_BLOB) + BLOB_TYPE(MYSQL_TYPE_MEDIUM_BLOB) + BLOB_TYPE(MYSQL_TYPE_LONG_BLOB) + BLOB_TYPE(MYSQL_TYPE_GEOMETRY) // Ummm, pass this to the target to handle? #undef BLOB_TYPE typename Type::C @@ -126,10 +126,10 @@ namespace MyGrate::MySQL { } \ throw std::logic_error("Didn't return a value: " + std::to_string(realtype)); \ } - STRING_TYPE(MYSQL_TYPE_STRING); - STRING_TYPE(MYSQL_TYPE_JSON); - STRING_TYPE(MYSQL_TYPE_SET); - STRING_TYPE(MYSQL_TYPE_ENUM); + STRING_TYPE(MYSQL_TYPE_STRING) + STRING_TYPE(MYSQL_TYPE_JSON) + STRING_TYPE(MYSQL_TYPE_SET) + STRING_TYPE(MYSQL_TYPE_ENUM) #undef STRING_TYPE typename Type::C diff --git a/lib/rawDataReader.cpp b/lib/rawDataReader.cpp index 90e227a..c0f32b5 100644 --- a/lib/rawDataReader.cpp +++ b/lib/rawDataReader.cpp @@ -26,9 +26,11 @@ namespace MyGrate { uint64_t RawDataReader::readValue() { - switch (const auto byte1 {readValue()}) { - case 0 ... 250: // The value as-is - return byte1; + const auto byte1 {readValue()}; + if (byte1 <= 250) { + return byte1; + } + switch (byte1) { case 252: // 2 bytes return readValue(); case 253: // 3 bytes -- cgit v1.2.3