]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: drop unused function udev_build_argv()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Sep 2018 15:28:50 +0000 (00:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Oct 2018 19:21:14 +0000 (04:21 +0900)
src/test/meson.build
src/test/test-udev-build-argv.c [deleted file]
src/udev/udev-event.c
src/udev/udev.h

index 97cca3269c0972dbc4400cb34bb255cbde3593aa..da500473c89ebea60b87e36d7e8218b3d807a255 100644 (file)
@@ -636,18 +636,6 @@ tests += [
           libacl],
          '', 'manual', '-DLOG_REALM=LOG_REALM_UDEV'],
 
-        [['src/test/test-udev-build-argv.c'],
-         [libudev_core,
-          libudev_static,
-          libsystemd_network,
-          libshared],
-         [threads,
-          librt,
-          libblkid,
-          libkmod,
-          libacl],
-         '', '', '-DLOG_REALM=LOG_REALM_UDEV'],
-
         [['src/test/test-id128.c'],
          [],
          []],
diff --git a/src/test/test-udev-build-argv.c b/src/test/test-udev-build-argv.c
deleted file mode 100644 (file)
index c71c706..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-#include "alloc-util.h"
-#include "string-util.h"
-#include "strv.h"
-#include "tests.h"
-#include "udev.h"
-
-static void test_udev_build_argv_one(const char *c) {
-        _cleanup_strv_free_ char **a = NULL;
-        _cleanup_free_ char *arg = NULL;
-        char *argv[128], **p;
-        int argc;
-        size_t i;
-
-        assert_se(a = strv_split_full(c, NULL, SPLIT_QUOTES | SPLIT_RELAX));
-
-        assert_se(arg = strdup(c));
-        assert_se(udev_build_argv(arg, &argc, argv) >= 0);
-
-        log_info("command: %s", c);
-
-        i = 0;
-        log_info("strv_split:");
-        STRV_FOREACH(p, a)
-                log_info("argv[%zu] = '%s'", i++, *p);
-
-        i = 0;
-        log_info("udev_build_argv:");
-        STRV_FOREACH(p, argv)
-                log_info("argv[%zu] = '%s'", i++, *p);
-
-        assert_se(strv_equal(argv, a));
-        assert_se(argc == (int) strv_length(a));
-
-}
-
-static void test_udev_build_argv(void) {
-        test_udev_build_argv_one("one   two   three");
-        test_udev_build_argv_one("one   'two   three '  \" four five \"  'aaa bbb  ");
-        test_udev_build_argv_one("/bin/echo -e \\101");
-        test_udev_build_argv_one("/bin/echo -n special-device");
-        test_udev_build_argv_one("/bin/echo -n special-device");
-        test_udev_build_argv_one("/bin/echo test");
-        test_udev_build_argv_one("/bin/echo -n test-%b");
-        test_udev_build_argv_one("/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9");
-        test_udev_build_argv_one("/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed  s/foo9/bar9/'");
-        test_udev_build_argv_one("/bin/echo -n 'foo3 foo4'   'foo5   foo6   foo7 foo8'");
-        test_udev_build_argv_one("/bin/sh -c 'printf %%s \\\"foo1 foo2\\\" | grep \\\"foo1 foo2\\\"'");
-        test_udev_build_argv_one("/bin/sh -c \\\"printf %%s 'foo1 foo2' | grep 'foo1 foo2'\\\"");
-        test_udev_build_argv_one("/bin/sh -c 'printf \\\"%%s %%s\\\" \\\"foo1 foo2\\\" \\\"foo3\\\"| grep \\\"foo1 foo2\\\"'");
-        test_udev_build_argv_one("/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9");
-        test_udev_build_argv_one("/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9");
-        test_udev_build_argv_one("/bin/echo -n foo");
-        test_udev_build_argv_one("/bin/echo -n usb-%b");
-        test_udev_build_argv_one("/bin/echo -n scsi-%b");
-        test_udev_build_argv_one("/bin/echo -n foo-%b");
-        test_udev_build_argv_one("/bin/echo test");
-        test_udev_build_argv_one("/bin/echo symlink test this");
-        test_udev_build_argv_one("/bin/echo symlink test this");
-        test_udev_build_argv_one("/bin/echo link test this");
-        test_udev_build_argv_one("/bin/echo -n node link1 link2");
-        test_udev_build_argv_one("/bin/echo -n node link1 link2 link3 link4");
-        test_udev_build_argv_one("/usr/bin/test -b %N");
-        test_udev_build_argv_one("/bin/echo -e name; (/usr/bin/badprogram)");
-        test_udev_build_argv_one("/bin/echo -e \\xc3\\xbcber");
-        test_udev_build_argv_one("/bin/echo -e \\xef\\xe8garbage");
-        test_udev_build_argv_one("/bin/echo 1 1 0400");
-        test_udev_build_argv_one("/bin/echo 0 0 0400letsdoabuffferoverflow0123456789012345789012345678901234567890");
-}
-
-int main(int argc, char *argv[]) {
-        test_setup_logging(LOG_DEBUG);
-
-        test_udev_build_argv();
-
-        return 0;
-}
index e46cf1563fe1f11d3af2d8aa7b89e1eae84d81c8..dc3a398c8d472f4d4b5bee6a6b760ed8f37f9de9 100644 (file)
@@ -697,41 +697,6 @@ static int spawn_wait(struct udev_event *event,
         return ret;
 }
 
-int udev_build_argv(char *cmd, int *argc, char *argv[]) {
-        int i = 0;
-        char *pos;
-
-        if (strchr(cmd, ' ') == NULL) {
-                argv[i++] = cmd;
-                goto out;
-        }
-
-        pos = cmd;
-        while (pos != NULL && pos[0] != '\0') {
-                if (IN_SET(pos[0], '\'', '"')) {
-                        /* do not separate quotes or double quotes */
-                        char delim[2] = { pos[0], '\0' };
-
-                        pos++;
-                        argv[i] = strsep(&pos, delim);
-                        if (pos != NULL)
-                                while (pos[0] == ' ')
-                                        pos++;
-                } else {
-                        argv[i] = strsep(&pos, " ");
-                        if (pos != NULL)
-                                while (pos[0] == ' ')
-                                        pos++;
-                }
-                i++;
-        }
-out:
-        argv[i] = NULL;
-        if (argc)
-                *argc = i;
-        return 0;
-}
-
 int udev_event_spawn(struct udev_event *event,
                      usec_t timeout_usec,
                      usec_t timeout_warn_usec,
index b7b2c0420c270c906cc675964dd1520170344f72..1164d2fb1b35a455bf03fb3f44a50aac7803e224 100644 (file)
@@ -75,7 +75,6 @@ void udev_event_execute_rules(struct udev_event *event,
                               struct udev_list *properties_list,
                               struct udev_rules *rules);
 void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_t timeout_warn_usec);
-int udev_build_argv(char *cmd, int *argc, char *argv[]);
 
 /* udev-watch.c */
 int udev_watch_init(void);