tree-wide: use xsprintf() where applicable
Also add a coccinelle receipt to help with such transitions.
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include "set.h"
|
||||
#include "special.h"
|
||||
#include "stat-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
#include "unit-name.h"
|
||||
@@ -716,7 +717,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
|
||||
if (pid == 0)
|
||||
pid = getpid();
|
||||
|
||||
snprintf(c, sizeof(c), PID_FMT"\n", pid);
|
||||
xsprintf(c, PID_FMT "\n", pid);
|
||||
|
||||
return write_string_file(fs, c, 0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -352,7 +352,7 @@ static int write_to_console(
|
||||
highlight = LOG_PRI(level) <= LOG_ERR && show_color;
|
||||
|
||||
if (show_location) {
|
||||
snprintf(location, sizeof(location), "(%s:%i) ", file, line);
|
||||
xsprintf(location, "(%s:%i) ", file, line);
|
||||
IOVEC_SET_STRING(iovec[n++], location);
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ static void log_assert(
|
||||
return;
|
||||
|
||||
DISABLE_WARNING_FORMAT_NONLITERAL;
|
||||
snprintf(buffer, sizeof(buffer), format, text, file, line, func);
|
||||
xsprintf(buffer, format, text, file, line, func);
|
||||
REENABLE_WARNING;
|
||||
|
||||
log_abort_msg = buffer;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "macro.h"
|
||||
#include "parse-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "stdio-util.h"
|
||||
#include "string-table.h"
|
||||
#include "string-util.h"
|
||||
|
||||
@@ -234,9 +235,9 @@ const char *signal_to_string(int signo) {
|
||||
return name;
|
||||
|
||||
if (signo >= SIGRTMIN && signo <= SIGRTMAX)
|
||||
snprintf(buf, sizeof(buf), "RTMIN+%d", signo - SIGRTMIN);
|
||||
xsprintf(buf, "RTMIN+%d", signo - SIGRTMIN);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%d", signo);
|
||||
xsprintf(buf, "%d", signo);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user