From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: linux-kselftest@vger.kernel.org
Cc: eva.kurchatova@virtuozzo.com, khorenko@virtuozzo.com
Subject: [PATCH 15/15] selftests/openat2: suppress -Wsign-compare and -Wunused-parameter
Date: Wed, 29 Apr 2026 13:28:11 +0300 [thread overview]
Message-ID: <20260429102811.47214-16-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20260429102811.47214-1-eva.kurchatova@virtuozzo.com>
openat2_test.c: In function ‘test_openat2_struct’:
openat2_test.c:89:27: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
89 | for (int i = 0; i < ARRAY_LEN(tests); i++) {
| ^
openat2_test.c:93:35: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
93 | for (int j = 0; j < ARRAY_LEN(misalignments); j++) {
| ^
openat2_test.c: In function ‘test_openat2_flags’:
openat2_test.c:246:27: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
246 | for (int i = 0; i < ARRAY_LEN(tests); i++) {
| ^
openat2_test.c:296:44: warning: comparison of integer expressions of different
signedness: ‘int’ and ‘__u64’ {aka ‘long long unsigned int’} [-Wsign-compare]
296 | failed |= (fdflags != test->how.flags);
| ^~
openat2_test.c: In function ‘main’:
openat2_test.c:326:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
326 | int main(int argc, char **argv)
| ~~~~^~~~
openat2_test.c:326:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
326 | int main(int argc, char **argv)
| ~~~~~~~^~~~
Use size_t for array loop iterator, explicitly cast open_how flags field
to fix -Wsign-compare warnings
Remove unused argc & argv parameters to fix -Wunused-parameter warnings
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
tools/testing/selftests/openat2/openat2_test.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
index 0e161ef9e9e4..a8b73b62c7c5 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -86,11 +86,11 @@ void test_openat2_struct(void)
BUILD_BUG_ON(ARRAY_LEN(misalignments) != NUM_OPENAT2_STRUCT_VARIATIONS);
BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_STRUCT_TESTS);
- for (int i = 0; i < ARRAY_LEN(tests); i++) {
+ for (size_t i = 0; i < ARRAY_LEN(tests); i++) {
struct struct_test *test = &tests[i];
struct open_how_ext how_ext = test->arg;
- for (int j = 0; j < ARRAY_LEN(misalignments); j++) {
+ for (size_t j = 0; j < ARRAY_LEN(misalignments); j++) {
int fd, misalign = misalignments[j];
char *fdpath = NULL;
bool failed;
@@ -243,7 +243,7 @@ void test_openat2_flags(void)
BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_FLAG_TESTS);
- for (int i = 0; i < ARRAY_LEN(tests); i++) {
+ for (size_t i = 0; i < ARRAY_LEN(tests); i++) {
int fd, fdflags = -1;
char *path, *fdpath = NULL;
bool failed = false;
@@ -293,7 +293,7 @@ void test_openat2_flags(void)
fdflags |= O_CREAT;
if (!(test->how.flags & O_LARGEFILE))
fdflags &= ~O_LARGEFILE;
- failed |= (fdflags != test->how.flags);
+ failed |= (fdflags != (int)test->how.flags);
}
if (failed) {
@@ -323,7 +323,7 @@ void test_openat2_flags(void)
#define NUM_TESTS (NUM_OPENAT2_STRUCT_VARIATIONS * NUM_OPENAT2_STRUCT_TESTS + \
NUM_OPENAT2_FLAG_TESTS)
-int main(int argc, char **argv)
+int main()
{
ksft_print_header();
ksft_set_plan(NUM_TESTS);
--
2.54.0
prev parent reply other threads:[~2026-04-29 10:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
2026-04-29 10:27 ` [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering Eva Kurchatova
2026-04-29 10:27 ` [PATCH 02/15] selftests/prctl: remove unused variable 'j' in set-process-name Eva Kurchatova
2026-04-29 10:27 ` [PATCH 03/15] selftests/netfilter: remove unused variables in conntrack_dump_flush Eva Kurchatova
2026-04-29 10:28 ` [PATCH 04/15] selftests/netfilter: remove unused variable 'plen' in conntrack_reverse_clash Eva Kurchatova
2026-04-29 10:28 ` [PATCH 05/15] selftests/mqueue: fix warnings in mq_perf_tests Eva Kurchatova
2026-04-29 10:28 ` [PATCH 06/15] selftests/mqueue: fix -Wunused-variable warning for 'usage' in mq_open_tests Eva Kurchatova
2026-04-29 10:28 ` [PATCH 07/15] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 08/15] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 09/15] selftests/membarrier: remove unused variable 'i' Eva Kurchatova
2026-04-29 10:28 ` [PATCH 10/15] selftests/epoll: remove unused variable 'pfd' in epoll59 test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 11/15] selftests/clone3: remove unused variables in clone3_cap_checkpoint_restore Eva Kurchatova
2026-04-29 10:28 ` [PATCH 12/15] selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23 Eva Kurchatova
2026-04-29 10:28 ` [PATCH 13/15] selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info Eva Kurchatova
2026-04-29 10:28 ` [PATCH 14/15] selftests/fchmodat2: suppress -Wunused-parameter Eva Kurchatova
2026-04-29 10:28 ` Eva Kurchatova [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429102811.47214-16-eva.kurchatova@virtuozzo.com \
--to=eva.kurchatova@virtuozzo.com \
--cc=khorenko@virtuozzo.com \
--cc=linux-kselftest@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox