aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2024-02-12 17:23:04 +0000
committerLucas De Marchi <lucas.de.marchi@gmail.com>2024-04-30 12:33:52 -0500
commit03da2db1358f5ae3b50596f04e5e05bcf7a48fee (patch)
tree8694f2ccf4dfacd12ec9c249e7dc705a75040e05
parent09256b9a4f79976b28d2b15c4be3ee805d57edff (diff)
downloadkmod-03da2db1358f5ae3b50596f04e5e05bcf7a48fee.tar.gz
libkmod: remove kmod_file::{zstd,xz}_used flags
These are used to protect a free(file->memory), within their respective unload functions. Where the sole caller of the unload function already does a NULL check prior. Even so, free(NULL) is guaranteed to be safe by the standard. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
-rw-r--r--libkmod/libkmod-file.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c
index 9a014ea..abd4723 100644
--- a/libkmod/libkmod-file.c
+++ b/libkmod/libkmod-file.c
@@ -48,12 +48,6 @@ struct file_ops {
};
struct kmod_file {
-#ifdef ENABLE_ZSTD
- bool zstd_used;
-#endif
-#ifdef ENABLE_XZ
- bool xz_used;
-#endif
int fd;
enum kmod_file_compression_type compression;
off_t size;
@@ -176,7 +170,6 @@ static int load_zstd(struct kmod_file *file)
ZSTD_freeDStream(dstr);
free((void *)zst_inb.src);
- file->zstd_used = true;
file->memory = zst_outb.dst;
file->size = zst_outb.pos;
return 0;
@@ -190,8 +183,6 @@ out:
static void unload_zstd(struct kmod_file *file)
{
- if (!file->zstd_used)
- return;
free(file->memory);
}
@@ -269,7 +260,6 @@ static int xz_uncompress(lzma_stream *strm, struct kmod_file *file)
goto out;
}
}
- file->xz_used = true;
file->memory = p;
file->size = total;
return 0;
@@ -299,8 +289,6 @@ static int load_xz(struct kmod_file *file)
static void unload_xz(struct kmod_file *file)
{
- if (!file->xz_used)
- return;
free(file->memory);
}