]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: readback errno before calling kmod_log()
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 11 Jun 2025 13:03:26 +0000 (08:03 -0500)
Majority of our code-base reads back errno before calling the kmod_log()
to print an error, info or debug message.

Correct the last instances for consistency sake.

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

index cc11f4d3187cfcb3f294a538c022caf8c779ab69..cd5cf0ebb8a090c279cf8ecdd778755e78ca4baa 100644 (file)
@@ -763,8 +763,8 @@ int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
        }
 
        if ((fd = open(filename, O_RDONLY | O_CLOEXEC)) < 0) {
-               DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
                err = -errno;
+               DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
                goto fail_open;
        }
 
@@ -780,9 +780,9 @@ int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
 
        idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (idx->mm == MAP_FAILED) {
+               err = -errno;
                ERR(ctx, "mmap(NULL, %" PRIu64 ", PROT_READ, MAP_PRIVATE, %d, 0): %m\n",
                    (uint64_t)st.st_size, fd);
-               err = -errno;
                goto fail_nommap;
        }