From: Kefu Chai Date: Thu, 5 Mar 2026 04:59:54 +0000 (+0800) Subject: test/rgw: fix -Wstring-plus-char warning in test_d4n_policy X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8df5776c162c9d9e90390be1e7afd8c32e1bc0d9;p=ceph.git test/rgw: fix -Wstring-plus-char warning in test_d4n_policy `c_str() + '\0'` adds char value 0 to the pointer, which is a no-op. The null terminator is already included by passing `length() + 1` as the length argument to append(). Drop the spurious `+ '\0'`. this change addresses the warning: ``` [1588/1869] Building CXX object src/test/rgw/CMakeFiles/ceph_test_rgw_d4n_policy.dir/test_d4n_policy.cc.o /home/kefu/dev/ceph/src/test/rgw/test_d4n_policy.cc:324:39: warning: adding 'char' to a string pointer does not append to the string [-Wstring-plus-char] 324 | attrVal.append(length_str.c_str() + '\0', length_str.length() + 1); | ~~~~~~~~~~~~~~~~~~~^~~~~~ /home/kefu/dev/ceph/src/test/rgw/test_d4n_policy.cc:324:39: note: use array indexing to silence this warning 324 | attrVal.append(length_str.c_str() + '\0', length_str.length() + 1); | ^ | & [ ] ``` Signed-off-by: Kefu Chai --- diff --git a/src/test/rgw/test_d4n_policy.cc b/src/test/rgw/test_d4n_policy.cc index 30e5aedc8467..467a0dfdd316 100644 --- a/src/test/rgw/test_d4n_policy.cc +++ b/src/test/rgw/test_d4n_policy.cc @@ -321,7 +321,7 @@ TEST_F(LFUDAPolicyFixture, EvictionYield) buffer::list attrVal; auto length_str = std::to_string(TEST_DATA_LENGTH); - attrVal.append(length_str.c_str() + '\0', length_str.length() + 1); + attrVal.append(length_str.c_str(), length_str.length() + 1); attrs.insert({"accounted_size", std::move(attrVal)}); attrVal.clear(); attrVal.append("testBucket\0", 10);