aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Paland <marco@paland.com>2018-05-11 13:18:15 +0200
committerMarco Paland <marco@paland.com>2018-05-11 13:18:15 +0200
commit277aa259fcfa3fb4f6a92c6d8832453ae693b869 (patch)
tree850155ddc49b10ced712d744dd756bd92bd21a97
parentbb5a8af50748b8846ce6d29063ef0747ca4cff86 (diff)
downloadprintf-277aa259fcfa3fb4f6a92c6d8832453ae693b869.tar.gz
printf-277aa259fcfa3fb4f6a92c6d8832453ae693b869.tar.bz2
printf-277aa259fcfa3fb4f6a92c6d8832453ae693b869.zip
fix(printf,test_suite): fix compiler warnings
-rw-r--r--printf.c8
-rw-r--r--test/test_suite.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/printf.c b/printf.c
index 5ba4748..8fe7048 100644
--- a/printf.c
+++ b/printf.c
@@ -293,12 +293,12 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
}
if (prec == 0U) {
- diff = value - whole;
+ diff = value - (double)whole;
if (diff > 0.5) {
// greater than 0.5, round up, e.g. 1.6 -> 2
++whole;
}
- else if ((diff == 0.5) && (whole & 1U)) {
+ else if ((diff == 0.5) && (whole & 1)) {
// exactly 0.5 and ODD, then round up
// 1.5 -> 2, but 2.5 -> 2
++whole;
@@ -528,7 +528,7 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags);
}
else {
- const int value = (flags & FLAGS_CHAR) ? va_arg(va, char) : (flags & FLAGS_SHORT) ? va_arg(va, short int) : va_arg(va, int);
+ const int value = (flags & FLAGS_CHAR) ? (char)va_arg(va, int) : (flags & FLAGS_SHORT) ? (short int)va_arg(va, int) : va_arg(va, int);
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned int)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags);
}
}
@@ -543,7 +543,7 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
idx = _ntoa_long(out, buffer, idx, maxlen, va_arg(va, unsigned long), false, base, precision, width, flags);
}
else {
- const unsigned int value = (flags & FLAGS_CHAR) ? va_arg(va, unsigned char) : (flags & FLAGS_SHORT) ? va_arg(va, unsigned short int) : va_arg(va, unsigned int);
+ const unsigned int value = (flags & FLAGS_CHAR) ? (unsigned char)va_arg(va, unsigned int) : (flags & FLAGS_SHORT) ? (unsigned short int)va_arg(va, unsigned int) : va_arg(va, unsigned int);
idx = _ntoa_long(out, buffer, idx, maxlen, value, false, base, precision, width, flags);
}
}
diff --git a/test/test_suite.cpp b/test/test_suite.cpp
index 21eb13f..c801c5f 100644
--- a/test/test_suite.cpp
+++ b/test/test_suite.cpp
@@ -894,7 +894,7 @@ TEST_CASE("float", "[]" ) {
test::sprintf(buffer, "%.1f", 42.5);
REQUIRE(!strcmp(buffer, "42.5"));
- test::sprintf(buffer, "%f", (float)42167);
+ test::sprintf(buffer, "%f", 42167.0);
REQUIRE(!strcmp(buffer, "42167.000000"));
test::sprintf(buffer, "%.9f", -12345.987654321);
@@ -1069,7 +1069,7 @@ TEST_CASE("buffer length", "[]" ) {
REQUIRE(buffer[0] == (char)0xA5);
REQUIRE(ret == 4);
- buffer[0] = 0xCC;
+ buffer[0] = (char)0xCC;
test::snprintf(buffer, 1, "%s", "Test");
REQUIRE(buffer[0] == '\0');