]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: split out printf() helpers to stdio-util.h
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 00:26:31 +0000 (01:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 12:25:57 +0000 (13:25 +0100)
28 files changed:
Makefile.am
src/basic/log.c
src/basic/macro.h
src/basic/mount-util.c
src/basic/stdio-util.h [new file with mode: 0644]
src/basic/util.h
src/basic/xattr-util.c
src/core/automount.c
src/core/main.c
src/core/selinux-access.c
src/fsck/fsck.c
src/journal-remote/journal-remote.c
src/journal/journal-send.c
src/journal/journald-console.c
src/journal/journald-kmsg.c
src/journal/journald-stream.c
src/journal/journald-syslog.c
src/journal/sd-journal.c
src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-socket.c
src/machine/machined-dbus.c
src/network/networkd-link.c
src/nspawn/nspawn.c
src/shared/bus-util.c
src/shared/efivars.c
src/shared/spawn-polkit-agent.c
src/tmpfiles/tmpfiles.c
src/udev/udev-builtin-keyboard.c

index d851e96f38d9f10e801426be74107915fb8f2b29..c47ad240abdcfe08d29b0b55f393c0f2690a15ba 100644 (file)
@@ -766,6 +766,7 @@ libbasic_la_SOURCES = \
        src/basic/capability-util.h \
        src/basic/conf-files.c \
        src/basic/conf-files.h \
+       src/basic/stdio-util.h \
        src/basic/hostname-util.h \
        src/basic/hostname-util.c \
        src/basic/unit-name.c \
index 4583cb840f54bbed897a3943c42cbdec321e67ce..505c0d072c56edff3a24c3792bb538b6d9dc7dd0 100644 (file)
@@ -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"
index 156c16b1c39f9f23c37aa900b7317442bdc59605..acd67feabbf3c1c4a24553fdb63ec2e84bee9ccd 100644 (file)
@@ -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.
index 6b33d4302441c1409f32036e18d10284cd3f8bbc..24e88babcdc2216c63ad3d3f3dea26b064735b81 100644 (file)
@@ -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 (file)
index 0000000..b36e8a9
--- /dev/null
@@ -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)
index fc73e13fe4898a09ace01826984f51acfa364fb6..95c7c75b9c4fdc198ce9f3a7a38784df88c5d018 100644 (file)
@@ -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[]);
index 35fd1c16167bfb90e12d15eaa4a605ee6243da1e..7351337c6b04924f02bc64d82becbafec62fbbc6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "fd-util.h"
 #include "sparse-endian.h"
+#include "stdio-util.h"
 #include "util.h"
 #include "xattr-util.h"
 
index 379f71f74a60eb7bb03cf877fe338a6b5e76f549..50a77727535096b1c174210a6fc597ef3c7f0f08 100644 (file)
@@ -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"
index dbe774b14d24563e69ca6139122303d46b0a2ebe..d9c888d747eab4e95283951f1b4c52a7e65e9bd6 100644 (file)
@@ -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"
index cf38fa0ebe9601ccd53cd1858a0734b48601f434..a9368ead22db5389ef0396e76085a2282ed135be 100644 (file)
 #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;
 
index 45c24b2fcf6ea95f814aaed05fea9e9c64f14b35..4119edde3096a4764c585b085e4623bcb392112d 100644 (file)
@@ -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) */
index dc87b2102096cc2f620fc1aec7a11c651b89a408..f70d278e1c02839799b1df78f8d3ff407b0c693c 100644 (file)
@@ -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"
index dddd5703f445acf90921ea11fed692f1ee85146a..8fe99fae99a7361a0758ca9d807b4d073dce3200 100644 (file)
@@ -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"
 
index 9acc324bc595a367a7cf2b9f36198afce110e8b6..72c4ba587961e991cb6b267733a521be0051ad20 100644 (file)
@@ -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) {
index 52e1fbeb3dc2ed8fef1720e324459c53a1663434..489f6f689c933f6b79bd13d1128f26e5225caf60 100644 (file)
@@ -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(
index de4f4d97fe7945289bf6cb0baddcb582020b08bc..0dd6d54d68b9165b403ed566567333355d72856c 100644 (file)
@@ -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"
 
index d0c4a41b9d17dfca5d70a4404a500ab505c25e62..3553e9cc1d6a1079c377f8196ceb3023a4362601 100644 (file)
@@ -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"
 
index cfe1623e5bdb332a2762d5cd13f4949bfe7b494b..bd93d9077675e1411200a2fb0add7d6afec180c7 100644 (file)
@@ -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"
 
index 7c9dcf52837eb84540cf89e08bbaffbaf7ffaeec..5951db483dff3c025654e762c387145f8279eaa0 100644 (file)
@@ -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"
index 7ca544f6fdfab54c83ad4a3b52cfc31eaeb0a539..2c46d84cd08ac77d73a1a63dde5b6921ada99700 100644 (file)
 #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"
index 3c91fa86442315106f5e24c1a764a68f5c52f1c8..182dedda897943c25ffe6cc9c69153a4c08985ca 100644 (file)
@@ -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"
index de49fd5c227439ec954655eba4a481ccfe4544fe..ab37c43dcb4e0bd213a580a5ef45247a1b00a9b4 100644 (file)
@@ -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"
index 28bca1f71eed1a9e544bece2cfe0339681af5a2a..1ce219b84463cfcb9d174ff5cf32b3990a3589cb 100644 (file)
@@ -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"
index b253eb95eed3db423feb18a12ab178a07091b6c9..8f6278191ab09e32e6257f1217320d76133ac143 100644 (file)
@@ -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"
index 6e8f156a688b3ae3804f16fb20fb577115aeea69..e7972d1574c13c919971691e7e2748ec291447e9 100644 (file)
@@ -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"
index 7cc9e7ccc19d2b22097476a31af7a6835f6e91f7..ec6e5a8312ea47cd78b4727afc5170a56b373b5a 100644 (file)
@@ -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;
 }
index 7217f546112fe3e5dd0b413c2ab59d298eaf56b7..41deea70fbd57ab1af6428c2b90bd22a4da89e8a 100644 (file)
@@ -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"
index 74df4cb0f436834ac29f7fe37a7cb2594236ae25..aa10beafb0ba9615583f4a13b53400793cfbbe23 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "fd-util.h"
 #include "parse-util.h"
+#include "stdio-util.h"
 #include "string-util.h"
 #include "udev.h"