mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Add more _printf_'s for format-nonliterals
Clang is a bit more strict wrt format-nonliterals: http://clang.llvm.org/docs/LanguageExtensions.html#format-string-checking Adding these extra printf attributes also makes gcc able to find more problems. E.g. this patch uncovers a format issue in udev-builtin-path_id.c Some parts looked intetional about breaking the format-nonliteral check. I added some supression for warnings there.
This commit is contained in:
parent
8d35dae708
commit
9091e686f4
@ -610,6 +610,8 @@ _pure_ static const char *job_get_status_message_format_try_harder(Unit *u, JobT
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
static void job_print_status_message(Unit *u, JobType t, JobResult result) {
|
||||
const char *format;
|
||||
|
||||
@ -676,6 +678,7 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
|
||||
unit_status_printf(u, ANSI_HIGHLIGHT_ON " INFO " ANSI_HIGHLIGHT_OFF, "%s is not active.");
|
||||
}
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
@ -1125,6 +1125,8 @@ _pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, Job
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
static void unit_status_print_starting_stopping(Unit *u, JobType t) {
|
||||
const char *format;
|
||||
|
||||
@ -1139,6 +1141,7 @@ static void unit_status_print_starting_stopping(Unit *u, JobType t) {
|
||||
|
||||
unit_status_printf(u, "", format);
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
@ -131,6 +131,7 @@ static int respond_oom_internal(struct MHD_Connection *connection) {
|
||||
|
||||
#define respond_oom(connection) log_oom(), respond_oom_internal(connection)
|
||||
|
||||
_printf_(3,4)
|
||||
static int respond_error(
|
||||
struct MHD_Connection *connection,
|
||||
unsigned code,
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include "macro.h"
|
||||
#include "util.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
_printf_(2,0)
|
||||
void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
|
||||
_cleanup_free_ char *f;
|
||||
if (asprintf(&f, "microhttpd: %s", fmt) <= 0) {
|
||||
@ -35,3 +38,4 @@ void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
|
||||
}
|
||||
log_metav(LOG_INFO, NULL, 0, NULL, f, ap);
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -250,6 +250,7 @@ finish:
|
||||
return -bus_error_name_to_errno(name);
|
||||
}
|
||||
|
||||
_printf_(3,0)
|
||||
int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) {
|
||||
|
||||
if (!name)
|
||||
@ -463,6 +464,7 @@ _public_ int sd_bus_error_set_errno(sd_bus_error *e, int error) {
|
||||
return -error;
|
||||
}
|
||||
|
||||
_printf_(3,0)
|
||||
int bus_error_set_errnofv(sd_bus_error *e, int error, const char *format, va_list ap) {
|
||||
int r;
|
||||
|
||||
|
@ -65,6 +65,7 @@ void udev_log(struct udev *udev,
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_stderr(struct udev *udev,
|
||||
int priority, const char *file, int line, const char *fn,
|
||||
const char *format, va_list args)
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_fn(struct udev *udev,
|
||||
int priority, const char *file, int line, const char *fn,
|
||||
const char *format, va_list args) {
|
||||
|
@ -71,6 +71,7 @@
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_fn(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args)
|
||||
|
@ -405,6 +405,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_fn(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args)
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
static bool debug;
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_fn(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args)
|
||||
|
@ -67,6 +67,7 @@ static char model_enc_str[256];
|
||||
static char revision_str[16];
|
||||
static char type_str[16];
|
||||
|
||||
_printf_(6,0)
|
||||
static void log_fn(struct udev *udev, int priority,
|
||||
const char *file, int line, const char *fn,
|
||||
const char *format, va_list args)
|
||||
|
@ -64,6 +64,7 @@ static int load_module(struct udev *udev, const char *alias)
|
||||
return err;
|
||||
}
|
||||
|
||||
_printf_(6,0)
|
||||
static void udev_kmod_log(void *data, int priority, const char *file, int line,
|
||||
const char *fn, const char *format, va_list args)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "udev.h"
|
||||
|
||||
_printf_(2,3)
|
||||
static int path_prepend(char **path, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
Loading…
x
Reference in New Issue
Block a user