File pacemaker#3795-0001-Low-various-address-format-overflow-warnings.patch of Package pacemaker.38493

From e4fc91fef4a05f981f235e8aa2f476fbb9da7ac1 Mon Sep 17 00:00:00 2001
From: Athos Ribeiro <athos.ribeiro@canonical.com>
Date: Thu, 9 Jan 2025 11:40:18 -0300
Subject: [PATCH] Low: various: address format-overflow warnings

When using -O3 to build pacemaker, gcc (14) will throw format-overflow
warnings for some possibly null '%s' directive arguments. We address the
current instances of such warnings by either removing meaningless log
entries or by moving them into proper contexts.

alerts.c:153:19: error: '%s' directive argument is null [-Werror=format-overflow=]
153 |         crm_trace("Inserting alert key %s = '%s'", *key, value);
    |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alerts.c:153:46: note: format string is defined here
153 |         crm_trace("Inserting alert key %s = '%s'", *key, value);
    |

Signed-off-by: Athos Ribeiro <athos.ribeiro@canonical.com>
---
 daemons/controld/controld_te_events.c | 1 -
 lib/common/alerts.c                   | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

Index: pacemaker-2.1.7+20231219.0f7f88312/daemons/controld/controld_te_events.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/daemons/controld/controld_te_events.c
+++ pacemaker-2.1.7+20231219.0f7f88312/daemons/controld/controld_te_events.c
@@ -320,7 +320,6 @@ get_cancel_action(const char *id, const
 
             task = crm_element_value(action->xml, XML_LRM_ATTR_TASK_KEY);
             if (!pcmk__str_eq(task, id, pcmk__str_casei)) {
-                crm_trace("Wrong key %s for %s on %s", task, id, node);
                 continue;
             }
 
Index: pacemaker-2.1.7+20231219.0f7f88312/lib/common/alerts.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/lib/common/alerts.c
+++ pacemaker-2.1.7+20231219.0f7f88312/lib/common/alerts.c
@@ -150,10 +150,11 @@ pcmk__add_alert_key(GHashTable *table, e
                     const char *value)
 {
     for (const char **key = pcmk__alert_keys[name]; *key; key++) {
-        crm_trace("Inserting alert key %s = '%s'", *key, value);
         if (value) {
+            crm_trace("Inserting alert key %s = '%s'", *key, value);
             g_hash_table_insert(table, strdup(*key), strdup(value));
         } else {
+            crm_trace("Removing alert key %s (no value given)", *key);
             g_hash_table_remove(table, *key);
         }
     }
openSUSE Build Service is sponsored by