commit 0ca8c822120194d5f7223ae211fec9f3cd437e12
parent f258ad448e470e9f95d907db453d69b186853392
Author: Matt Demanett <matt@demanett.net>
Date: Wed, 3 Jan 2018 18:45:29 -0500
Be less precious about buffer lengths; silences a linux compile warning.
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/Reftone.cpp b/src/Reftone.cpp
@@ -79,15 +79,16 @@ struct ReftoneDisplay : TransparentWidget {
};
void ReftoneDisplay::draw(NVGcontext* vg) {
- char octave[2];
- snprintf(octave, 2, "%d", _module->_octave);
+ const int n = 20;
+ char octave[n];
+ snprintf(octave, n, "%d", _module->_octave);
- char fine[4];
+ char fine[n];
fine[0] = _module->_fine < 0.0 ? '-' : '+';
- snprintf(fine + 1, 3, "%02d", abs((int)(_module->_fine * 100)));
+ snprintf(fine + 1, n - 1, "%02d", abs((int)(_module->_fine * 100)));
char frequency[20];
- snprintf(frequency, 20, "%0.0fhz", _module->_frequency);
+ snprintf(frequency, n, "%0.0fhz", _module->_frequency);
const char* pitch = NULL;
const char* sharpFlat = NULL;