[PATCH] AIX - fix for xlc compile warnings due to missing typecasts

Markus Baertschi markus at markus.org
Thu Oct 16 11:25:10 CEST 2008


On AIX the xlc compiler warns about incompatible pointer types
in base/events.c, base/nebmods.c and xdata/xpddefault.c.
The message is typically as this:
"nebmods.c", line 538.48: 1506-068 (W) Operation between types "void*" and
"int(*)(int,void*)" is not allowed.
This patch adds the necessary typecasts '(void*)' to eliminate the warning.

The patch applies against 3.0.3 and the CVS tarball. I've tested
it on AIX 5.3 with xlc (the IBM compiler) and gcc and also on
Linux (Ubuntu hardy, gcc 4.1.2).

Markus


diff --git a/base/events.c b/base/events.c
index 794b207..95094fa 100644
--- a/base/events.c
+++ b/base/events.c
@@ -575,7 +575,7 @@ void init_timing_loop(void){

        /* add a log rotation event if necessary */
        if(log_rotation_method!=LOG_ROTATION_NONE)
-
schedule_new_event(EVENT_LOG_ROTATION,TRUE,get_next_log_rotation_time(),TRUE,0,get_next_log_rotation_time,TRUE,NULL,NULL,0);
+
schedule_new_event(EVENT_LOG_ROTATION,TRUE,get_next_log_rotation_time(),TRUE,0,(void
*)get_next_log_rotation_time,TRUE,NULL,NULL,0);

        /* add a retention data save event if needed */
        if(retain_state_information==TRUE && retention_update_interval>0)
@@ -792,7 +792,7 @@ void reschedule_event(timed_event *event, timed_event
**event_list, timed_event

                /* use custom timing function */
                if(event->timing_func!=NULL){
-                       timingfunc=event->timing_func;
+                       (void *)timingfunc=event->timing_func;
                        event->run_time=(*timingfunc)();
                        }

@@ -1379,7 +1379,7 @@ int handle_timed_event(timed_event *event){

                /* run a user-defined function */
                if(event->event_data!=NULL){
-                       userfunc=event->event_data;
+                       (void *)userfunc=event->event_data;
                        (*userfunc)(event->event_args);
                        }
                break;
@@ -1639,7 +1639,7 @@ void compensate_for_system_time_change(unsigned long
last_time, unsigned long cu

                /* use custom timing function */
                if(temp_event->timing_func!=NULL){
-                       timingfunc=temp_event->timing_func;
+                       (void *)timingfunc=temp_event->timing_func;
                        temp_event->run_time=(*timingfunc)();
                        }

@@ -1660,7 +1660,7 @@ void compensate_for_system_time_change(unsigned long
last_time, unsigned long cu

                /* use custom timing function */
                if(temp_event->timing_func!=NULL){
-                       timingfunc=temp_event->timing_func;
+                       (void *)timingfunc=temp_event->timing_func;
                        temp_event->run_time=(*timingfunc)();
                        }

diff --git a/base/nebmods.c b/base/nebmods.c
index 8485706..6e3d14d 100644
--- a/base/nebmods.c
+++ b/base/nebmods.c
@@ -282,7 +282,7 @@ int neb_load_module(nebmodule *mod){
                }

        /* run the module's init function */
-       initfunc=mod->init_func;
+       (void *)initfunc=mod->init_func;

result=(*initfunc)(NEBMODULE_NORMAL_LOAD,mod->args,mod->module_handle);

        /* if the init function returned an error, unload the module */
@@ -348,7 +348,7 @@ int neb_unload_module(nebmodule *mod, int flags, int
reason){
        /* call the de-initialization function if available (and the module
was initialized) */
        if(mod->deinit_func && reason!=NEBMODULE_ERROR_BAD_INIT){

-               deinitfunc=mod->deinit_func;
+               (void *)deinitfunc=mod->deinit_func;

                /* module can opt to not be unloaded */
                result=(*deinitfunc)(flags,reason);
@@ -505,7 +505,7 @@ int neb_deregister_module_callbacks(nebmodule *mod){

for(temp_callback=neb_callback_list[callback_type];temp_callback!=NULL;temp_callback=next_callback){
                        next_callback=temp_callback->next;
                        if((void *)temp_callback->module_handle==(void
*)mod->module_handle)
-
neb_deregister_callback(callback_type,temp_callback->callback_func);
+
neb_deregister_callback(callback_type,(int(*)(int,void*))temp_callback->callback_func);
                        }

                }
@@ -535,7 +535,7 @@ int neb_deregister_callback(int callback_type, int
(*callback_func)(int,void *))
                next_callback=temp_callback->next;

                /* we found it */
-               if(temp_callback->callback_func==callback_func)
+               if(temp_callback->callback_func==(void *)callback_func)
                        break;

                last_callback=temp_callback;
@@ -578,7 +578,7 @@ int neb_make_callbacks(int callback_type, void *data){

        /* make the callbacks... */

for(temp_callback=neb_callback_list[callback_type];temp_callback!=NULL;temp_callback=temp_callback->next){
-               callbackfunc=temp_callback->callback_func;
+               (void *)callbackfunc=temp_callback->callback_func;
                cbresult=callbackfunc(callback_type,data);

                total_callbacks++;
diff --git a/xdata/xpddefault.c b/xdata/xpddefault.c
index 77446ef..f30c2a8 100644
--- a/xdata/xpddefault.c
+++ b/xdata/xpddefault.c
@@ -316,11 +316,11 @@ int xpddefault_initialize_performance_data(char
*config_file){

        /* periodically process the host perfdata file */
        if(xpddefault_host_perfdata_file_processing_interval>0 &&
xpddefault_host_perfdata_file_processing_command!=NULL)
-
schedule_new_event(EVENT_USER_FUNCTION,TRUE,current_time+xpddefault_host_perfdata_file_processing_interval,TRUE,xpddefault_host_perfdata_file_processing_interval,NULL,TRUE,xpddefault_process_host_perfdata_file,NULL,0);
+
schedule_new_event(EVENT_USER_FUNCTION,TRUE,current_time+xpddefault_host_perfdata_file_processing_interval,TRUE,xpddefault_host_perfdata_file_processing_interval,NULL,TRUE,(void
*)xpddefault_process_host_perfdata_file,NULL,0);

        /* periodically process the service perfdata file */
        if(xpddefault_service_perfdata_file_processing_interval>0 &&
xpddefault_service_perfdata_file_processing_command!=NULL)
-
schedule_new_event(EVENT_USER_FUNCTION,TRUE,current_time+xpddefault_service_perfdata_file_processing_interval,TRUE,xpddefault_service_perfdata_file_processing_interval,NULL,TRUE,xpddefault_process_service_perfdata_file,NULL,0);
+
schedule_new_event(EVENT_USER_FUNCTION,TRUE,current_time+xpddefault_service_perfdata_file_processing_interval,TRUE,xpddefault_service_perfdata_file_processing_interval,NULL,TRUE,(void
*)xpddefault_process_service_perfdata_file,NULL,0);

        /* save the host perf data file macro */
        my_free(macro_x[MACRO_HOSTPERFDATAFILE]);


-- 
 Markus Baertschi             Phone: ++41 (21) 807 1677
 Bas du Rossé 16             Fax  : ++41 (21) 807 1678
 CH-1163, Etoy                Email: markus at markus.org
 Switzerland                  Homepage: www.markus.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20081016/39ea610c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typecast.patch
Type: application/octet-stream
Size: 5441 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20081016/39ea610c/attachment.obj>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------- next part --------------
_______________________________________________
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