Ok, as expected it is the '\0' suffix in non-human mode.

Broken since:
https://github.com/sysstat/sysstat/commit/33557c3db463ac6efb337a67dd5f099609d62b30

You can not have an "empty" char constant like ''.
But '\0' is literal "00" byte.
So that is the error.

Instead this should use '%' or '' as a string.

Simple reference program:
cat test.c
#include<stdio.h>

int main()
{
    static const char percent[] = "%";
    static const char empty[] = "";
    static const char *unit = empty;
    printf("FOO%s", unit);
    unit = percent;
    printf("BAR%s", unit);
}

That would output % or nothing.
$ ./test > foo
$ hexdump -C foo
00000000  46 4f 4f 42 41 52 25                              |FOOBAR%|
00000007

There are a dozen ways to do string constants in programs (static consts, 
DEFINES, ...).
I'll suggest the way closest to the current code upstream and we can follow the 
outcome of the discussion.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1716113

Title:
  pidstat outputs to log with invalid characters

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/sysstat/+bug/1716113/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to