summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bc7b4a4)
Remove uses of sprintf to fix this warning:
warning: 'sprintf' is deprecated: This function is provided for
compatibility reasons only. Due to security concerns inherent in the
design of sprintf(3), it is highly recommended that you use snprintf(3)
instead. [-Wdeprecated-declarations]
Change-Id: I69dff6379623aefcfd60d6ad1ad96b48ae637155
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9592
Tested-by: jenkins <jenkins@lttng.org>
/* Resize. */
g_string_set_size(str, len + print_len);
va_start(ap, fmt);
/* Resize. */
g_string_set_size(str, len + print_len);
va_start(ap, fmt);
- print_len = vsprintf(str->str + len, fmt, ap);
+ print_len = vsnprintf(str->str + len, print_len + 1, fmt, ap);
va_end(ap);
} else {
str->len = len + print_len;
va_end(ap);
} else {
str->len = len + print_len;
BT_ASSERT_DBG(uuid_in);
BT_ASSERT_DBG(str_out);
BT_ASSERT_DBG(uuid_in);
BT_ASSERT_DBG(str_out);
- sprintf(str_out, BT_UUID_FMT, BT_UUID_FMT_VALUES(uuid_in));
+ snprintf(str_out, BT_UUID_STR_LEN + 1, BT_UUID_FMT, BT_UUID_FMT_VALUES(uuid_in));
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
#include "common/common.h"
#include "common/uuid.h"
#include "compat/endian.h"
#include "common/common.h"
#include "common/uuid.h"
#include "compat/endian.h"
static GQuark get_prefixed_named_quark(struct ctf_visitor_generate_ir *ctx, char prefix,
const char *name)
{
static GQuark get_prefixed_named_quark(struct ctf_visitor_generate_ir *ctx, char prefix,
const char *name)
{
-
- /* Prefix character + original string + '\0' */
- char *prname = g_new(char, strlen(name) + 2);
- if (!prname) {
- _BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE("Failed to allocate a string.");
- goto end;
- }
-
- sprintf(prname, "%c%s", prefix, name);
- qname = g_quark_from_string(prname);
- g_free(prname);
-
-end:
- return qname;
+ std::string prname = std::string {prefix} + name;
+ return g_quark_from_string(prname.c_str());
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <glib.h>
#include "fs-sink.hpp"
#include <glib.h>
#include "fs-sink.hpp"
static void make_unique_default_clock_class_name(struct fs_sink_ctf_stream_class *sc)
{
unsigned int suffix = 0;
static void make_unique_default_clock_class_name(struct fs_sink_ctf_stream_class *sc)
{
unsigned int suffix = 0;
- g_string_assign(sc->default_clock_class_name, "");
- sprintf(buf, "default");
+ std::string name = "default";
- while (default_clock_class_name_exists(sc->trace, buf)) {
- sprintf(buf, "default%u", suffix);
+ while (default_clock_class_name_exists(sc->trace, name.c_str())) {
+ name = "default" + std::to_string(suffix);
- g_string_assign(sc->default_clock_class_name, buf);
+ g_string_assign(sc->default_clock_class_name, name.c_str());
}
static int translate_stream_class(struct fs_sink_comp *fs_sink, struct fs_sink_ctf_trace *trace,
}
static int translate_stream_class(struct fs_sink_comp *fs_sink, struct fs_sink_ctf_trace *trace,
* Just convert it to a temporary string to handle
* everything the same way.
*/
* Just convert it to a temporary string to handle
* everything the same way.
*/
- sprintf(tmp_arg, "%" PRId64, value);
+ snprintf(tmp_arg, sizeof(tmp_arg), "%" PRId64, value);
arg = tmp_arg;
} else {
BT_ASSERT(bt_value_is_string(param));
arg = tmp_arg;
} else {
BT_ASSERT(bt_value_is_string(param));