Comment 7 for bug 1716113

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

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.