File 0011-dlm_controld-add-gcc-format-printf-attribute-to-log_.patch of Package libdlm
From 1490dfb9a6966cf984f88090b985f662ea04859d Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
Date: Tue, 31 Jan 2023 08:52:24 -0500
Subject: [PATCH 11/24] dlm_controld: add gcc format printf attribute to
log_level
This patch will add __attribute__ (( format( printf, 3, 4 ) ) to
log_level() functionality which has a format string as parameter. With
this change we enable compiler warnings if format string and applied
parameters do not match. We had some couple of warnings which this patch
fixes as well.
---
dlm_controld/daemon_cpg.c | 2 +-
dlm_controld/dlm_daemon.h | 1 +
dlm_controld/plock.c | 3 ++-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/daemon_cpg.c b/dlm_controld/daemon_cpg.c
index e6a03a288ae4..2e0634d4624c 100644
--- a/dlm_controld/daemon_cpg.c
+++ b/dlm_controld/daemon_cpg.c
@@ -2080,7 +2080,7 @@ int receive_run_reply(struct dlm_header *hd, int len)
return 0;
if (len != sizeof(struct run_reply)) {
- log_debug("receive_run_reply %s bad len %s expect %d",
+ log_debug("receive_run_reply %s bad len %d expect %zu",
rep->uuid, len, sizeof(struct run_reply));
run->info.reply_count++;
run->info.need_replies--;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index f0bad90fd699..94a9238f9cd5 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -216,6 +216,7 @@ EXTERN struct list_head run_ops;
#define LOG_PLOCK 0x00010000
#define LOG_NONE 0x00001111
+__attribute__ (( format( printf, 3, 4 ) ))
void log_level(char *name_in, uint32_t level_in, const char *fmt, ...);
#define log_error(fmt, args...) log_level(NULL, LOG_ERR, fmt, ##args)
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 8b052a946f8b..2f0392c3368c 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1925,7 +1925,8 @@ void receive_plocks_data(struct lockspace *ls, struct dlm_header *hd, int len)
/* no locks should be included for owned resources */
if (owner && count) {
- log_elock(ls, "recv_plocks_data %d:%u n %llu o %d bad count %u",
+ log_elock(ls, "recv_plocks_data %d:%u n %llu o %d bad count %" PRIu32,
+ hd->nodeid, hd->msgdata,
(unsigned long long)num, owner, count);
goto fail_free;
}
--
2.35.3