]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd, osd: don't use VLA in cls_log() anymore. 45278/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 8 Mar 2022 01:51:09 +0000 (01:51 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 8 Mar 2022 01:51:09 +0000 (01:51 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/objclass.cc
src/osd/objclass.cc

index c32f7eb5082104e7cb3dd645551c58a383fbae06..2642a60fadf0b0ce59e79bc73d2cf27db7741139 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <cstdarg>
 #include <cstring>
+#include <boost/container/small_vector.hpp>
 #include "common/ceph_context.h"
 #include "common/ceph_releases.h"
 #include "common/config.h"
@@ -536,16 +537,16 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, b
 // the classical OSD, it's different b/c of how the dout macro expands.
 int cls_log(int level, const char *format, ...)
 {
-   int size = 256;
+   size_t size = 256;
    va_list ap;
    while (1) {
-     char buf[size];
+     boost::container::small_vector<char, 256> buf(size);
      va_start(ap, format);
-     int n = vsnprintf(buf, size, format, ap);
+     int n = vsnprintf(buf.data(), size, format, ap);
      va_end(ap);
-#define MAX_SIZE 8196
-     if ((n > -1 && n < size) || size > MAX_SIZE) {
-       dout(ceph::dout::need_dynamic(level)) << buf << dendl;
+#define MAX_SIZE 8196UL
+     if ((n > -1 && static_cast<size_t>(n) < size) || size > MAX_SIZE) {
+       dout(ceph::dout::need_dynamic(level)) << buf.data() << dendl;
        return n;
      }
      size *= 2;
index eb20811a233b36047568836fbb6331b5fa34ee3b..74bd95e9712e281e51258d3f9f247171e73958df 100644 (file)
@@ -2,6 +2,7 @@
 // vim: ts=8 sw=2 smarttab
 
 #include <cstdarg>
+#include <boost/container/small_vector.hpp>
 #include "common/ceph_context.h"
 #include "common/ceph_releases.h"
 #include "common/config.h"
@@ -753,16 +754,16 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, b
 // crimson-osd, it's different b/c of how the dout macro expands.
 int cls_log(int level, const char *format, ...)
 {
-   int size = 256;
+   size_t size = 256;
    va_list ap;
    while (1) {
-     char buf[size];
+     boost::container::small_vector<char, 256> buf(size);
      va_start(ap, format);
-     int n = vsnprintf(buf, size, format, ap);
+     int n = vsnprintf(buf.data(), size, format, ap);
      va_end(ap);
-#define MAX_SIZE 8196
-     if ((n > -1 && n < size) || size > MAX_SIZE) {
-       dout(ceph::dout::need_dynamic(level)) << buf << dendl;
+#define MAX_SIZE 8196UL
+     if ((n > -1 && static_cast<size_t>(n) < size) || size > MAX_SIZE) {
+       dout(ceph::dout::need_dynamic(level)) << buf.data() << dendl;
        return n;
      }
      size *= 2;