Clean-up: common: fix -Wshadow errors in event-field-value.c
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 31 Mar 2021 18:44:06 +0000 (14:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Apr 2021 20:21:58 +0000 (16:21 -0400)
commit9918e00a8a03011c145bb45c35b183c94ec69023
treeb36e559639fed43f996ab5a070e4a7d159381702
parent44635d77b591f83a80d48cd93497bd1cd6aa788d
Clean-up: common: fix -Wshadow errors in event-field-value.c

We get this when building with -Wshadow:

      CC       event-field-value.lo
    In file included from /home/simark/src/lttng-tools/src/common/error.h:19,
                     from /home/simark/src/lttng-tools/src/common/event-field-value.c:17:
    /home/simark/src/lttng-tools/src/common/event-field-value.c: In function ‘lttng_event_field_value_unsigned_int_get_value’:
    /home/simark/src/lttng-tools/src/common/macros.h:55:42: error: declaration of ‘__ptr’ shadows a previous local [-Werror=shadow]
       55 |   const typeof(((type *)NULL)->member) * __ptr = (ptr); \
          |                                          ^~~~~
    /home/simark/src/lttng-tools/src/common/event-field-value.c:390:10: note: in expansion of macro ‘container_of’
      390 |   *val = container_of(
          |          ^~~~~~~~~~~~
    /home/simark/src/lttng-tools/src/common/event-field-value.c:391:5: note: in expansion of macro ‘container_of’
      391 |     container_of(field_val,
          |     ^~~~~~~~~~~~
    /home/simark/src/lttng-tools/src/common/macros.h:55:42: note: shadowed declaration is here
       55 |   const typeof(((type *)NULL)->member) * __ptr = (ptr); \
          |                                          ^~~~~
    /home/simark/src/lttng-tools/src/common/event-field-value.c:390:10: note: in expansion of macro ‘container_of’
      390 |   *val = container_of(
          |          ^~~~~~~~~~~~

This is because of the nested use of container_of, causing two temporary
__ptr variables to be declared in the same scope. Fix it by assigning
results of container_of to temporary variables. I think the temporary
variables make it more readable anyway, showing what's going on.

Change-Id: I7b66bc40227a4c76b7f5416a911dcdc696f4efc8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/event-field-value.c
This page took 0.025697 seconds and 4 git commands to generate.