[PATCH] irmd: Remove unused variable in prog_table

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Mon, 5 Apr 2021 11:05:59 +0200

This removes a program name variable that was not used anymore.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/irmd/main.c       | 12 +-----------
 src/irmd/prog_table.c | 25 +------------------------
 src/irmd/prog_table.h |  7 +------
 3 files changed, 3 insertions(+), 41 deletions(-)

diff --git a/src/irmd/main.c b/src/irmd/main.c
index 66bad7d..31f244d 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -699,7 +699,6 @@ static int bind_program(char *   prog,
                         char **  argv)
 {
         char *              progs;
-        char *              progn;
         char **             argv_dup = NULL;
         int                 i;
         char *              name_dup = NULL;
@@ -719,13 +718,6 @@ static int bind_program(char *   prog,
                         return -ENOMEM;
                 }
 
-                progn = strdup(name);
-                if (progn == NULL) {
-                        pthread_rwlock_unlock(&irmd.reg_lock);
-                        free(progs);
-                        return -ENOMEM;
-                }
-
                 if ((flags & BIND_AUTO) && argc) {
                 /* We need to duplicate argv and set argv[0] to prog. */
                         argv_dup = malloc((argc + 2) * sizeof(*argv_dup));
@@ -739,17 +731,15 @@ static int bind_program(char *   prog,
                                                 "%s to %s.",
                                                 prog, name);
                                         free(progs);
-                                        free(progn);
                                         return -ENOMEM;
                                 }
                         }
                         argv_dup[argc + 1] = NULL;
                 }
-                e = prog_entry_create(progn, progs, flags, argv_dup);
+                e = prog_entry_create(progs, flags, argv_dup);
                 if (e == NULL) {
                         pthread_rwlock_unlock(&irmd.reg_lock);
                         free(progs);
-                        free(progn);
                         argvfree(argv_dup);
                         return -ENOMEM;
                 }
diff --git a/src/irmd/prog_table.c b/src/irmd/prog_table.c
index a6cc37a..eb2b196 100644
--- a/src/irmd/prog_table.c
+++ b/src/irmd/prog_table.c
@@ -30,14 +30,12 @@
 #include <stdlib.h>
 #include <string.h>
 
-struct prog_entry * prog_entry_create(char *   progn,
-                                      char *   prog,
+struct prog_entry * prog_entry_create(char *   prog,
                                       uint32_t flags,
                                       char **  argv)
 {
         struct prog_entry * e;
 
-        assert(progn);
         assert(prog);
 
         e = malloc(sizeof(*e));
@@ -47,7 +45,6 @@ struct prog_entry * prog_entry_create(char *   progn,
         list_head_init(&e->next);
         list_head_init(&e->names);
 
-        e->progn = progn;
         e->prog  = prog;
         e->flags = flags;
 
@@ -69,9 +66,6 @@ void prog_entry_destroy(struct prog_entry * e)
         if (e == NULL)
                 return;
 
-        if (e->progn != NULL)
-                free(e->progn);
-
         if (e->prog != NULL)
                 free(e->prog);
 
@@ -168,20 +162,3 @@ struct prog_entry * prog_table_get(struct list_head * 
prog_table,
 
         return NULL;
 }
-
-struct prog_entry * prog_table_get_by_progn(struct list_head * prog_table,
-                                            char *             progn)
-{
-        struct list_head * p;
-
-        assert(prog_table);
-        assert(progn);
-
-        list_for_each(p, prog_table) {
-                struct prog_entry * e = list_entry(p, struct prog_entry, next);
-                if (!strcmp(e->progn, progn))
-                        return e;
-        }
-
-        return NULL;
-}
diff --git a/src/irmd/prog_table.h b/src/irmd/prog_table.h
index 35fb778..eed046c 100644
--- a/src/irmd/prog_table.h
+++ b/src/irmd/prog_table.h
@@ -30,15 +30,13 @@
 
 struct prog_entry {
         struct list_head next;
-        char *           progn;   /* name for irmd */
         char *           prog;    /* name of binary */
         uint32_t         flags;
         char **          argv;
         struct list_head names; /* names that all instances will listen for */
 };
 
-struct prog_entry * prog_entry_create(char *   progn,
-                                      char *   prog,
+struct prog_entry * prog_entry_create(char *   prog,
                                       uint32_t flags,
                                       char **  argv);
 
@@ -59,7 +57,4 @@ void                prog_table_del(struct list_head * 
prog_table,
 struct prog_entry * prog_table_get(struct list_head * prog_table,
                                    char *             prog);
 
-struct prog_entry * prog_table_get_by_progn(struct list_head * prog_table,
-                                            char *             progn);
-
 #endif /* OUROBOROS_IRMD_PROG_TABLE_H */
-- 
2.31.1


Other related posts:

  • » [PATCH] irmd: Remove unused variable in prog_table - Dimitri Staessens