linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libkmod: assign values to variables to fix warnings
@ 2021-01-08  7:22 Shuo Wang
  2021-01-11 13:09 ` Lucas De Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Shuo Wang @ 2021-01-08  7:22 UTC (permalink / raw)
  To: lucas.de.marchi, patchwork-bot, linux-modules; +Cc: hushiyuan

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] libkmod: assign values to variables to fix warnings
  2021-01-08  7:22 [PATCH] libkmod: assign values to variables to fix warnings Shuo Wang
@ 2021-01-11 13:09 ` Lucas De Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Lucas De Marchi @ 2021-01-11 13:09 UTC (permalink / raw)
  To: Shuo Wang; +Cc: patchwork-bot, linux-modules, hushiyuan

what compiler?

On Thu, Jan 7, 2021 at 11:22 PM Shuo Wang <wangshuo47@huawei.com> wrote:
>
> 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);

line is assigned here. Why is this giving you a warning? I remember
seeing these warnings that ended up being fixed
in gcc some years ago.

Lucas De Marchi

>
> --
> 2.23.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libkmod: assign values to variables to fix warnings
  2021-01-21  7:06 Shuo Wang
@ 2021-01-23 19:04 ` Lucas De Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Lucas De Marchi @ 2021-01-23 19:04 UTC (permalink / raw)
  To: Shuo Wang; +Cc: patchwork-bot, linux-modules, hushiyuan

On Wed, Jan 20, 2021 at 11:06 PM Shuo Wang <wangshuo47@huawei.com> wrote:
>
>
>         Dear Lucas,
>
> Thanks for your reply. I was wondering if these changes will
>  be merged in the future?

It seems those errors are actually compiler mistakes. Aren't there
updates to the compiler?  What distro is shipping gcc 7.3.0??
See below.

>
> Best regards,
> Shuo
>
> >gcc version 7.3.0 (GCC)
> >
> >>what compiler?
> >>>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);

line is declared above and just assigned here, the initial NULL makes
no difference.

Lucas De Marchi

> >>>
> >>>--
> >>>2.23.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] libkmod: assign values to variables to fix warnings
@ 2021-01-21  7:06 Shuo Wang
  2021-01-23 19:04 ` Lucas De Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Shuo Wang @ 2021-01-21  7:06 UTC (permalink / raw)
  To: lucas.de.marchi, patchwork-bot, linux-modules; +Cc: hushiyuan


	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)
>
>>what compiler?
>>>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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] libkmod: assign values to variables to fix warnings
@ 2021-01-11 14:13 Shuo Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Shuo Wang @ 2021-01-11 14:13 UTC (permalink / raw)
  To: lucas.de.marchi, patchwork-bot, linux-modules; +Cc: hushiyuan

gcc version 7.3.0 (GCC)

>what compiler?
>>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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-23 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08  7:22 [PATCH] libkmod: assign values to variables to fix warnings Shuo Wang
2021-01-11 13:09 ` Lucas De Marchi
2021-01-11 14:13 Shuo Wang
2021-01-21  7:06 Shuo Wang
2021-01-23 19:04 ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).