mirror of
https://github.com/ceph/ceph
synced 2025-04-11 04:02:04 +00:00
crimson/osd, osd: don't use VLA in cls_log() anymore.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
parent
f62329f9a4
commit
45c7b4b51a
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user