Re: [Nagios-devel] Patches for nagios-3.0b6
Posted: Tue Nov 06, 2007 3:32 pm
Lars Vogdt wrote:
> Hi
>
> First: thanks for this great product!
>
> I like to thank a bit with the following 3 patches for nagios-3.0b6 -
> and would feel happy if you can apply them for the next release.
>
> I've got some more compiler (gcc42) warnings about implicit
> declarations, unused variables and ignoring function return values.
> But I haven't investigated any time in these warnings, yet.
>
If you could start with implicit declarations that'd be great, since
those might hide real bugs. I'm fairly certain you'd lower the
warnings for ignored return values by that too (although you almost
certainly want to disable that warning, since it's pretty common
practice to ignore return values of memcpy(), snprintf(), strcpy()
and their likes).
>
> 2) Fix compiler warnings part 1 (string compare)
>
> Index: cgi/avail.c
> ===================================================================
> --- cgi/avail.c.orig
> +++ cgi/avail.c
> @@ -2475,7 +2475,7 @@
> char *last_host_name="";
>
> /* we're displaying one or more hosts */
> - if(display_type==DISPLAY_HOST_AVAIL && host_name!=""){
> + if(display_type==DISPLAY_HOST_AVAIL && (strcmp(host_name,"")!=0)){
>
Please make this
if (... && host_name[0] != 0)
instead, and same for the rest of the cases. If there's any doubt that
the variable is initialized, make them "(... && host_name && host_name[0] != 0)"
instead.
>
> 3) Fix compiler warnings part 2 (variable used bevor set)
>
This one passes the 5 minute review unmolested. Nicely done.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
> Hi
>
> First: thanks for this great product!
>
> I like to thank a bit with the following 3 patches for nagios-3.0b6 -
> and would feel happy if you can apply them for the next release.
>
> I've got some more compiler (gcc42) warnings about implicit
> declarations, unused variables and ignoring function return values.
> But I haven't investigated any time in these warnings, yet.
>
If you could start with implicit declarations that'd be great, since
those might hide real bugs. I'm fairly certain you'd lower the
warnings for ignored return values by that too (although you almost
certainly want to disable that warning, since it's pretty common
practice to ignore return values of memcpy(), snprintf(), strcpy()
and their likes).
>
> 2) Fix compiler warnings part 1 (string compare)
>
> Index: cgi/avail.c
> ===================================================================
> --- cgi/avail.c.orig
> +++ cgi/avail.c
> @@ -2475,7 +2475,7 @@
> char *last_host_name="";
>
> /* we're displaying one or more hosts */
> - if(display_type==DISPLAY_HOST_AVAIL && host_name!=""){
> + if(display_type==DISPLAY_HOST_AVAIL && (strcmp(host_name,"")!=0)){
>
Please make this
if (... && host_name[0] != 0)
instead, and same for the rest of the cases. If there's any doubt that
the variable is initialized, make them "(... && host_name && host_name[0] != 0)"
instead.
>
> 3) Fix compiler warnings part 2 (variable used bevor set)
>
This one passes the 5 minute review unmolested. Nicely done.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]