[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: cgi/cmd.c: Squelch warning about empty gnu_printf format string (Andreas Ericsson)

git at icinga.org git at icinga.org
Wed May 12 18:57:43 CEST 2010


Module: icinga-core
Branch: mfriedrich/core
Commit: 8a307eab39a3ef4d9b6cd7cd78f85b52c95e7fa3
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=8a307eab39a3ef4d9b6cd7cd78f85b52c95e7fa3

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed May 12 18:53:43 2010 +0200

cgi/cmd.c: Squelch warning about empty gnu_printf format string  (Andreas Ericsson)

fixes #397

---

 Changelog |    1 +
 cgi/cmd.c |   14 ++++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Changelog b/Changelog
index e0dc556..9caf572 100644
--- a/Changelog
+++ b/Changelog
@@ -28,6 +28,7 @@ FIXES
 * core: create logging.h, with stubs for the common function in cgiutils.c (Andreas Ericsson)
 * core: Janitor patch: Remove unused variables (Andreas Ericsson)
 * core: base/utils.c: typo-fix s/escape_newlines==/escape_newlines_please==/ (Andreas Ericsson)
+* core: cgi/cmd.c: Squelch warning about empty gnu_printf format string  (Andreas Ericsson)
 
 * idoutils: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)
 * idoutils: ndo2db_get_object_id fails to return existing IDs (William Preston)
diff --git a/cgi/cmd.c b/cgi/cmd.c
index 222b341..f2acafd 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -1918,11 +1918,13 @@ static int cmd_submitf(int id, const char *fmt, ...){
 	if (len < 0)
 		return ERROR;
 
-	va_start(ap, fmt);
-	len2 = vsnprintf(&cmd[len], sizeof(cmd) - len - 1, fmt, ap);
-	va_end(ap);
-	if (len2 < 0)
-		return ERROR;
+	if(fmt) {
+		va_start(ap, fmt);
+		len2 = vsnprintf(&cmd[len], sizeof(cmd) - len - 1, fmt, ap);
+		va_end(ap);
+		if (len2 < 0)
+			return ERROR;
+	}
 
 	return write_command_to_file(cmd);
 	}
@@ -1985,7 +1987,7 @@ int commit_command(int cmd){
 	case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
 	case CMD_START_OBSESSING_OVER_HOST_CHECKS:
 	case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
-		result = cmd_submitf(cmd,"");
+		result = cmd_submitf(cmd,NULL);
 		break;
 
 		/** simple host commands **/





More information about the icinga-checkins mailing list