Closed ihsinme closed 2 years ago
Of course, code is correct, I just wonder under which circumstances could scanning of "%s %lu"
in /proc/stat
fail. Found by static analysis or really an error during testing?
FYI we prefer patches on ML: http://lists.linux.it/listinfo/ltp (https://github.com/linux-test-project/ltp#developers-corner).
The change itself looks fine.
Really though, we should check the result of sscanf
. Also I think this test needs to be converted to the new API.
Good afternoon. Sorry for the delay, could you elaborate on my next steps. Thanks to.
@richiejp going to merge this, can I add your Reviewed-by:
tag?
https://github.com/pevik/ltp/commit/3571296d225bd93b6fc049b89a49b90a10600133
in your code, you don't initialize
val
and you don't check the result of runningsscanf
. therefore, in case of an incorrect call tosscanf
, functionget_num_switches
may return a random value. the easiest fix is to initializeval
to zero