From 74086863706893ca7abf2230cee1585d47803078 Mon Sep 17 00:00:00 2001 From: TapTap Date: Thu, 24 Sep 2026 01:38:56 +0200 Subject: [PATCH] test: fix cppcheck style findings in cycle-F tests --- rc/a.txt | 1 + rc/link | 1 + rc/sub/b.txt | 1 + rd/a.txt | 1 + rd/link | 1 + rd/sub/b.txt | 1 + src/shared/file.c | 2 +- test_probe/dst/workspace/test_probe/src/a.txt | 1 + test_probe/dst/workspace/test_probe/src/extra.txt | 1 + .../dst/workspace/test_probe/src/extradir/in.txt | 1 + test_probe/dst/workspace/test_probe/src/extralink | 1 + test_probe/dst/workspace/test_probe/src/link | 1 + test_probe/dst/workspace/test_probe/src/sub/b.txt | 1 + .../dst/workspace/test_probe/src/sub/deep/d.txt | 1 + test_probe/dst/workspace/test_probe/src/sub/rel | 1 + test_probe/src/a.txt | 1 + test_probe/src/link | 1 + test_probe/src/sub/b.txt | 1 + test_probe/src/sub/deep/d.txt | 1 + test_probe/src/sub/rel | 1 + test_probe2/dst/workspace/test_probe2/src/a.txt | 1 + .../dst/workspace/test_probe2/src/sub/b.txt | 1 + test_probe2/src/a.txt | 1 + test_probe2/src/sub/b.txt | 1 + test_probe3/dst/workspace/test_probe3/src/a.txt | 1 + .../dst/workspace/test_probe3/src/sub/b.txt | 1 + test_probe3/src/a.txt | 1 + test_probe3/src/sub/b.txt | 1 + tests/test_delay_updates.c | 1 + tests/test_file.c | 14 +++++++++++++- 30 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 rc/a.txt create mode 120000 rc/link create mode 100644 rc/sub/b.txt create mode 100644 rd/a.txt create mode 120000 rd/link create mode 100644 rd/sub/b.txt create mode 100644 test_probe/dst/workspace/test_probe/src/a.txt create mode 100644 test_probe/dst/workspace/test_probe/src/extra.txt create mode 100644 test_probe/dst/workspace/test_probe/src/extradir/in.txt create mode 120000 test_probe/dst/workspace/test_probe/src/extralink create mode 120000 test_probe/dst/workspace/test_probe/src/link create mode 100644 test_probe/dst/workspace/test_probe/src/sub/b.txt create mode 100644 test_probe/dst/workspace/test_probe/src/sub/deep/d.txt create mode 120000 test_probe/dst/workspace/test_probe/src/sub/rel create mode 100644 test_probe/src/a.txt create mode 120000 test_probe/src/link create mode 100644 test_probe/src/sub/b.txt create mode 100644 test_probe/src/sub/deep/d.txt create mode 120000 test_probe/src/sub/rel create mode 100644 test_probe2/dst/workspace/test_probe2/src/a.txt create mode 100644 test_probe2/dst/workspace/test_probe2/src/sub/b.txt create mode 100644 test_probe2/src/a.txt create mode 100644 test_probe2/src/sub/b.txt create mode 100644 test_probe3/dst/workspace/test_probe3/src/a.txt create mode 100644 test_probe3/dst/workspace/test_probe3/src/sub/b.txt create mode 100644 test_probe3/src/a.txt create mode 100644 test_probe3/src/sub/b.txt diff --git a/rc/a.txt b/rc/a.txt new file mode 100644 index 0000000..bf1a1fd --- /dev/null +++ b/rc/a.txt @@ -0,0 +1 @@ +top diff --git a/rc/link b/rc/link new file mode 120000 index 0000000..19acdd8 --- /dev/null +++ b/rc/link @@ -0,0 +1 @@ +b.txt \ No newline at end of file diff --git a/rc/sub/b.txt b/rc/sub/b.txt new file mode 100644 index 0000000..79c5395 --- /dev/null +++ b/rc/sub/b.txt @@ -0,0 +1 @@ +nested diff --git a/rd/a.txt b/rd/a.txt new file mode 100644 index 0000000..bf1a1fd --- /dev/null +++ b/rd/a.txt @@ -0,0 +1 @@ +top diff --git a/rd/link b/rd/link new file mode 120000 index 0000000..19acdd8 --- /dev/null +++ b/rd/link @@ -0,0 +1 @@ +b.txt \ No newline at end of file diff --git a/rd/sub/b.txt b/rd/sub/b.txt new file mode 100644 index 0000000..79c5395 --- /dev/null +++ b/rd/sub/b.txt @@ -0,0 +1 @@ +nested diff --git a/src/shared/file.c b/src/shared/file.c index b9cafc8..fa38b4d 100644 --- a/src/shared/file.c +++ b/src/shared/file.c @@ -424,7 +424,7 @@ static int file_spool_create(const char* dest_path, char** out_spool_path) { continue; } char* copy = str_dup(dest_path); - char* dir = copy ? dirname(copy) : NULL; + const char* dir = copy ? dirname(copy) : NULL; size_t need = dir ? strlen(dir) + 1 + strlen(name) + 1 : 0; char* full = need ? malloc(need) : NULL; if (!full) { diff --git a/test_probe/dst/workspace/test_probe/src/a.txt b/test_probe/dst/workspace/test_probe/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe/dst/workspace/test_probe/src/extra.txt b/test_probe/dst/workspace/test_probe/src/extra.txt new file mode 100644 index 0000000..587be6b --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/extra.txt @@ -0,0 +1 @@ +x diff --git a/test_probe/dst/workspace/test_probe/src/extradir/in.txt b/test_probe/dst/workspace/test_probe/src/extradir/in.txt new file mode 100644 index 0000000..975fbec --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/extradir/in.txt @@ -0,0 +1 @@ +y diff --git a/test_probe/dst/workspace/test_probe/src/extralink b/test_probe/dst/workspace/test_probe/src/extralink new file mode 120000 index 0000000..8d14cbf --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/extralink @@ -0,0 +1 @@ +a.txt \ No newline at end of file diff --git a/test_probe/dst/workspace/test_probe/src/link b/test_probe/dst/workspace/test_probe/src/link new file mode 120000 index 0000000..19acdd8 --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/link @@ -0,0 +1 @@ +b.txt \ No newline at end of file diff --git a/test_probe/dst/workspace/test_probe/src/sub/b.txt b/test_probe/dst/workspace/test_probe/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/test_probe/dst/workspace/test_probe/src/sub/deep/d.txt b/test_probe/dst/workspace/test_probe/src/sub/deep/d.txt new file mode 100644 index 0000000..4cdb226 --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/sub/deep/d.txt @@ -0,0 +1 @@ +deep diff --git a/test_probe/dst/workspace/test_probe/src/sub/rel b/test_probe/dst/workspace/test_probe/src/sub/rel new file mode 120000 index 0000000..d8b329f --- /dev/null +++ b/test_probe/dst/workspace/test_probe/src/sub/rel @@ -0,0 +1 @@ +../a.txt \ No newline at end of file diff --git a/test_probe/src/a.txt b/test_probe/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe/src/link b/test_probe/src/link new file mode 120000 index 0000000..19acdd8 --- /dev/null +++ b/test_probe/src/link @@ -0,0 +1 @@ +b.txt \ No newline at end of file diff --git a/test_probe/src/sub/b.txt b/test_probe/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/test_probe/src/sub/deep/d.txt b/test_probe/src/sub/deep/d.txt new file mode 100644 index 0000000..4cdb226 --- /dev/null +++ b/test_probe/src/sub/deep/d.txt @@ -0,0 +1 @@ +deep diff --git a/test_probe/src/sub/rel b/test_probe/src/sub/rel new file mode 120000 index 0000000..d8b329f --- /dev/null +++ b/test_probe/src/sub/rel @@ -0,0 +1 @@ +../a.txt \ No newline at end of file diff --git a/test_probe2/dst/workspace/test_probe2/src/a.txt b/test_probe2/dst/workspace/test_probe2/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe2/dst/workspace/test_probe2/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe2/dst/workspace/test_probe2/src/sub/b.txt b/test_probe2/dst/workspace/test_probe2/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe2/dst/workspace/test_probe2/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/test_probe2/src/a.txt b/test_probe2/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe2/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe2/src/sub/b.txt b/test_probe2/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe2/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/test_probe3/dst/workspace/test_probe3/src/a.txt b/test_probe3/dst/workspace/test_probe3/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe3/dst/workspace/test_probe3/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe3/dst/workspace/test_probe3/src/sub/b.txt b/test_probe3/dst/workspace/test_probe3/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe3/dst/workspace/test_probe3/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/test_probe3/src/a.txt b/test_probe3/src/a.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/test_probe3/src/a.txt @@ -0,0 +1 @@ +hello diff --git a/test_probe3/src/sub/b.txt b/test_probe3/src/sub/b.txt new file mode 100644 index 0000000..cc628cc --- /dev/null +++ b/test_probe3/src/sub/b.txt @@ -0,0 +1 @@ +world diff --git a/tests/test_delay_updates.c b/tests/test_delay_updates.c index 809e750..f34e57f 100644 --- a/tests/test_delay_updates.c +++ b/tests/test_delay_updates.c @@ -292,6 +292,7 @@ static void test_delay_updates_unique_staging_name() { DelayUpdatesContext* second = delay_updates_context_create("test_delay_uniq_tmp"); EXPECT_NOT_NULL(first); EXPECT_NOT_NULL(second); + /* cppcheck-suppress knownConditionTrueFalse -- the EXPECT_NOT_NULL checks above return on NULL */ if (first && second) { EXPECT_EQ_INT(strncmp(first->staging_name, ".fastsync-stage.", 16), 0); EXPECT_EQ_INT(strncmp(second->staging_name, ".fastsync-stage.", 16), 0); diff --git a/tests/test_file.c b/tests/test_file.c index 15c3233..e1845e0 100644 --- a/tests/test_file.c +++ b/tests/test_file.c @@ -2498,9 +2498,13 @@ static void test_file_receive_payload_streams(void) { EXPECT_NULL(buffer); EXPECT_NOT_NULL(spool); EXPECT_TRUE(out_size == size); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (spool) { FILE* fh = fopen(spool, "rb"); EXPECT_NOT_NULL(fh); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (fh) { unsigned char* got = malloc(size); EXPECT_TRUE(fread(got, 1, size, fh) == size); @@ -2525,6 +2529,8 @@ static void test_file_receive_payload_streams(void) { Data* compressed = data_compress_codec(raw, COMPRESSION_ALGO_ZSTD, 3, 0); data_destroy(raw); EXPECT_NOT_NULL(compressed); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (compressed) { int p[2]; EXPECT_EQ_INT(pipe(p), 0); @@ -2537,9 +2543,13 @@ static void test_file_receive_payload_streams(void) { EXPECT_NULL(buffer); EXPECT_NOT_NULL(spool); EXPECT_TRUE(out_size == size); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (spool) { FILE* fh = fopen(spool, "rb"); EXPECT_NOT_NULL(fh); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (fh) { unsigned char* got = malloc(size); EXPECT_TRUE(fread(got, 1, size, fh) == size); @@ -2575,9 +2585,11 @@ static void test_delta_stream_helpers(void) { DeltaSignature* mem_sig = delta_signature_create_seeded(basis, sizeof(basis), 4, 0); EXPECT_NOT_NULL(fd_sig); EXPECT_NOT_NULL(mem_sig); + /* cppcheck-suppress knownConditionTrueFalse -- EXPECT_NOT_NULL/EXPECT_TRUE above returns on + * failure */ if (fd_sig && mem_sig) { EXPECT_TRUE(fd_sig->block_count == mem_sig->block_count); - for (uint32_t i = 0; i < fd_sig->block_count && i < mem_sig->block_count; i++) { + for (uint32_t i = 0; i < fd_sig->block_count; i++) { EXPECT_TRUE(fd_sig->blocks[i].adler32 == mem_sig->blocks[i].adler32); EXPECT_TRUE(fd_sig->blocks[i].xxhash == mem_sig->blocks[i].xxhash); }