[Nagiosplug-devel] check_nt.c
Karl DeBisschop
kdebisschop at alert.infoplease.com
Tue Jul 29 19:40:04 CEST 2003
Hi Yves,
I'm trying to clenup code for a 1.4.0 alpha on the plugins, so I've got
my compiler set very strict.
I come up with this warning about comparison of unsigned expressions:
gcc -O3 -march=athlon-xp -pedantic -W -Wimplicit-int -Wmain
-Wreturn-type -Wunused -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wparentheses -Wtraditional -Wshadow -Wcast-qual
-Wpointer-arith -L. -L/usr/lib -o check_dig check_dig.o netutils.o
utils.o ../lib/libnagiosplug.a -lnsl -lresolv popen.o
if gcc -DLOCALEDIR=\"/usr/local/nagios/share/locale\" -DHAVE_CONFIG_H
-I. -I../../plugins -I. -I.. -I../../lib -I../../intl
-I/usr/include/ldap -I/include -I/usr/include -I/usr/kerberos/include
-O3 -march=athlon-xp -pedantic -W -Wimplicit-int -Wmain -Wreturn-type
-Wunused -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts
-Wparentheses -Wtraditional -Wshadow -Wcast-qual -Wpointer-arith -MT
check_nt.o -MD -MP -MF ".deps/check_nt.Tpo" \
-c -o check_nt.o `test -f '../../plugins/check_nt.c' || echo
'../../plugins/'`../../plugins/check_nt.c; \
then mv -f ".deps/check_nt.Tpo" ".deps/check_nt.Po"; \
else rm -f ".deps/check_nt.Tpo"; exit 1; \
fi
../../plugins/check_nt.c: In function `main':
../../plugins/check_nt.c:125: warning: comparison of unsigned expression
>= 0 is always true
../../plugins/check_nt.c:127: warning: comparison of unsigned expression
>= 0 is always true
gcc -O3 -march=athlon-xp -pedantic -W -Wimplicit-int -Wmain
-Wreturn-type -Wunused -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wparentheses -Wtraditional -Wshadow -Wcast-qual
-Wpointer-arith -L. -L/usr/lib -o check_nt check_nt.o netutils.o
utils.o ../lib/libnagiosplug.a -lnsl -lresolv
The lines look like:
else if(vars_to_check==CHECK_CPULOAD){
if (check_value_list==TRUE) {
if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
/* -l parameters is present with only integers */
return_code=STATE_OK;
asprintf(&temp_string,"CPU Load");
while (lvalue_list[0+offset]>(unsigned long)0 &&
lvalue_list[0+offset]<=(unsigned long)17280 &&
-> lvalue_list[1+offset]>=(unsigned long)0 &&
lvalue_list[1+offset]<=(unsigned long)100 &&
-> lvalue_list[2+offset]>=(unsigned long)0 &&
lvalue_list[2+offset]<=(unsigned long)100) {
/* loop until one of the parameters is wrong or not present */
/* Send request and retrieve data */
If there are no bugs in the program, those lines could be removed. I
could also imagine there is a bug, and the comparator should be '>'
instead of '>='.
However, as I do not use nsclient or check_nt, I have only just now
started looking at the code. Can you suggest the propoer way to modify
this code so the warning will be suppressed?
--
Karl DeBisschop <kdebisschop at alert.infoplease.com>
More information about the Devel
mailing list