graphics/nxwidgets: Fix the compiler warning
src/cprogressbar.cxx: In member function 'virtual void NXWidgets::CProgressBar::drawContents(NXWidgets::CGraphicsPort*)': Error: src/cprogressbar.cxx:185:22: error: '%d' directive writing between 1 and 8 bytes into a region of size 6 [-Werror=format-overflow=] 185 | sprintf(text, "%d%%", (100 * m_value) / (m_maximumValue - m_minimumValue)); | ^~ src/cprogressbar.cxx:185:21: note: directive argument in the range [-3276800, 3276800] 185 | sprintf(text, "%d%%", (100 * m_value) / (m_maximumValue - m_minimumValue)); | ^~~~~~ src/cprogressbar.cxx:185:14: note: 'sprintf' output between 3 and 10 bytes into a destination of size 6 185 | sprintf(text, "%d%%", (100 * m_value) / (m_maximumValue - m_minimumValue)); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
18bb3331f3
commit
2385718f1c
@ -181,8 +181,9 @@ void CProgressBar::drawContents(CGraphicsPort *port)
|
||||
|
||||
if (m_showPercentageText)
|
||||
{
|
||||
char text[6];
|
||||
sprintf(text, "%d%%", (100 * m_value) / (m_maximumValue - m_minimumValue));
|
||||
char text[12];
|
||||
snprintf(text, sizeof(text), "%d%%",
|
||||
(100 * m_value) / (m_maximumValue - m_minimumValue));
|
||||
|
||||
struct nxgl_point_s pos;
|
||||
pos.x = rect.getX() +
|
||||
|
Loading…
Reference in New Issue
Block a user