Fix warning in snprintf and g++7 and above.

This commit is contained in:
Stephen Anthony 2018-08-19 20:46:05 -02:30
parent f87e5d73f1
commit 9037af617d
1 changed files with 3 additions and 3 deletions

View File

@ -50,7 +50,7 @@ string Base::toString(int value, Common::Base::Format outputBase)
case Base::F_2_16: // base 2: 2 bytes (16 bits) wide case Base::F_2_16: // base 2: 2 bytes (16 bits) wide
{ {
int places = (outputBase == Base::F_2_8 || int places = (outputBase == Base::F_2_8 ||
(outputBase == Base::F_2 && value < 0x100)) ? 8 : 16; (outputBase == Base::F_2 && value < 0x100)) ? 8 : 16;
vToS_buf[places] = '\0'; vToS_buf[places] = '\0';
int bit = 1; int bit = 1;
while(--places >= 0) { while(--places >= 0) {
@ -63,9 +63,9 @@ string Base::toString(int value, Common::Base::Format outputBase)
case Base::F_10: // base 10: 3 or 5 bytes (depending on value) case Base::F_10: // base 10: 3 or 5 bytes (depending on value)
if(value < 0x100) if(value < 0x100)
std::snprintf(vToS_buf, 4, "%3d", value); std::snprintf(vToS_buf, 4, "%3d", value & 0xff);
else else
std::snprintf(vToS_buf, 6, "%5d", value); std::snprintf(vToS_buf, 6, "%5d", value & 0xffff);
break; break;
case Base::F_10_02: // base 10: 2 digits (with leading zero) case Base::F_10_02: // base 10: 2 digits (with leading zero)