From b5cf7ec784335ec561e379f8e78f48019a344ac0 Mon Sep 17 00:00:00 2001 From: Shreenidhi Shedi Date: Mon, 9 Aug 2021 00:21:10 +0530 Subject: [PATCH] fix(install): rectify unused function args in log.c Signed-off-by: Shreenidhi Shedi --- src/install/log.c | 8 +++++--- src/install/macro.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/install/log.c b/src/install/log.c index 303eece86e..3f77b5a5c1 100644 --- a/src/install/log.c +++ b/src/install/log.c @@ -103,10 +103,12 @@ void log_set_facility(int facility) static int write_to_console(int level, const char *file, unsigned int line, const char *func, const char *buffer) { - struct iovec iovec[5]; unsigned int n = 0; + // might be useful going ahead + UNUSED(level); + if (console_fd < 0) return 0; @@ -115,8 +117,8 @@ static int write_to_console(int level, const char *file, unsigned int line, cons IOVEC_SET_STRING(iovec[n++], "dracut-install: "); if (show_location) { - char location[64]; - if (snprintf(location, sizeof(location), "(%s:%u) ", file, line) <= 0) + char location[LINE_MAX] = {0}; + if (snprintf(location, sizeof(location), "(%s:%s:%u) ", file, func, line) <= 0) return -errno; IOVEC_SET_STRING(iovec[n++], location); } diff --git a/src/install/macro.h b/src/install/macro.h index a6346c9db8..003cf80ac5 100644 --- a/src/install/macro.h +++ b/src/install/macro.h @@ -293,4 +293,7 @@ do { \ _ptr_; \ }) +/* Use to suppress unused variable/function arg warning */ +#define UNUSED(var) ((void)var) + #include "log.h"