]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: move xstrappend and xstrputc to lsfd.h
authorMasatake YAMATO <yamato@redhat.com>
Mon, 7 Mar 2022 13:07:21 +0000 (22:07 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 4 Apr 2022 12:05:58 +0000 (21:05 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c
misc-utils/lsfd.h

index 6614a889d476cf80fd16b8a3459bcb12b9cb92e2..8d593fa279a2b732712523d7caaec5862834e4f9 100644 (file)
@@ -305,9 +305,6 @@ struct lsfd_control {
        struct lsfd_counter **counters;         /* NULL terminated array. */
 };
 
-static void xstrappend(char **a, const char *b);
-static void xstrputc(char **a, char c);
-
 static int column_name_to_id(const char *name, size_t namesz)
 {
        size_t i;
@@ -1342,18 +1339,6 @@ static void __attribute__((__noreturn__)) usage(void)
        exit(EXIT_SUCCESS);
 }
 
-static void xstrappend(char **a, const char *b)
-{
-       if (strappend(a, b) < 0)
-               err(EXIT_FAILURE, _("failed to allocate memory for string"));
-}
-
-static void xstrputc(char **a, char c)
-{
-       char b[] = {c, '\0'};
-       xstrappend(a, b);
-}
-
 static void append_filter_expr(char **a, const char *b, bool and)
 {
        if (*a == NULL) {
index ec8f40cfb5b455ea18a54c8d24e2ae9e03868d08..cf2cb52b306c4e8ad9c853e84e0f82300566f0aa 100644 (file)
@@ -30,6 +30,7 @@
 #include <inttypes.h>
 
 #include "list.h"
+#include "strutils.h"
 
 /*
  * column IDs
@@ -181,4 +182,16 @@ const char *get_chrdrv(unsigned long major);
 const char *get_miscdev(unsigned long minor);
 const char *get_nodev_filesystem(unsigned long minor);
 
+static inline void xstrappend(char **a, const char *b)
+{
+       if (strappend(a, b) < 0)
+               err(XALLOC_EXIT_CODE, _("failed to allocate memory for string"));
+}
+
+static inline void xstrputc(char **a, char c)
+{
+       char b[] = {c, '\0'};
+       xstrappend(a, b);
+}
+
 #endif /* UTIL_LINUX_LSFD_H */