Skip to content
Commit 9a22d3df authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov
Browse files

pstree: workaround stupidity of modern compilers



gcc v6.0  and clang think that &next->pid.node can't be null.

Here is an explanation from a kernel log (v3.12-5097-g1310a5a):
"""
the result of this expression is not defined by a C standard
and some gcc versions (e.g.  4.3.4) assume the above expression can never
be equal to NULL.  The net result is an oops because the iteration is not
properly terminated.
"""

$ gcc -v
gcc version 6.0.0 20160406 (Red Hat 6.0.0-0.20) (GCC)
$ python test/zdtm.py run  -t zdtm/static/session00
...
$ gdb -c /tmp/core.61 criu/criu
Program terminated with signal SIGSEGV, Segmentation fault.
598			if (&next->pid.node == NULL || next->pid.virt > pid)

$ make CC=clang
pstree.c:598:18: error: comparison of address of 'next->pid.node' equal to a null pointer is always false [-Werror,-Wtautological-pointer-compare]
                if (&next->pid.node == NULL || next->pid.virt > pid)

Signed-off-by: default avatarAndrew Vagin <avagin@virtuozzo.com>
Acked-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: default avatarPavel Emelyanov <xemul@virtuozzo.com>
parent bfe7f6dc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment