File bsc#1246622-0001-Log-various-Avoid-warnings-about-a-negative-value-fo.patch of Package pacemaker

From 11ab54a6b11e11a457fe9c84527a9da9866fff1e Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Thu, 24 Jul 2025 11:39:51 +0200
Subject: [PATCH] Log: various: Avoid warnings about a negative value for
 `stonith-watchdog-timeout`

Despite the discussion from
https://github.com/ClusterLabs/pacemaker/pull/3677 about some potential
ideas for the future, so far it has been documented that a negative
value for `stonith-watchdog-timeout` is valid. But with 56a00acc6a,
crm_get_msec() started explicitly warning about a "Negative" value being
invalid.

Even if we decide to forbid any negative value for
`stonith-watchdog-timeout` in the future, it'll need a proper
deprecation and eventually a transformation. So no matter how we'll
proceed, for now we probably have to parse it as an integer first to
avoid the warning from crm_get_msec() .
---
 daemons/controld/controld_fencing.c | 14 +++++++++++++-
 daemons/fenced/fenced_cib.c         | 12 ++++++++++--
 lib/common/watchdog.c               | 16 ++++++++++++++--
 3 files changed, 37 insertions(+), 5 deletions(-)

Index: pacemaker-2.1.10+20250718.fdf796ebc8/daemons/controld/controld_fencing.c
===================================================================
--- pacemaker-2.1.10+20250718.fdf796ebc8.orig/daemons/controld/controld_fencing.c
+++ pacemaker-2.1.10+20250718.fdf796ebc8/daemons/controld/controld_fencing.c
@@ -1009,9 +1009,21 @@ controld_execute_fence_action(pcmk__grap
 bool
 controld_verify_stonith_watchdog_timeout(const char *value)
 {
-    long long st_timeout = (value != NULL)? crm_get_msec(value) : 0;
+    long long st_timeout = 0;
     const char *our_nodename = controld_globals.our_nodename;
 
+    if (value != NULL) {
+        /* @COMPAT So far it has been documented that a negative value is
+         * valid. Parse it as an integer first to avoid the warning from
+         * crm_get_msec().
+         */
+        int rc = pcmk__scan_ll(value, &st_timeout, PCMK__PARSE_INT_DEFAULT);
+
+        if (rc != pcmk_rc_ok || st_timeout >= 0) {
+            st_timeout = crm_get_msec(value);
+        }
+    }
+
     if (st_timeout == 0
         || (stonith_api && (stonith_api->state != stonith_disconnected) &&
             stonith__watchdog_fencing_enabled_for_node_api(stonith_api,
Index: pacemaker-2.1.10+20250718.fdf796ebc8/daemons/fenced/fenced_cib.c
===================================================================
--- pacemaker-2.1.10+20250718.fdf796ebc8.orig/daemons/fenced/fenced_cib.c
+++ pacemaker-2.1.10+20250718.fdf796ebc8/daemons/fenced/fenced_cib.c
@@ -203,8 +203,16 @@ update_stonith_watchdog_timeout_ms(xmlNo
     if (stonith_watchdog_xml) {
         value = crm_element_value(stonith_watchdog_xml, PCMK_XA_VALUE);
     }
-    if (value) {
-        timeout_ms = crm_get_msec(value);
+    if (value != NULL) {
+        /* @COMPAT So far it has been documented that a negative value is
+         * valid. Parse it as an integer first to avoid the warning from
+         * crm_get_msec().
+         */
+        int rc = pcmk__scan_ll(value, &timeout_ms, PCMK__PARSE_INT_DEFAULT);
+
+        if (rc != pcmk_rc_ok || timeout_ms >= 0) {
+            timeout_ms = crm_get_msec(value);
+        }
     }
 
     if (timeout_ms < 0) {
Index: pacemaker-2.1.10+20250718.fdf796ebc8/lib/common/watchdog.c
===================================================================
--- pacemaker-2.1.10+20250718.fdf796ebc8.orig/lib/common/watchdog.c
+++ pacemaker-2.1.10+20250718.fdf796ebc8/lib/common/watchdog.c
@@ -288,11 +288,23 @@ pcmk__valid_stonith_watchdog_timeout(con
      * specific string like "auto" (but not both) to mean "auto-calculate the
      * timeout." Reject other values that aren't parsable as timeouts.
      */
-    long st_timeout = value? crm_get_msec(value) : 0;
+    long long st_timeout = 0;
+
+    if (value != NULL) {
+        /* @COMPAT So far it has been documented that a negative value is
+         * valid. Parse it as an integer first to avoid the warning from
+         * crm_get_msec().
+         */
+        int rc = pcmk__scan_ll(value, &st_timeout, PCMK__PARSE_INT_DEFAULT);
+
+        if (rc != pcmk_rc_ok || st_timeout >= 0) {
+            st_timeout = crm_get_msec(value);
+        }
+    }
 
     if (st_timeout < 0) {
         st_timeout = pcmk__auto_stonith_watchdog_timeout();
-        crm_debug("Using calculated value %ld for "
+        crm_debug("Using calculated value %lld for "
                   PCMK_OPT_STONITH_WATCHDOG_TIMEOUT " (%s)",
                   st_timeout, value);
     }
openSUSE Build Service is sponsored by