From 82f2bdb17aea86dbef296c60dd4eee691695036e Mon Sep 17 00:00:00 2001 From: Aurelien Degremont Date: Tue, 28 Jan 2025 15:08:07 +0100 Subject: [PATCH] LU-19098 hsm: don't print progname twice with lhsmtool Since Lustre 2.11, log message from llapi_error() prefixes the message with the current program short name. There is no more a need for lhsmtool_posix log fonctions (CT_xxxx) to also do the same. Remove the duplicate prog name and cmd_name. Test-Parameters: trivial testlist=sanity-hsm Signed-off-by: Aurelien Degremont Change-Id: I4ebdf01cd00d1544678cbad066e2c3a79ecfda38 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59680 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/utils/lhsmtool_posix.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lustre/utils/lhsmtool_posix.c b/lustre/utils/lhsmtool_posix.c index ae6e608..7e02586 100644 --- a/lustre/utils/lhsmtool_posix.c +++ b/lustre/utils/lhsmtool_posix.c @@ -169,7 +169,6 @@ static int arc_fd = -1; static int err_major; static int err_minor; -static char cmd_name[PATH_MAX]; static char fs_name[MAX_OBD_NAME + 1]; static int pid_file_fd = -1; @@ -186,23 +185,23 @@ static inline double ct_now(void) #define CT_ERROR(_rc, _format, ...) \ llapi_error(LLAPI_MSG_ERROR, _rc, \ - "%f %s[%ld]: "_format, \ - ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__) + "%f [%ld]: "_format, \ + ct_now(), syscall(SYS_gettid), ## __VA_ARGS__) #define CT_DEBUG(_format, ...) \ llapi_error(LLAPI_MSG_DEBUG | LLAPI_MSG_NO_ERRNO, 0, \ - "%f %s[%ld]: "_format, \ - ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__) + "%f [%ld]: "_format, \ + ct_now(), syscall(SYS_gettid), ## __VA_ARGS__) #define CT_WARN(_format, ...) \ llapi_error(LLAPI_MSG_WARN | LLAPI_MSG_NO_ERRNO, 0, \ - "%f %s[%ld]: "_format, \ - ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__) + "%f [%ld]: "_format, \ + ct_now(), syscall(SYS_gettid), ## __VA_ARGS__) #define CT_TRACE(_format, ...) \ llapi_error(LLAPI_MSG_INFO | LLAPI_MSG_NO_ERRNO, 0, \ - "%f %s[%ld]: "_format, \ - ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__) + "%f [%ld]: "_format, \ + ct_now(), syscall(SYS_gettid), ## __VA_ARGS__) static void usage(const char *name, int rc) { @@ -257,7 +256,7 @@ static void usage(const char *name, int rc) " -u, --update-interval Interval between progress reports sent\n" " to Coordinator\n" " -v, --verbose Produce more verbose output\n", - cmd_name, cmd_name, cmd_name, cmd_name, cmd_name, cmd_name); + name, name, name, name, name, name); exit(rc); } @@ -410,7 +409,7 @@ repeat: opt.o_event_fifo = optarg; break; case 'h': - usage(argv[0], 0); + usage(basename(argv[0]), 0); case 'i': opt.o_action = CA_IMPORT; break; @@ -2446,10 +2445,10 @@ int main(int argc, char **argv) { int rc; - snprintf(cmd_name, sizeof(cmd_name), "%s", basename(argv[0])); rc = ct_parseopts(argc, argv); if (rc < 0) { - CT_WARN("try '%s --help' for more information", cmd_name); + CT_WARN("try '%s --help' for more information", + basename(argv[0])); return -rc; } -- 1.8.3.1