]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared: remove unreachable snprintf error case
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 7 May 2025 10:58:56 +0000 (11:58 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 9 May 2025 18:52:46 +0000 (13:52 -0500)
It is practically impossible for `/proc/self/fd/%d` to result in a
string of PATH_MAX size. Remove the unreachable error handling.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
shared/util.c

index b10122ce06e3cd4806274fe88f370d324e3ee53c..2c6cfa96a73db9902b3e797c710218a603512202 100644 (file)
@@ -482,9 +482,7 @@ char *fd_lookup_path(int fd)
        char fd_path[PATH_MAX];
        ssize_t len;
 
-       len = snprintf(proc_path, sizeof(proc_path), "/proc/self/fd/%d", fd);
-       if (len < 0 || len >= (ssize_t)sizeof(proc_path))
-               return NULL;
+       snprintf(proc_path, sizeof(proc_path), "/proc/self/fd/%d", fd);
 
        /*
         * We are using mkstemp to create a temporary file. We need to read the link since