]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/common: Remove VLA from `append_rand_alpha`
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 24 Mar 2026 19:04:56 +0000 (15:04 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Thu, 26 Mar 2026 04:07:20 +0000 (00:07 -0400)
This is not a good function and it should be revisisted later.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_common.h

index 3131e1d8f1dc612f7b969e91d2d2430db65e5cd0..ff8549b9892308ebfc20a296820758dece856817 100644 (file)
@@ -1644,13 +1644,14 @@ static inline int rgw_str_to_bool(const char *s, int def_val)
           strcasecmp(s, "1") == 0);
 }
 
-static inline void append_rand_alpha(CephContext *cct, const std::string& src, std::string& dest, int len)
+inline void
+append_rand_alpha(
+    CephContext* cct,
+    const std::string& src,
+    std::string& dest,
+    int len)
 {
-  dest = src;
-  char buf[len + 1];
-  gen_rand_alphanumeric(cct, buf, len);
-  dest.append("_");
-  dest.append(buf);
+  dest = fmt::format("{}_{}", src, gen_rand_alphanumeric(cct, len));
 }
 
 static inline uint64_t rgw_rounded_kb(uint64_t bytes)