From: Jérémie Galarneau Date: Wed, 24 Jul 2024 17:26:52 +0000 (+0000) Subject: clang-tidy: LTTNG_IOCTL_CHECK can use const return variable X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3d235a437328a2d2e528a657082760dda98b2e43;p=lttng-tools.git clang-tidy: LTTNG_IOCTL_CHECK can use const return variable 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 --- diff --git a/src/common/kernel-ctl/kernel-ctl.cpp b/src/common/kernel-ctl/kernel-ctl.cpp index d3a97ce84..8623e341c 100644 --- a/src/common/kernel-ctl/kernel-ctl.cpp +++ b/src/common/kernel-ctl/kernel-ctl.cpp @@ -22,17 +22,17 @@ #include #include -#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; \ }) /*