[PATCH] schedule_new_event() returns a pointer to a timed_event structure

Ricardo Maraschini ricardo.maraschini at opservices.com.br
Fri Jun 22 19:59:29 CEST 2012


Hello, 

Please attempt to fix below, maybe we gonna have some problems ahead :-)
During Nagios compilation I've received the following warning:

commands.c: In function ‘cmd_signal_process’:
commands.c:2000:9: warning: assignment makes integer from pointer without a cast [enabled by default]

Looking to the code, schedule_new_event() returns a pointer to a timed_event structure or NULL in case of errors during malloc. As cmd_signal_process() returns an integer, i've made a patch to analyse the return of schedule_new_event() and give the appropriate return code(ERROR || OK).

As I've also seen, we are using cmd_signal_process() only once, and it's inside commands.c. The funny thing is that we don't check for return code when we call it :-)





--- base/commands.c	(revision 1973)
+++ base/commands.c	(working copy)
@@ -1989,6 +1989,7 @@
 	time_t scheduled_time = 0L;
 	char *temp_ptr = NULL;
 	int result = OK;
+	timed_event *event; 
 
 	/* get the time to schedule the event */
 	if((temp_ptr = my_strtok(args, "\n")) == NULL)
@@ -1997,8 +1998,11 @@
 		scheduled_time = strtoul(temp_ptr, NULL, 10);
 
 	/* add a scheduled program shutdown or restart to the event list */
-	result = schedule_new_event((cmd == CMD_SHUTDOWN_PROCESS) ? EVENT_PROGRAM_SHUTDOWN : EVENT_PROGRAM_RESTART, TRUE, scheduled_time, FALSE, 0, NULL, FALSE, NULL, NULL, 0);
+	event = schedule_new_event((cmd == CMD_SHUTDOWN_PROCESS) ? EVENT_PROGRAM_SHUTDOWN : EVENT_PROGRAM_RESTART, TRUE, scheduled_time, FALSE, 0, NULL, FALSE, NULL, NULL, 0);
 
+	if (event == NULL)
+		result = ERROR;
+
 	return result;
 	}
 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list