]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsirq: Skip optarg duplication
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 11 Apr 2026 18:53:10 +0000 (20:53 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 12 Apr 2026 11:08:38 +0000 (13:08 +0200)
The -i argument specfies an input filename. Skip the duplication,
which fixes memory leaks and reduces binary size.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
sys-utils/lsirq.c

index e9bcbfaa937b2313cd67193a09a454576ec85be6..acc2f32561f782a7776c7d8088198670624696f5 100644 (file)
@@ -28,7 +28,6 @@
 #include "closestream.h"
 #include "optutils.h"
 #include "strutils.h"
-#include "xalloc.h"
 #include "pathnames.h"
 
 #include "irq-common.h"
@@ -106,7 +105,7 @@ int main(int argc, char **argv)
        cpu_set_t *cpuset = NULL;
        size_t setsize = 0;
        int softirq = 0;
-       char *input_file = NULL;
+       const char *input_file = NULL;
 
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
@@ -124,7 +123,7 @@ int main(int argc, char **argv)
                        out.pairs = 1;
                        break;
                case 'i':
-                       input_file = xstrdup(optarg);
+                       input_file = optarg;
                        break;
                case 'n':
                        out.no_headings = 1;
@@ -169,9 +168,9 @@ int main(int argc, char **argv)
 
        if (input_file == NULL) {
                if (softirq == 1)
-                       input_file = xstrdup(_PATH_PROC_SOFTIRQS);
+                       input_file = _PATH_PROC_SOFTIRQS;
                else
-                       input_file = xstrdup(_PATH_PROC_INTERRUPTS);
+                       input_file = _PATH_PROC_INTERRUPTS;
        }
 
        /* default */
@@ -193,7 +192,5 @@ int main(int argc, char **argv)
        if (print_irq_data(input_file, &out, softirq, threshold, setsize, cpuset) < 0)
                return EXIT_FAILURE;
 
-       free(input_file);
-
        return EXIT_SUCCESS;
 }