diff mbox series

libmultipath: fix condlog NULL argument in uevent_get_env_var

Message ID 1591312806-25110-1-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series libmultipath: fix condlog NULL argument in uevent_get_env_var | expand

Commit Message

Benjamin Marzinski June 4, 2020, 11:20 p.m. UTC
uevent_get_env_var() could call condlog with p == NULL. On gcc 10,
this triggers warnings like:

In file included from uevent.c:47:
In function 'uevent_get_env_var',
    inlined from 'uevent_get_wwid' at uevent.c:170:8:
debug.h:13:2: error: '%s' directive argument is null
[-Werror=format-overflow=]
   13 |  dlog(logsink, prio, fmt "\n", ##args)
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uevent.c:132:2: note: in expansion of macro 'condlog'
  132 |  condlog(4, "%s: %s -> '%s'", __func__, attr, p);
      |  ^~~~~~~
uevent.c: In function 'uevent_get_wwid':
uevent.c:132:25: note: format string is defined here
  132 |  condlog(4, "%s: %s -> '%s'", __func__, attr, p);
      |                         ^~

If p is NULL, use "(null)" instead.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/uevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin Wilck June 5, 2020, 7:30 p.m. UTC | #1
On Thu, 2020-06-04 at 18:20 -0500, Benjamin Marzinski wrote:
> uevent_get_env_var() could call condlog with p == NULL. On gcc 10,
> this triggers warnings like:
> 
> In file included from uevent.c:47:
> In function 'uevent_get_env_var',
>     inlined from 'uevent_get_wwid' at uevent.c:170:8:
> debug.h:13:2: error: '%s' directive argument is null
> [-Werror=format-overflow=]
>    13 |  dlog(logsink, prio, fmt "\n", ##args)
>       |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> uevent.c:132:2: note: in expansion of macro 'condlog'
>   132 |  condlog(4, "%s: %s -> '%s'", __func__, attr, p);
>       |  ^~~~~~~
> uevent.c: In function 'uevent_get_wwid':
> uevent.c:132:25: note: format string is defined here
>   132 |  condlog(4, "%s: %s -> '%s'", __func__, attr, p);
>       |                         ^~
> 
> If p is NULL, use "(null)" instead.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  libmultipath/uevent.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Martin Wilck <mwilck@suse.com>



--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index d38e8a7f..e0d13b11 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -129,7 +129,7 @@  static const char* uevent_get_env_var(const struct uevent *uev,
 		}
 	}
 
-	condlog(4, "%s: %s -> '%s'", __func__, attr, p);
+	condlog(4, "%s: %s -> '%s'", __func__, attr, p ?: "(null)");
 	return p;
 
 invalid: