Page 1 of 1

[Nagios-devel] [PATCH] schedule_new_event() returns a pointer to a

Posted: Fri Jun 22, 2012 5:09 pm
by Guest
Hello,=20

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 =E2=80=98cmd_signal_process=E2=80=99:
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_even=
t 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_n=
ew_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 in=
side commands.c. The funny thing is that we don't check for return code whe=
n we call it :-)





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





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]