85a3c2235b
- wd: gcc shows snprintf warnings(bsc#1071187) Added: 0008-wd-fix-snprintf-warnings.patch OBS-URL: https://build.opensuse.org/request/show/548540 OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/corosync?expand=0&rev=126
75 lines
3.1 KiB
Diff
75 lines
3.1 KiB
Diff
From 0906e5717cce87ac8db25ac9a335a63530dba839 Mon Sep 17 00:00:00 2001
|
|
From: Bin Liu <bliu@suse.com>
|
|
Date: Fri, 1 Dec 2017 10:58:50 +0800
|
|
Subject: [PATCH] wd: fix snprintf warnings
|
|
|
|
When running ./configure --enable-watchdog, gcc 7.2.1 will report
|
|
warnings for snprintf. This patch fixes the warnings.
|
|
|
|
Signed-off-by: Bin Liu <bliu@suse.com>
|
|
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
|
|
---
|
|
exec/wd.c | 20 ++++++++++----------
|
|
1 file changed, 10 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/exec/wd.c b/exec/wd.c
|
|
index 8d0734c9..042d2046 100644
|
|
--- a/exec/wd.c
|
|
+++ b/exec/wd.c
|
|
@@ -221,15 +221,15 @@ static int32_t wd_resource_state_is_ok (struct resource *ref)
|
|
uint64_t allowed_period;
|
|
char key_name[ICMAP_KEYNAME_MAXLEN];
|
|
|
|
- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "last_updated");
|
|
- if (icmap_get_uint64(key_name, &last_updated) != CS_OK) {
|
|
+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "last_updated") >= ICMAP_KEYNAME_MAXLEN) ||
|
|
+ (icmap_get_uint64(key_name, &last_updated) != CS_OK)) {
|
|
/* key does not exist.
|
|
*/
|
|
return CS_FALSE;
|
|
}
|
|
|
|
- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state");
|
|
- if (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0) {
|
|
+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state") >= ICMAP_KEYNAME_MAXLEN) ||
|
|
+ (icmap_get_string(key_name, &state) != CS_OK || strcmp(state, "disabled") == 0)) {
|
|
/* key does not exist.
|
|
*/
|
|
if (state != NULL)
|
|
@@ -279,8 +279,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data)
|
|
|
|
next_timeout = ref->check_timeout;
|
|
|
|
- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "poll_period");
|
|
- if (icmap_get_uint64(ref->res_path, &tmp_value) == CS_OK) {
|
|
+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "poll_period") >= ICMAP_KEYNAME_MAXLEN) ||
|
|
+ (icmap_get_uint64(ref->res_path, &tmp_value) == CS_OK)) {
|
|
if (tmp_value >= WD_MIN_TIMEOUT_MS && tmp_value <= WD_MAX_TIMEOUT_MS) {
|
|
log_printf (LOGSYS_LEVEL_DEBUG,
|
|
"poll_period changing from:%"PRIu64" to %"PRIu64".",
|
|
@@ -299,8 +299,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data)
|
|
}
|
|
}
|
|
|
|
- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "recovery");
|
|
- if (icmap_get_string(key_name, &ref->recovery) != CS_OK) {
|
|
+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "recovery") >= ICMAP_KEYNAME_MAXLEN) ||
|
|
+ (icmap_get_string(key_name, &ref->recovery) != CS_OK)) {
|
|
/* key does not exist.
|
|
*/
|
|
log_printf (LOGSYS_LEVEL_WARNING,
|
|
@@ -308,8 +308,8 @@ static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data)
|
|
cs_fsm_state_set(&ref->fsm, WD_S_STOPPED, ref, wd_fsm_cb);
|
|
return;
|
|
}
|
|
- snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state");
|
|
- if (icmap_get_string(key_name, &state) != CS_OK) {
|
|
+ if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state") >= ICMAP_KEYNAME_MAXLEN) ||
|
|
+ (icmap_get_string(key_name, &state) != CS_OK)) {
|
|
/* key does not exist.
|
|
*/
|
|
log_printf (LOGSYS_LEVEL_WARNING,
|
|
--
|
|
2.13.6
|
|
|