1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-14 03:23:29 +00:00

relying on the return value of scanf when using %n is bad

This commit is contained in:
Phil Sutter 2009-05-11 01:25:25 +02:00 committed by Phil Sutter
parent 5d69d0378f
commit 580043075e

View File

@ -1336,8 +1336,8 @@ static struct text_object *construct_text_object(const char *s,
END OBJ(buffers, INFO_BUFFERS)
END OBJ(cached, INFO_BUFFERS)
#define SCAN_CPU(__arg, __var) { \
int __offset; \
if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) == 2) \
int __offset = 0; \
if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
__arg += __offset; \
else \
__var = 0; \