Fix: tests: `-Wstringop-overflow` warning
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Mon, 4 May 2020 19:59:22 +0000 (15:59 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 5 May 2020 17:39:25 +0000 (13:39 -0400)
commit90667ac0b737be510fa63535a64f66f96e85e2fa
tree03cd9da3d2dd50282ead6417ba31e1106eb17f3d
parent92dbeff150951f4827c209028cacd035caf15288
Fix: tests: `-Wstringop-overflow` warning

I get the following warning when compiling with `-Wall -Werror` with gcc
9.3.0:
  In file included from ../../src/common/macros.h:15,
                   from ../../src/common/lttng-kernel.h:14,
                   from ../../src/bin/lttng-sessiond/trace-kernel.h:14,
                   from test_kernel_data.c:16:
  In function ‘lttng_strnlen’,
      inlined from ‘lttng_strncpy’ at ../../src/common/macros.h:120:6,
      inlined from ‘test_create_kernel_event’ at test_kernel_data.c:136:2:
  ../../src/common/compat/string.h:28:8: error: ‘memchr’ reading 256 bytes from a region of size 11 [-Werror=stringop-overflow=]
     28 |  end = memchr(str, 0, max);
       |        ^~~~~~~~~~~~~~~~~~~

Fix this warning by using the RANDOM_STRING_LEN value as the max number
of bytes to copy.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I61752ee17163c4d642aad21b296c0fc4fad5b7a6
(cherry picked from commit 1dd622b10db0821d77490c937caee80c65332f14)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/unit/test_kernel_data.c
This page took 0.025447 seconds and 4 git commands to generate.