]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw: fix -Wstring-plus-char warning in test_d4n_policy 67665/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 5 Mar 2026 04:59:54 +0000 (12:59 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 5 Mar 2026 05:07:12 +0000 (13:07 +0800)
`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 <k.chai@proxmox.com>
src/test/rgw/test_d4n_policy.cc

index 30e5aedc84678771c975c736eb67c1380e0515fe..467a0dfdd3160b1bc60733b7051a50a824345ba5 100644 (file)
@@ -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);