]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strv: use ul_ prefix for strv functions
authorKarel Zak <kzak@redhat.com>
Thu, 26 Jun 2025 11:47:00 +0000 (13:47 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Jun 2025 11:49:37 +0000 (13:49 +0200)
The functions are originally from systemd/udev, so it's possible that
during static linking, they may collide with other systemd-based
components.

Fixes: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
17 files changed:
include/strv.h
lib/env.c
lib/strv.c
libmount/src/context.c
libmount/src/context_mount.c
login-utils/su-common.c
misc-utils/logger.c
sys-utils/chmem.c
sys-utils/lscpu-riscv.c
sys-utils/mount.c
sys-utils/rtcwake.c
sys-utils/wdctl.c
sys-utils/zramctl.c
term-utils/script.c
term-utils/wall.c
text-utils/bits.c
text-utils/column.c

index db24ce482b176638252e4289a5fc9c450a5fa9bf..b565a910cfaa54e5389a80d40b1ff65b5fea52b1 100644 (file)
@@ -8,52 +8,51 @@
 
 #include "c.h"
 
-char **strv_free(char **l);
-void strv_clear(char **l);
-char **strv_copy(char * const *l);
-unsigned strv_length(char * const *l);
+char **ul_strv_free(char **l);
+char **ul_strv_copy(char * const *l);
+unsigned ul_strv_length(char * const *l);
 
-int strv_extend_strv(char ***a, char **b);
-int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
-int strv_extend(char ***l, const char *value);
+int ul_strv_extend_strv(char ***a, char **b);
+int ul_strv_extend_strv_concat(char ***a, char **b, const char *suffix);
+int ul_strv_extend(char ***l, const char *value);
 
-int strv_extendv(char ***l, const char *format, va_list ap)
+int ul_strv_extendv(char ***l, const char *format, va_list ap)
                __attribute__ ((__format__ (__printf__, 2, 0)));
-int strv_extendf(char ***l, const char *format, ...)
+int ul_strv_extendf(char ***l, const char *format, ...)
                __attribute__ ((__format__ (__printf__, 2, 3)));
 
-int strv_push(char ***l, char *value);
-int strv_push_prepend(char ***l, char *value);
-int strv_consume(char ***l, char *value);
-int strv_consume_prepend(char ***l, char *value);
+int ul_strv_push(char ***l, char *value);
+int ul_strv_push_prepend(char ***l, char *value);
+int ul_strv_consume(char ***l, char *value);
+int ul_strv_consume_prepend(char ***l, char *value);
 
-char **strv_remove(char **l, const char *s);
+char **ul_strv_remove(char **l, const char *s);
 
-char **strv_new(const char *x, ...);
+char **ul_strv_new(const char *x, ...);
 
-static inline const char* STRV_IFNOTNULL(const char *x) {
+static inline const char* UL_STRV_IFNOTNULL(const char *x) {
         return x ? x : (const char *) -1;
 }
 
-static inline int strv_isempty(char * const *l) {
+static inline int ul_strv_isempty(char * const *l) {
         return !l || !*l;
 }
 
-char **strv_split(const char *s, const char *separator);
-char *strv_join(char **l, const char *separator);
+char **ul_strv_split(const char *s, const char *separator);
+char *ul_strv_join(char **l, const char *separator);
 
-#define STRV_FOREACH(s, l)                      \
+#define UL_STRV_FOREACH(s, l)                      \
         for ((s) = (l); (s) && *(s); (s)++)
 
-#define STRV_FOREACH_BACKWARDS(s, l)            \
-        STRV_FOREACH(s, l)                      \
+#define UL_STRV_FOREACH_BACKWARDS(s, l)            \
+        UL_STRV_FOREACH(s, l)                      \
                 ;                               \
         for ((s)--; (l) && ((s) >= (l)); (s)--)
 
 
-#define STRV_MAKE_EMPTY ((char*[1]) { NULL })
+#define UL_STRV_MAKE_EMPTY ((char*[1]) { NULL })
 
-char **strv_reverse(char **l);
+char **ul_strv_reverse(char **l);
 
 #endif /* UTIL_LINUX_STRV */
 
index dc65c5584af5a3ae01620d9ec68d2317888d7849..cdd8f8c58769a4affa481bab1c46d51aa549500f 100644 (file)
--- a/lib/env.c
+++ b/lib/env.c
@@ -150,14 +150,14 @@ struct ul_env_list *env_list_add_getenvs(struct ul_env_list *ls, const char *str
        if (!str)
                return ls;
 
-       all = strv_split(str, ",");
+       all = ul_strv_split(str, ",");
        if (!all)
                return ls;
 
-       STRV_FOREACH(name, all)
+       UL_STRV_FOREACH(name, all)
                ls = env_list_add_getenv(ls, *name, NULL);
 
-       strv_free(all);
+       ul_strv_free(all);
        return ls;
 }
 
index fd84fe32af682ef4dbc93e487080cb3799a366aa..6946f409b142ea68ac59b4c5c29191bbe3306034 100644 (file)
@@ -24,7 +24,7 @@
 #include "strutils.h"
 #include "strv.h"
 
-void strv_clear(char **l) {
+static void ul_strv_clear(char **l) {
         char **k;
 
         if (!l)
@@ -36,16 +36,16 @@ void strv_clear(char **l) {
         *l = NULL;
 }
 
-char **strv_free(char **l) {
-        strv_clear(l);
+char **ul_strv_free(char **l) {
+        ul_strv_clear(l);
         free(l);
         return NULL;
 }
 
-char **strv_copy(char * const *l) {
+char **ul_strv_copy(char * const *l) {
         char **r, **k;
 
-        k = r = malloc(sizeof(char *) * (strv_length(l) + 1));
+        k = r = malloc(sizeof(char *) * (ul_strv_length(l) + 1));
         if (!r)
                 return NULL;
 
@@ -53,7 +53,7 @@ char **strv_copy(char * const *l) {
                 for (; *l; k++, l++) {
                         *k = strdup(*l);
                         if (!*k) {
-                                strv_free(r);
+                                ul_strv_free(r);
                                 return NULL;
                         }
                 }
@@ -62,7 +62,7 @@ char **strv_copy(char * const *l) {
         return r;
 }
 
-unsigned strv_length(char * const *l) {
+unsigned ul_strv_length(char * const *l) {
         unsigned n = 0;
 
         if (!l)
@@ -74,7 +74,7 @@ unsigned strv_length(char * const *l) {
         return n;
 }
 
-static char **strv_new_ap(const char *x, va_list ap) {
+static char **ul_strv_new_ap(const char *x, va_list ap) {
         const char *s;
         char **a;
         unsigned n = 0, i = 0;
@@ -82,7 +82,7 @@ static char **strv_new_ap(const char *x, va_list ap) {
 
         /* As a special trick we ignore all listed strings that equal
          * (const char*) -1. This is supposed to be used with the
-         * STRV_IFNOTNULL() macro to include possibly NULL strings in
+         * UL_STRV_IFNOTNULL() macro to include possibly NULL strings in
          * the string list. */
 
         if (x) {
@@ -129,27 +129,27 @@ static char **strv_new_ap(const char *x, va_list ap) {
         return a;
 
 fail:
-        strv_free(a);
+        ul_strv_free(a);
         return NULL;
 }
 
-char **strv_new(const char *x, ...) {
+char **ul_strv_new(const char *x, ...) {
         char **r;
         va_list ap;
 
         va_start(ap, x);
-        r = strv_new_ap(x, ap);
+        r = ul_strv_new_ap(x, ap);
         va_end(ap);
 
         return r;
 }
 
-int strv_extend_strv(char ***a, char **b) {
+int ul_strv_extend_strv(char ***a, char **b) {
         int r;
         char **s;
 
-        STRV_FOREACH(s, b) {
-                r = strv_extend(a, *s);
+        UL_STRV_FOREACH(s, b) {
+                r = ul_strv_extend(a, *s);
                 if (r < 0)
                         return r;
         }
@@ -157,18 +157,18 @@ int strv_extend_strv(char ***a, char **b) {
         return 0;
 }
 
-int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
+int ul_strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
         int r;
         char **s;
 
-        STRV_FOREACH(s, b) {
+        UL_STRV_FOREACH(s, b) {
                 char *v;
 
                 v = strconcat(*s, suffix);
                 if (!v)
                         return -ENOMEM;
 
-                r = strv_push(a, v);
+                r = ul_strv_push(a, v);
                 if (r < 0) {
                         free(v);
                         return r;
@@ -186,7 +186,7 @@ int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
         _FOREACH_WORD(word, length, s, separator, false, state)
 
 
-char **strv_split(const char *s, const char *separator) {
+char **ul_strv_split(const char *s, const char *separator) {
         const char *word, *state;
         size_t l;
         unsigned n, i;
@@ -206,7 +206,7 @@ char **strv_split(const char *s, const char *separator) {
         FOREACH_WORD_SEPARATOR(word, l, s, separator, state) {
                 r[i] = strndup(word, l);
                 if (!r[i]) {
-                        strv_free(r);
+                        ul_strv_free(r);
                         return NULL;
                 }
 
@@ -217,7 +217,7 @@ char **strv_split(const char *s, const char *separator) {
         return r;
 }
 
-char *strv_join(char **l, const char *separator) {
+char *ul_strv_join(char **l, const char *separator) {
         char *r, *e;
         char **s;
         size_t n, k;
@@ -228,7 +228,7 @@ char *strv_join(char **l, const char *separator) {
         k = strlen(separator);
 
         n = 0;
-        STRV_FOREACH(s, l) {
+        UL_STRV_FOREACH(s, l) {
                 if (n != 0)
                         n += k;
                 n += strlen(*s);
@@ -239,7 +239,7 @@ char *strv_join(char **l, const char *separator) {
                 return NULL;
 
         e = r;
-        STRV_FOREACH(s, l) {
+        UL_STRV_FOREACH(s, l) {
                 if (e != r)
                         e = stpcpy(e, separator);
 
@@ -251,14 +251,14 @@ char *strv_join(char **l, const char *separator) {
         return r;
 }
 
-int strv_push(char ***l, char *value) {
+int ul_strv_push(char ***l, char *value) {
         char **c;
         unsigned n, m;
 
         if (!value)
                 return 0;
 
-        n = strv_length(*l);
+        n = ul_strv_length(*l);
 
         /* Increase and check for overflow */
         m = n + 2;
@@ -276,14 +276,14 @@ int strv_push(char ***l, char *value) {
         return 0;
 }
 
-int strv_push_prepend(char ***l, char *value) {
+int ul_strv_push_prepend(char ***l, char *value) {
         char **c;
         unsigned n, m, i;
 
         if (!value)
                 return 0;
 
-        n = strv_length(*l);
+        n = ul_strv_length(*l);
 
         /* increase and check for overflow */
         m = n + 2;
@@ -306,27 +306,27 @@ int strv_push_prepend(char ***l, char *value) {
         return 0;
 }
 
-int strv_consume(char ***l, char *value) {
+int ul_strv_consume(char ***l, char *value) {
         int r;
 
-        r = strv_push(l, value);
+        r = ul_strv_push(l, value);
         if (r < 0)
                 free(value);
 
         return r;
 }
 
-int strv_consume_prepend(char ***l, char *value) {
+int ul_strv_consume_prepend(char ***l, char *value) {
         int r;
 
-        r = strv_push_prepend(l, value);
+        r = ul_strv_push_prepend(l, value);
         if (r < 0)
                 free(value);
 
         return r;
 }
 
-int strv_extend(char ***l, const char *value) {
+int ul_strv_extend(char ***l, const char *value) {
         char *v;
 
         if (!value)
@@ -336,10 +336,10 @@ int strv_extend(char ***l, const char *value) {
         if (!v)
                 return -ENOMEM;
 
-        return strv_consume(l, v);
+        return ul_strv_consume(l, v);
 }
 
-char **strv_remove(char **l, const char *s) {
+char **ul_strv_remove(char **l, const char *s) {
         char **f, **t;
 
         if (!l)
@@ -360,7 +360,7 @@ char **strv_remove(char **l, const char *s) {
         return l;
 }
 
-int strv_extendf(char ***l, const char *format, ...) {
+int ul_strv_extendf(char ***l, const char *format, ...) {
         va_list ap;
         char *x;
         int r;
@@ -372,10 +372,10 @@ int strv_extendf(char ***l, const char *format, ...) {
         if (r < 0)
                 return -ENOMEM;
 
-        return strv_consume(l, x);
+        return ul_strv_consume(l, x);
 }
 
-int strv_extendv(char ***l, const char *format, va_list ap) {
+int ul_strv_extendv(char ***l, const char *format, va_list ap) {
         char *x;
         int r;
 
@@ -383,13 +383,13 @@ int strv_extendv(char ***l, const char *format, va_list ap) {
         if (r < 0)
                 return -ENOMEM;
 
-        return strv_consume(l, x);
+        return ul_strv_consume(l, x);
 }
 
-char **strv_reverse(char **l) {
+char **ul_strv_reverse(char **l) {
         unsigned n, i;
 
-        n = strv_length(l);
+        n = ul_strv_length(l);
         if (n <= 1)
                 return l;
 
index dfecab788d1d1675d0cf4c598985fd10ee4769ac..55cf75ddd150353e146ef17562f74afacbea9f11 100644 (file)
@@ -2737,7 +2737,7 @@ void mnt_context_syscall_reset_status(struct libmnt_context *cxt)
 void mnt_context_reset_mesgs(struct libmnt_context *cxt)
 {
        DBG(CXT, ul_debug("reset messages"));
-       strv_free(cxt->mesgs);
+       ul_strv_free(cxt->mesgs);
        cxt->mesgs = NULL;
 }
 
@@ -2746,7 +2746,7 @@ int mnt_context_append_mesg(struct libmnt_context *cxt, const char *msg)
        if (msg) {
                DBG(CXT, ul_debug("mesg: '%s'", msg));
        }
-       return strv_extend(&cxt->mesgs, msg);
+       return ul_strv_extend(&cxt->mesgs, msg);
 }
 
 int mnt_context_sprintf_mesg(struct libmnt_context *cxt, const char *msg, ...)
@@ -2755,7 +2755,7 @@ int mnt_context_sprintf_mesg(struct libmnt_context *cxt, const char *msg, ...)
        va_list ap;
 
        va_start(ap, msg);
-       rc = strv_extendv(&cxt->mesgs, msg, ap);
+       rc = ul_strv_extendv(&cxt->mesgs, msg, ap);
        va_end(ap);
 
        return rc;
@@ -2808,10 +2808,10 @@ size_t mnt_context_get_nmesgs(struct libmnt_context *cxt, char type)
        if (!cxt || !cxt->mesgs)
                return 0;
 
-       n = strv_length(cxt->mesgs);
+       n = ul_strv_length(cxt->mesgs);
        if (n && type) {
                n = 0;
-               STRV_FOREACH(s, cxt->mesgs) {
+               UL_STRV_FOREACH(s, cxt->mesgs) {
                        if (*s && **s == type)
                                n++;
                }
index 14ff9ba13a805547489a63d5c988ac5fd810a4f1..24369857d97055f70741eb5b748a8ddc35c25151 100644 (file)
@@ -1449,10 +1449,10 @@ static void join_err_mesgs(struct libmnt_context *cxt, char *buf, size_t bufsz)
        char **s;
        int n = 0;
 
-       if (!cxt || !buf || strv_isempty(cxt->mesgs))
+       if (!cxt || !buf || ul_strv_isempty(cxt->mesgs))
                return;
 
-       STRV_FOREACH(s, cxt->mesgs) {
+       UL_STRV_FOREACH(s, cxt->mesgs) {
                size_t len;
 
                if (!bufsz)
index 2cdeba857f641c2a1d0dc2e510118dfa812876d0..38d476a1a29a569c10fc9ccd5505f43d763ecb8c 100644 (file)
@@ -61,7 +61,6 @@
 #include "pathnames.h"
 #include "env.h"
 #include "closestream.h"
-#include "strv.h"
 #include "strutils.h"
 #include "ttyutils.h"
 #include "pwdutils.h"
index 14710eb9cc756055b5d21ed020b3fd89b5db24b9..4883c7e43f9335b423d9421c0220a37f6257b841 100644 (file)
@@ -622,7 +622,7 @@ static void add_structured_data_param(struct list_head *ls, const char *param)
 
        sd = list_last_entry(ls, struct structured_data, sds);
 
-       if (strv_extend(&sd->params,  param))
+       if (ul_strv_extend(&sd->params,  param))
                err_oom();
 }
 
@@ -638,7 +638,7 @@ static void __attribute__ ((__format__ (__printf__, 2, 3)))
 
        sd = list_last_entry(ls, struct structured_data, sds);
        va_start(ap, fmt);
-       x = strv_extendv(&sd->params, fmt, ap);
+       x = ul_strv_extendv(&sd->params, fmt, ap);
        va_end(ap);
 
        if (x)
@@ -649,11 +649,11 @@ static char *strdup_structured_data(struct structured_data *sd)
 {
        char *res, *tmp;
 
-       if (strv_isempty(sd->params))
+       if (ul_strv_isempty(sd->params))
                return NULL;
 
        xasprintf(&res, "[%s %s]", sd->id,
-                       (tmp = strv_join(sd->params, " ")));
+                       (tmp = ul_strv_join(sd->params, " ")));
        free(tmp);
        return res;
 }
index 932d0af13daafc4aa2ef601437b63e1b9becb75c..52e6f49b3f7364703bab19d916e0805b41fabc75 100644 (file)
@@ -319,14 +319,14 @@ static void parse_parameter(struct chmem_desc *desc, char *param)
 {
        char **split;
 
-       split = strv_split(param, "-");
-       if (strv_length(split) > 2)
+       split = ul_strv_split(param, "-");
+       if (ul_strv_length(split) > 2)
                errx(EXIT_FAILURE, _("Invalid parameter: %s"), param);
-       if (strv_length(split) == 1)
+       if (ul_strv_length(split) == 1)
                parse_single_param(desc, split[0]);
        else
                parse_range_param(desc, split[0], split[1]);
-       strv_free(split);
+       ul_strv_free(split);
        if (desc->start > desc->end)
                errx(EXIT_FAILURE, _("Invalid range: %s"), param);
 }
index 649f332ba61cf283ec17b79509d0c6353cc712d3..3d017620643135ad90334450d8ca5a8a6b6910b3 100644 (file)
@@ -40,19 +40,19 @@ void lscpu_format_isa_riscv(struct lscpu_cputype *ct)
        char **split;
        size_t i;
 
-       split = strv_split(ct->isa, "_");
+       split = ul_strv_split(ct->isa, "_");
 
        /* Sort multi-letter extensions alphabetically */
-       if (strv_length(split) > 1)
-               qsort(&split[1], strv_length(split) - 1, sizeof(char *), riscv_cmp_func);
+       if (ul_strv_length(split) > 1)
+               qsort(&split[1], ul_strv_length(split) - 1, sizeof(char *), riscv_cmp_func);
 
        /* Keep Base ISA and single-letter extensions at the start */
        strcpy(ct->isa, split[0]);
 
-       for (i = 1; i < strv_length(split); i++) {
+       for (i = 1; i < ul_strv_length(split); i++) {
                strcat(ct->isa, " ");
                strcat(ct->isa, split[i]);
        }
 
-       strv_free(split);
+       ul_strv_free(split);
 }
index 86800a12702df0674cf748844010ac27d828a9c7..875d249b477280de3b0114f989ff4689d118db66 100644 (file)
@@ -390,7 +390,7 @@ static size_t libmount_mesgs(struct libmnt_context *cxt, char type)
        }
 
        /* Messages */
-       STRV_FOREACH(s, mesgs) {
+       UL_STRV_FOREACH(s, mesgs) {
                switch (type) {
                case 'e':
                        if (!startswith(*s, "e "))
index 49dab17bdd76d0e55d306c3d9195db672fc22011..d01f5ed343c9b86a262e0b70f77567027f6ce1b7 100644 (file)
@@ -267,7 +267,7 @@ static char **get_sys_power_states(struct rtcwake_control *ctl)
                if (ss <= 0)
                        goto nothing;
                buf[ss] = '\0';
-               ctl->possible_modes = strv_split(buf, " \n");
+               ctl->possible_modes = ul_strv_split(buf, " \n");
                close(fd);
        }
        return ctl->possible_modes;
@@ -385,7 +385,7 @@ static int get_rtc_mode(struct rtcwake_control *ctl, const char *s)
        size_t i;
        char **modes = get_sys_power_states(ctl), **m;
 
-       STRV_FOREACH(m, modes) {
+       UL_STRV_FOREACH(m, modes) {
                if (strcmp(s, *m) == 0)
                        return SYSFS_MODE;
        }
@@ -421,7 +421,7 @@ static void list_modes(struct rtcwake_control *ctl)
        if (!modes)
                errx(EXIT_FAILURE, _("could not read: %s"), SYS_POWER_STATE_PATH);
 
-       STRV_FOREACH(m, modes)
+       UL_STRV_FOREACH(m, modes)
                printf("%s ", *m);
 
        for (i = 0; i < ARRAY_SIZE(rtcwake_mode_string); i++)
index 9290eb31202f2ccb4552b2e16e7d381561fb6f7b..b3203d461186be73b391391d2ed84f946e1eb73a 100644 (file)
@@ -594,7 +594,7 @@ static int read_governors(struct wd_device *wd)
                while ((sz = getline(&line, &dummy, f)) >= 0) {
                        if (rtrim_whitespace((unsigned char *) line) == 0)
                                continue;
-                       strv_consume(&wd->available_governors, line);
+                       ul_strv_consume(&wd->available_governors, line);
                        dummy = 0;
                        line = NULL;
                }
@@ -663,7 +663,7 @@ static void show_governors(struct wd_device *wd)
        if (wd->governor)
                printf(_("%-14s %s\n"), _("Pre-timeout governor:"), wd->governor);
        if (wd->available_governors) {
-               char *tmp = strv_join(wd->available_governors, " ");
+               char *tmp = ul_strv_join(wd->available_governors, " ");
 
                if (tmp)
                        printf(_("%-14s %s\n"),
index 175ad98d51f3016fe9c3e71c2a36ff8674ff6303..e9eea4d1e2837f367f4c99fc8cf0f35cb81cb00d 100644 (file)
@@ -308,7 +308,7 @@ static void zram_unlock(struct zram *z) {
 static void zram_reset_stat(struct zram *z)
 {
        if (z) {
-               strv_free(z->mm_stat);
+               ul_strv_free(z->mm_stat);
                z->mm_stat = NULL;
                z->mm_stat_probed = 0;
        }
@@ -525,11 +525,11 @@ static int get_mm_stat(struct zram *z,
        if (!z->mm_stat && !z->mm_stat_probed) {
                char *str = NULL;
                if (ul_path_read_string(sysfs, &str, "mm_stat") > 0 && str) {
-                       z->mm_stat = strv_split(str, " ");
+                       z->mm_stat = ul_strv_split(str, " ");
 
                        /* make sure kernel provides mm_stat as expected */
-                       if (strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names)) {
-                               strv_free(z->mm_stat);
+                       if (ul_strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names)) {
+                               ul_strv_free(z->mm_stat);
                                z->mm_stat = NULL;
                        }
                }
index 80ea477ab4f355d23fa5bf63101d3f61a83b6af7..7f31c141cf0ec335441bc737f8904779509c4125 100644 (file)
@@ -934,7 +934,7 @@ int main(int argc, char **argv)
                        errtryhelp(EXIT_FAILURE);
                }
 
-               ctl.command = strv_join(argv, " ");
+               ctl.command = ul_strv_join(argv, " ");
                if (!ctl.command)
                        errx(EXIT_FAILURE, _("failed to concatenate arguments"));
 
index c6067a0c8f003e51fb2ffafb14d2741fb1573d34..293275cb3ef6aded91e9e2862529eb298109e3dc 100644 (file)
@@ -195,7 +195,7 @@ static int has_tty(char **ttys, char *name)
 {
        char **str;
 
-       STRV_FOREACH(str, ttys) {
+       UL_STRV_FOREACH(str, ttys) {
                if (strcmp(*str, name) == 0)
                        return 1;
        }
@@ -292,7 +292,7 @@ int main(int argc, char **argv)
                        }
                        if (!(group_buf && !is_gr_member(name, group_buf))
                            && sd_session_get_tty(sessions_list[i], &tty) >= 0
-                           && strv_consume(&ttys, tty) < 0)
+                           && ul_strv_consume(&ttys, tty) < 0)
                                err(EXIT_FAILURE, _("failed to allocate lines list"));
 
                        free(name);
@@ -324,19 +324,19 @@ utmp:
                        mem2strcpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line), sizeof(line));
                        if (has_tty(ttys, line))
                                continue;
-                       if (strv_extend(&ttys, line) < 0)
+                       if (ul_strv_extend(&ttys, line) < 0)
                                err(EXIT_FAILURE, _("failed to allocate lines list"));
                }
                endutxent();
        }
 
-       STRV_FOREACH(str, ttys) {
+       UL_STRV_FOREACH(str, ttys) {
                char *er = ttymsg(&iov, 1, *str, timeout);
                if (er)
                         warnx("%s", er);
        }
 
-       strv_free(ttys);
+       ul_strv_free(ttys);
        free(mbuf);
        free_group_workspace(group_buf);
        exit(EXIT_SUCCESS);
index d758c3f567906d1ec59cd488476fdfd2781c3a4f..aca4306ee1e2c32da83d7da0cbc7e25f050db9dd 100644 (file)
@@ -302,11 +302,11 @@ int main(int argc, char **argv)
                while (fgets(buf, sizeof(buf), stdin)) {
                        /* strip LF, CR, CRLF, LFCR */
                        rtrim_whitespace((unsigned char *)buf);
-                       if (strv_push(&stdin_lines, xstrdup(buf)) < 0)
+                       if (ul_strv_push(&stdin_lines, xstrdup(buf)) < 0)
                                errx(EXIT_FAILURE, _("cannot allocate memory"));
                }
 
-               argc = strv_length(stdin_lines);
+               argc = ul_strv_length(stdin_lines);
                argv = stdin_lines;
        }
 
@@ -320,7 +320,7 @@ int main(int argc, char **argv)
        for (; argc > 0; argc--, argv++)
                parse_mask_or_list(*argv, bits, width);
 
-       strv_free(stdin_lines);
+       ul_strv_free(stdin_lines);
 
        print_bits(bits, width, mode);
 
index a929cd8136aabfd46fa5f2395de84d3e354d73c6..c3321ae166636e24196e39f67901cd0905f86247 100644 (file)
@@ -318,7 +318,7 @@ static wchar_t *local_wcstok(struct column_control const *const ctl, wchar_t *p,
 
 static char **split_or_error(const char *str, const char *errmsg)
 {
-       char **res = strv_split(str, ",");
+       char **res = ul_strv_split(str, ",");
        if (!res) {
                if (errno == ENOMEM)
                        err_oom();
@@ -350,7 +350,7 @@ static void init_table(struct column_control *ctl)
        if (ctl->tab_columns) {
                char **opts;
 
-               STRV_FOREACH(opts, ctl->tab_columns) {
+               UL_STRV_FOREACH(opts, ctl->tab_columns) {
                        struct libscols_column *cl;
 
                        cl = scols_table_new_column(ctl->tab, NULL, 0, 0);
@@ -360,7 +360,7 @@ static void init_table(struct column_control *ctl)
        } else if (ctl->tab_colnames) {
                char **name;
 
-               STRV_FOREACH(name, ctl->tab_colnames)
+               UL_STRV_FOREACH(name, ctl->tab_colnames)
                        scols_table_new_column(ctl->tab, *name, 0, 0);
        } else
                scols_table_enable_noheadings(ctl->tab, 1);
@@ -436,13 +436,13 @@ static int has_unnamed(const char *list)
 
        all = split_or_error(list, NULL);
        if (all) {
-               STRV_FOREACH(one, all) {
+               UL_STRV_FOREACH(one, all) {
                        if (strcmp(*one, "-") == 0) {
                                rc = 1;
                                break;
                        }
                }
-               strv_free(all);
+               ul_strv_free(all);
        }
 
        return rc;
@@ -473,7 +473,7 @@ static void apply_columnflag_from_list(struct column_control *ctl, const char *l
        all = split_or_error(list, errmsg);
 
        /* apply to columns specified by name */
-       STRV_FOREACH(one, all) {
+       UL_STRV_FOREACH(one, all) {
                int low = 0, up = 0;
 
                if (strcmp(*one, "-") == 0) {
@@ -499,7 +499,7 @@ static void apply_columnflag_from_list(struct column_control *ctl, const char *l
                if (cl)
                        column_set_flag(cl, flag);
        }
-       strv_free(all);
+       ul_strv_free(all);
 
        /* apply flag to all columns without name */
        if (unnamed) {
@@ -527,7 +527,7 @@ static void reorder_table(struct column_control *ctl)
 
        wanted = xcalloc(ncols, sizeof(struct libscols_column *));
 
-       STRV_FOREACH(one, order) {
+       UL_STRV_FOREACH(one, order) {
                struct libscols_column *cl = string_to_column(ctl, *one);
                if (cl)
                        wanted[count++] = cl;
@@ -539,7 +539,7 @@ static void reorder_table(struct column_control *ctl)
        }
 
        free(wanted);
-       strv_free(order);
+       ul_strv_free(order);
 }
 
 static void create_tree(struct column_control *ctl)
@@ -998,7 +998,7 @@ int main(int argc, char **argv)
 
                switch(c) {
                case 'C':
-                       if (strv_extend(&ctl.tab_columns, optarg))
+                       if (ul_strv_extend(&ctl.tab_columns, optarg))
                                err_oom();
                        break;
                case 'c':
@@ -1143,9 +1143,9 @@ int main(int argc, char **argv)
 
                        scols_unref_table(ctl.tab);
                        if (ctl.tab_colnames)
-                               strv_free(ctl.tab_colnames);
+                               ul_strv_free(ctl.tab_colnames);
                        if (ctl.tab_columns)
-                               strv_free(ctl.tab_columns);
+                               ul_strv_free(ctl.tab_columns);
                }
                break;
        case COLUMN_MODE_FILLCOLS: