Pulse: Fix -Wformat-overflow

Gcc8 x86_64 warns sprintf() output between 2 and 9 bytes
into a destination of size 4. But, sprintf output can be
within 4 bytes since SMP_MAX_CPUS is 64 max.
So replace sprintf() with snprintf() and modify
format string to fix Wformat-overflow.

Change-Id: I7a23e6d98a5dd02a32a5aae573947a5650c82f7f
Reviewed-on: https://review.haiku-os.org/446
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Murai Takashi 2018-08-04 09:15:43 +09:00 committed by waddlesplash
parent 7c423844de
commit 30ee7c9dba

View File

@ -80,7 +80,7 @@ NormalPulseView::NormalPulseView(BRect rect)
CPUBUTTON_MLEFT + CPUBUTTON_WIDTH + 7,
CPUBUTTON_MTOP + ITEM_OFFSET * x + CPUBUTTON_HEIGHT + 7);
char temp[4];
sprintf(temp, "%d", x + 1);
snprintf(temp, sizeof(temp), "%hhd", x + 1);
fCpuButtons[x] = new CPUButton(r, B_TRANSLATE("Pulse"), temp, NULL);
AddChild(fCpuButtons[x]);
}