Thread (2 messages) 2 messages, 2 authors, 2021-01-23
STALE2075d

[PATCH] libkmod: assign values to variables to fix warnings

From: Shuo Wang <hidden>
Date: 2021-01-21 07:08:08

	Dear Lucas,

Thanks for your reply. I was wondering if these changes will
 be merged in the future?

Best regards,
Shuo
gcc version 7.3.0 (GCC)
quoted
what compiler?
quoted
libkmod/libkmod.c: In function 'kmod_lookup_alias_is_builtin':
./shared/util.h:73:9: warning: 'line' may be used uninitialized in this function [-Wmaybe-uninitialized]
        free(*(void**) p);
        ^~~~~~~~~~~~~~~~~
libkmod/libkmod.c:581:23: note: 'line' was declared here
 _cleanup_free_ char *line;
                      ^~~~
In file included from libkmod/libkmod-module.c:42:0:
libkmod/libkmod-module.c: In function 'kmod_module_probe_insert_module':
./shared/util.h:73:9: warning: 'cmd' may be used uninitialized in this function [-Wmaybe-uninitialized]
        free(*(void**) p);
        ^~~~~~~~~~~~~~~~~
libkmod/libkmod-module.c:1009:23: note: 'cmd' was declared here
 _cleanup_free_ char *cmd;

---
libkmod/libkmod-module.c | 2 +-
libkmod/libkmod.c        | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 76a6dc3..2e973b5 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -1006,7 +1006,7 @@ static int module_do_install_commands(struct kmod_module *mod,
{
	const char *command = kmod_module_get_install_commands(mod);
	char *p;
-	_cleanup_free_ char *cmd;
+	_cleanup_free_ char *cmd = NULL;
	int err;
	size_t cmdlen, options_len, varlen;
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 43423d6..66e658c 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -578,7 +578,7 @@ finish:
bool kmod_lookup_alias_is_builtin(struct kmod_ctx *ctx, const char *name)
{
-	_cleanup_free_ char *line;
+	_cleanup_free_ char *line = NULL;

	line = lookup_builtin_file(ctx, name);

-- 
2.23.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help