Cppcheck fixes (#6386)
* collector: cgroups: Fix a cppcheck warning
Cppcheck was throwing the following warning in
collectors/cgroups.plugin/cgroup-network.c
[collectors/cgroups.plugin/cgroup-network.c:233]: (warning) Assignment of function parameter has no effect outside the function. Did you forget dereferencing it?
One of the arguments to switch_namespace() is 'const char *prefix', in
this function we were checking if prefix was NULL and if so setting it
(local scope wise) to "".
While this wasn't technically incorrect in this context. It is also
unnecessary as the prefix variable is only passed to the proc_pid_fd()
function where the same check happens, so we can simply remove the
offending line.
Signed-off-by: Andrew Clayton <andrew@zeta.digital-domain.net>
* tests/profile: Remove somewhat redundant code
cppcheck was throwing a warning in benchmark-line-parsing.c
[tests/profile/benchmark-line-parsing.c:648]: (warning) Unnecessary
comparison of static strings, this comes from
(void)strcmp("1", "2");
in main()
That is amongst a group of three function calls preceded by the comment
// cache functions
But then test1() which uses strcmp() is called twice anyway with the
timing result of just the second one used, so the dummy strcmp() call
would seem superfluous.
I would say the same is true for the call to strtoull()
(void)strtoull("123", NULL, 0);
as that is also used in test1().
I actually ran this benchmark with and without the calls to all three
functions, i.e
// cache functions
(void)simple_hash2("hello world");
(void)strcmp("1", "2");
(void)strtoull("123", NULL, 0);
With the above functions being called
test1() average time = 7801604
test2() average time = 1333162
Without those three function calls
test1() average time = 7779905
test2() average time = 1321438
Those are the averages of three runs. test1() uses strcmp() & strtoull()
and test2() uses simple_hash2(), so in that run, not calling the three
functions initially was actually quicker.
Subsequent runs of each show similar numbers with each edging the other
out, however the difference is in the noise.
Signed-off-by: Andrew Clayton <andrew@zeta.digital-domain.net>