]> git.lttng.org Git - lttng-ust.git/commit
fix: clang warning '-Wnull-pointer-subtraction' in lttng_ust_is_pointer_type
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 21 Jul 2022 15:51:11 +0000 (11:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 21 Jul 2022 17:56:37 +0000 (13:56 -0400)
commitbfcbb918834017f74b01fdb61ebc6f9cb3c25b57
treef70c58ad72c56382e898cdc66dbfacd332ee179d
parentd720c2d1aacce6072d7161575f6ed3275067a0ef
fix: clang warning '-Wnull-pointer-subtraction' in lttng_ust_is_pointer_type

Some versions of Clang enable '-Wnull-pointer-subtraction' in '-Wall'
which results in the following message:

././ust-utils-common.h:166:2: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
        ok_is_pointer_type(void *);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~
././ust-utils-common.h:120:5: note: expanded from macro 'ok_is_pointer_type'
        ok(lttng_ust_is_pointer_type(_type) == true, "lttng_ust_is_pointer_type - '" lttng_ust_stringify(_type) "' is a pointer")
        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../include/lttng/ust-utils.h:71:45: note: expanded from macro 'lttng_ust_is_pointer_type'
        (lttng_ust_is_integer_type(typeof(((type)0 - (type)0))) && !lttng_ust_is_integer_type(type))
                                                   ^

Since this macro is used only the determine if the type is a pointer we
can use any value other than NULL and thus not depend on undefined
behavior.

Change-Id: Iab7a182f580ce7431a817ab006ecdf3f1da09ae0
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-utils.h
This page took 0.028479 seconds and 4 git commands to generate.