clang-tidy: LTTNG_IOCTL_CHECK can use const return variable
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 24 Jul 2024 17:26:52 +0000 (17:26 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Jul 2024 01:26:51 +0000 (01:26 +0000)
clang-tidy reports:
kernel-ctl/kernel-ctl.cpp:70:9: warning: variable '_ioctl_ret' of type 'int' can be declared 'const' [misc-const-correctness]

Change-Id: I87ca5168eeca6af3e9ec459a1887493df1a51793
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/kernel-ctl/kernel-ctl.cpp

index d3a97ce843f5bd860a8967c2ac9a64bd3ee0e631..8623e341c84f308abfb015209b3b25b2be93847f 100644 (file)
 #include <string.h>
 #include <sys/ioctl.h>
 
-#define LTTNG_IOCTL_CHECK(fildes, request, ...)                         \
-       ({                                                              \
-               int _ioctl_ret = ioctl(fildes, request, ##__VA_ARGS__); \
-               LTTNG_ASSERT(_ioctl_ret <= 0);                          \
-               !_ioctl_ret ? 0 : -errno;                               \
+#define LTTNG_IOCTL_CHECK(fildes, request, ...)                               \
+       ({                                                                    \
+               const int _ioctl_ret = ioctl(fildes, request, ##__VA_ARGS__); \
+               LTTNG_ASSERT(_ioctl_ret <= 0);                                \
+               !_ioctl_ret ? 0 : -errno;                                     \
        })
 
-#define LTTNG_IOCTL_NO_CHECK(fildes, request, ...)                      \
-       ({                                                              \
-               int _ioctl_ret = ioctl(fildes, request, ##__VA_ARGS__); \
-               _ioctl_ret >= 0 ? _ioctl_ret : -errno;                  \
+#define LTTNG_IOCTL_NO_CHECK(fildes, request, ...)                            \
+       ({                                                                    \
+               const int _ioctl_ret = ioctl(fildes, request, ##__VA_ARGS__); \
+               _ioctl_ret >= 0 ? _ioctl_ret : -errno;                        \
        })
 
 /*
This page took 0.026403 seconds and 4 git commands to generate.