diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-27 01:26:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-10-27 13:25:57 +0100 |
commit | 15a5e95075a7f6007dd97b2a165c8ed16fe683df (patch) | |
tree | da7259ad54e2009c45a10ff4e0acad4160eed3be /src | |
parent | c7f1808add4d971229ba5311cf66e659122aa338 (diff) |
util-lib: split out printf() helpers to stdio-util.h
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/log.c | 1 | ||||
-rw-r--r-- | src/basic/macro.h | 45 | ||||
-rw-r--r-- | src/basic/mount-util.c | 1 | ||||
-rw-r--r-- | src/basic/stdio-util.h | 78 | ||||
-rw-r--r-- | src/basic/util.h | 4 | ||||
-rw-r--r-- | src/basic/xattr-util.c | 1 | ||||
-rw-r--r-- | src/core/automount.c | 1 | ||||
-rw-r--r-- | src/core/main.c | 1 | ||||
-rw-r--r-- | src/core/selinux-access.c | 8 | ||||
-rw-r--r-- | src/fsck/fsck.c | 1 | ||||
-rw-r--r-- | src/journal-remote/journal-remote.c | 1 | ||||
-rw-r--r-- | src/journal/journal-send.c | 1 | ||||
-rw-r--r-- | src/journal/journald-console.c | 1 | ||||
-rw-r--r-- | src/journal/journald-kmsg.c | 1 | ||||
-rw-r--r-- | src/journal/journald-stream.c | 1 | ||||
-rw-r--r-- | src/journal/journald-syslog.c | 1 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-control.c | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-socket.c | 3 | ||||
-rw-r--r-- | src/machine/machined-dbus.c | 1 | ||||
-rw-r--r-- | src/network/networkd-link.c | 1 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 1 | ||||
-rw-r--r-- | src/shared/bus-util.c | 1 | ||||
-rw-r--r-- | src/shared/efivars.c | 1 | ||||
-rw-r--r-- | src/shared/spawn-polkit-agent.c | 6 | ||||
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 1 | ||||
-rw-r--r-- | src/udev/udev-builtin-keyboard.c | 1 |
27 files changed, 111 insertions, 55 deletions
diff --git a/src/basic/log.c b/src/basic/log.c index 4583cb840f..505c0d072c 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -42,6 +42,7 @@ #include "process-util.h" #include "signal-util.h" #include "socket-util.h" +#include "stdio-util.h" #include "string-table.h" #include "string-util.h" #include "syslog-util.h" diff --git a/src/basic/macro.h b/src/basic/macro.h index 156c16b1c3..acd67feabb 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -301,51 +301,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { #define char_array_0(x) x[sizeof(x)-1] = 0; -#define VA_FORMAT_ADVANCE(format, ap) \ -do { \ - int _argtypes[128]; \ - size_t _i, _k; \ - _k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \ - assert(_k < ELEMENTSOF(_argtypes)); \ - for (_i = 0; _i < _k; _i++) { \ - if (_argtypes[_i] & PA_FLAG_PTR) { \ - (void) va_arg(ap, void*); \ - continue; \ - } \ - \ - switch (_argtypes[_i]) { \ - case PA_INT: \ - case PA_INT|PA_FLAG_SHORT: \ - case PA_CHAR: \ - (void) va_arg(ap, int); \ - break; \ - case PA_INT|PA_FLAG_LONG: \ - (void) va_arg(ap, long int); \ - break; \ - case PA_INT|PA_FLAG_LONG_LONG: \ - (void) va_arg(ap, long long int); \ - break; \ - case PA_WCHAR: \ - (void) va_arg(ap, wchar_t); \ - break; \ - case PA_WSTRING: \ - case PA_STRING: \ - case PA_POINTER: \ - (void) va_arg(ap, void*); \ - break; \ - case PA_FLOAT: \ - case PA_DOUBLE: \ - (void) va_arg(ap, double); \ - break; \ - case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \ - (void) va_arg(ap, long double); \ - break; \ - default: \ - assert_not_reached("Unknown format string argument."); \ - } \ - } \ -} while(false) - /* Because statfs.t_type can be int on some architectures, we have to cast * the const magic to the type, otherwise the compiler warns about * signed/unsigned comparison, because the magic can be 32 bit unsigned. diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index 6b33d43024..24e88babcd 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -30,6 +30,7 @@ #include "parse-util.h" #include "path-util.h" #include "set.h" +#include "stdio-util.h" #include "string-util.h" #include "util.h" diff --git a/src/basic/stdio-util.h b/src/basic/stdio-util.h new file mode 100644 index 0000000000..b36e8a947e --- /dev/null +++ b/src/basic/stdio-util.h @@ -0,0 +1,78 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +#pragma once + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see <http://www.gnu.org/licenses/>. +***/ + +#include <printf.h> +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> + +#include "macro.h" + +#define xsprintf(buf, fmt, ...) \ + assert_message_se((size_t) snprintf(buf, ELEMENTSOF(buf), fmt, __VA_ARGS__) < ELEMENTSOF(buf), "xsprintf: " #buf "[] must be big enough") + + +#define VA_FORMAT_ADVANCE(format, ap) \ +do { \ + int _argtypes[128]; \ + size_t _i, _k; \ + _k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \ + assert(_k < ELEMENTSOF(_argtypes)); \ + for (_i = 0; _i < _k; _i++) { \ + if (_argtypes[_i] & PA_FLAG_PTR) { \ + (void) va_arg(ap, void*); \ + continue; \ + } \ + \ + switch (_argtypes[_i]) { \ + case PA_INT: \ + case PA_INT|PA_FLAG_SHORT: \ + case PA_CHAR: \ + (void) va_arg(ap, int); \ + break; \ + case PA_INT|PA_FLAG_LONG: \ + (void) va_arg(ap, long int); \ + break; \ + case PA_INT|PA_FLAG_LONG_LONG: \ + (void) va_arg(ap, long long int); \ + break; \ + case PA_WCHAR: \ + (void) va_arg(ap, wchar_t); \ + break; \ + case PA_WSTRING: \ + case PA_STRING: \ + case PA_POINTER: \ + (void) va_arg(ap, void*); \ + break; \ + case PA_FLOAT: \ + case PA_DOUBLE: \ + (void) va_arg(ap, double); \ + break; \ + case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \ + (void) va_arg(ap, long double); \ + break; \ + default: \ + assert_not_reached("Unknown format string argument."); \ + } \ + } \ +} while(false) diff --git a/src/basic/util.h b/src/basic/util.h index fc73e13fe4..95c7c75b9c 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -85,10 +85,6 @@ static inline const char* one_zero(bool b) { bool fstype_is_network(const char *fstype); -#define xsprintf(buf, fmt, ...) \ - assert_message_se((size_t) snprintf(buf, ELEMENTSOF(buf), fmt, __VA_ARGS__) < ELEMENTSOF(buf), \ - "xsprintf: " #buf "[] must be big enough") - noreturn void freeze(void); void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index 35fd1c1616..7351337c6b 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -23,6 +23,7 @@ #include "fd-util.h" #include "sparse-endian.h" +#include "stdio-util.h" #include "util.h" #include "xattr-util.h" diff --git a/src/core/automount.c b/src/core/automount.c index 379f71f74a..50a7772753 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -45,6 +45,7 @@ #include "path-util.h" #include "process-util.h" #include "special.h" +#include "stdio-util.h" #include "string-table.h" #include "string-util.h" #include "unit-name.h" diff --git a/src/core/main.c b/src/core/main.c index dbe774b14d..d9c888d747 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -78,6 +78,7 @@ #include "smack-setup.h" #include "special.h" #include "stat-util.h" +#include "stdio-util.h" #include "strv.h" #include "switch-root.h" #include "terminal-util.h" diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c index cf38fa0ebe..a9368ead22 100644 --- a/src/core/selinux-access.c +++ b/src/core/selinux-access.c @@ -32,13 +32,15 @@ #endif #include "sd-bus.h" + +#include "audit-fd.h" #include "bus-util.h" -#include "util.h" #include "log.h" +#include "path-util.h" #include "selinux-util.h" -#include "audit-fd.h" +#include "stdio-util.h" #include "strv.h" -#include "path-util.h" +#include "util.h" static bool initialized = false; diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 45c24b2fcf..4119edde30 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -45,6 +45,7 @@ #include "signal-util.h" #include "socket-util.h" #include "special.h" +#include "stdio-util.h" #include "util.h" /* exit codes as defined in fsck(8) */ diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index dc87b21020..f70d278e1c 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -48,6 +48,7 @@ #include "signal-util.h" #include "socket-util.h" #include "stat-util.h" +#include "stdio-util.h" #include "string-table.h" #include "string-util.h" #include "strv.h" diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c index dddd5703f4..8fe99fae99 100644 --- a/src/journal/journal-send.c +++ b/src/journal/journal-send.c @@ -36,6 +36,7 @@ #include "io-util.h" #include "memfd-util.h" #include "socket-util.h" +#include "stdio-util.h" #include "string-util.h" #include "util.h" diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c index 9acc324bc5..72c4ba5879 100644 --- a/src/journal/journald-console.c +++ b/src/journal/journald-console.c @@ -31,6 +31,7 @@ #include "journald-server.h" #include "parse-util.h" #include "process-util.h" +#include "stdio-util.h" #include "terminal-util.h" static bool prefix_timestamp(void) { diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 52e1fbeb3d..489f6f689c 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -37,6 +37,7 @@ #include "journald-syslog.h" #include "parse-util.h" #include "process-util.h" +#include "stdio-util.h" #include "string-util.h" void server_forward_kmsg( diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index de4f4d97fe..0dd6d54d68 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -44,6 +44,7 @@ #include "parse-util.h" #include "selinux-util.h" #include "socket-util.h" +#include "stdio-util.h" #include "string-util.h" #include "syslog-util.h" diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index d0c4a41b9d..3553e9cc1d 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -36,6 +36,7 @@ #include "process-util.h" #include "selinux-util.h" #include "socket-util.h" +#include "stdio-util.h" #include "string-util.h" #include "syslog-util.h" diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index cfe1623e5b..bd93d90776 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -47,6 +47,8 @@ #include "missing.h" #include "path-util.h" #include "replace-var.h" +#include "stat-util.h" +#include "stdio-util.h" #include "string-util.h" #include "strv.h" diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index 7c9dcf5283..5951db483d 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -34,6 +34,7 @@ #include "bus-message.h" #include "bus-util.h" #include "capability-util.h" +#include "stdio-util.h" #include "string-util.h" #include "strv.h" #include "user-util.h" diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index 7ca544f6fd..2c46d84cd0 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -32,10 +32,11 @@ #include "bus-socket.h" #include "fd-util.h" #include "formats-util.h" +#include "hexdecoct.h" #include "macro.h" #include "missing.h" -#include "hexdecoct.h" #include "signal-util.h" +#include "stdio-util.h" #include "string-util.h" #include "user-util.h" #include "utf8.h" diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 3c91fa8644..182dedda89 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -39,6 +39,7 @@ #include "machined.h" #include "path-util.h" #include "process-util.h" +#include "stdio-util.h" #include "strv.h" #include "unit-name.h" #include "user-util.h" diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index de49fd5c22..ab37c43dcb 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -33,6 +33,7 @@ #include "networkd-netdev.h" #include "set.h" #include "socket-util.h" +#include "stdio-util.h" #include "string-table.h" #include "udev-util.h" #include "util.h" diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 28bca1f71e..1ce219b844 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -91,6 +91,7 @@ #include "signal-util.h" #include "socket-util.h" #include "stat-util.h" +#include "stdio-util.h" #include "string-util.h" #include "strv.h" #include "terminal-util.h" diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index b253eb95ee..8f6278191a 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -43,6 +43,7 @@ #include "rlimit-util.h" #include "set.h" #include "signal-util.h" +#include "stdio-util.h" #include "string-util.h" #include "strv.h" #include "syslog-util.h" diff --git a/src/shared/efivars.c b/src/shared/efivars.c index 6e8f156a68..e7972d1574 100644 --- a/src/shared/efivars.c +++ b/src/shared/efivars.c @@ -28,6 +28,7 @@ #include "fd-util.h" #include "io-util.h" #include "parse-util.h" +#include "stdio-util.h" #include "utf8.h" #include "util.h" #include "virt.h" diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c index 7cc9e7ccc1..ec6e5a8312 100644 --- a/src/shared/spawn-polkit-agent.c +++ b/src/shared/spawn-polkit-agent.c @@ -30,6 +30,7 @@ #include "log.h" #include "process-util.h" #include "spawn-polkit-agent.h" +#include "stdio-util.h" #include "util.h" #ifdef ENABLE_POLKIT @@ -78,8 +79,9 @@ void polkit_agent_close(void) { return; /* Inform agent that we are done */ - kill(agent_pid, SIGTERM); - kill(agent_pid, SIGCONT); + (void) kill(agent_pid, SIGTERM); + (void) kill(agent_pid, SIGCONT); + (void) wait_for_terminate(agent_pid, NULL); agent_pid = 0; } diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 7217f54611..41deea70fb 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -62,6 +62,7 @@ #include "set.h" #include "specifier.h" #include "stat-util.h" +#include "stdio-util.h" #include "string-table.h" #include "string-util.h" #include "strv.h" diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 74df4cb0f4..aa10beafb0 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -25,6 +25,7 @@ #include "fd-util.h" #include "parse-util.h" +#include "stdio-util.h" #include "string-util.h" #include "udev.h" |