]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/list: remove LIST_HEAD macro
authorKarel Zak <kzak@redhat.com>
Thu, 5 Jan 2017 10:54:59 +0000 (11:54 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 5 Jan 2017 10:54:59 +0000 (11:54 +0100)
* the variable definition with hidden type is always horrible, for
  example:

  int func() {
    LIST_HEAD(foo);
    ...
  }

  the more readable is:

          int func() {
            struct list_head foo;

            INIT_LIST_HEAD(&foo);
            ...
          }

* the name LIST_HEAD conflict with /usr/include/sys/queue.h

* we use it only on two places in sulogin

Signed-off-by: Karel Zak <kzak@redhat.com>
include/list.h
login-utils/sulogin-consoles.c
login-utils/sulogin.c

index 3c08aa5f2c2a7f2f3a1403ca932179a1f3f7f461..cf022fb22529b067ba9597d757be4ea752f8a28f 100644 (file)
@@ -33,11 +33,6 @@ struct list_head {
        struct list_head *next, *prev;
 };
 
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
-       struct list_head name = LIST_HEAD_INIT(name)
-
 #define INIT_LIST_HEAD(ptr) do { \
        (ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)
index 532e7e7c72b67900c4f139b49945d168cdb29f98..30a0f042a09de149212e0a5a102967015e12fdd3 100644 (file)
@@ -802,8 +802,7 @@ int main(int argc, char *argv[])
 {
        char *name = NULL;
        int fd, re;
-       LIST_HEAD(consoles);
-       struct list_head *p;
+       struct list_head *p, consoles;
 
        if (argc == 2) {
                name = argv[1];
@@ -816,6 +815,7 @@ int main(int argc, char *argv[])
        if (!name)
                errx(EXIT_FAILURE, "usage: %s [<tty>]\n", program_invocation_short_name);
 
+       INIT_LIST_HEAD(&consoles);
        re = detect_consoles(name, fd, &consoles);
 
        list_for_each(p, &consoles) {
index 8dc2b639d3181e733c60f255838f533319393858..5b8712bfe9fd05e3222513d62917d602a9d1fa32 100644 (file)
@@ -827,8 +827,7 @@ static void usage(FILE *out)
 
 int main(int argc, char **argv)
 {
-       LIST_HEAD(consoles);
-       struct list_head *ptr;
+       struct list_head *ptr, consoles;
        struct console *con;
        char *tty = NULL;
        struct passwd *pwd;
@@ -849,6 +848,8 @@ int main(int argc, char **argv)
                { NULL,           0, 0, 0 }
        };
 
+       INIT_LIST_HEAD(&consoles);
+
        /*
         * If we are init we need to set up a own session.
         */