**To: devel@kannel.org
**From: Alexander Malysh [EMAIL PROTECTED]
**Subject: Re: fluctuating between XXX_UNDEF and '-1' in Kannel code
**Date: Fri, 18 Feb 2005 15:26:53 +0100
**
**Hi Davy,
**
**Davy Chan wrote:
**
** Statement:
** We are now using -1 as the definition for an undefined value:
** DLR_UNDEFINED = MSG_PARAM_UNDEFINED = SMS_PARAM_UNDEFINED =
** MC_UNDEF = MWI_UNDEF = DC_UNDEF = COMPRESS_UNDEF = RPI_UNDEF
** = -1
**
**hmm, don't have code to check now but IIRC we have onl MSG_PARAM_UNDEFINED
**SMS_PARAM_UNDEFINED.
**that was intentional so that MSG_PARAM_UNDEFINED may have another undefined
**value as SMS_PARAM_UNDEFINED.
Actually, in gateway/gw/sms.h, the other UNDEF's are defined there. Of
course, currently, they are defined based on the SMS_PARAM_UNDEFINED which
is based on MSG_PARAM_UNDEFINED.
But, the other UNDEFs are in the header, and I think they should be
used instead of -1 in gateway/gw/smsbox.c:smsbox_req_handle(). As
a matter of fact, my patch will use the defined symbols as
much as possible. Fixed two bugs (rpi cannot be greater than 1 not 2; and
alt_dcs can be greater than 1 [max is 2]) by using the defines instead
of hardcoding the values.
**
**
** Problem:
** 1) Some of our code still has '-1' hardcoded instead of using the
** symbolic XXX_UNDEF.
**
**this should be fixed
**
** 2) Some places in the code have a comparison to '-1' to check for
** an undefined value instead of using the symbolic XXX_UNDEF.
**
**ditto
**
** 3) Some places in the code use a comparison to '-1' to check for
** an undefined value because we did not specify a symbolic
** name for an undefined value (usually return values from
** the gwlib functions).
**
**we should not define all undefined values as you write above. sms messages
**should check against SMS_PARAM_UNDEFINED and global msg values (not sms
**specific) against MSG_PARAM_UNDEFINED.
Sorry. Not as clear as I should have been. I mean to use SMS_PARAM_UNDEFINED,
MSG_PARAM_UNDEFINED, DLR_UNDEFINED, MC_UNDEF, MWI_UNDEF, DC_UNDEF,
COMPRESS_UNDEF, and RPI_UNDEF where appliable. When a -1 is present
where it is not related to SMS or MSG (e.g. octstr functions and
conn connections), then use IS_UNDEFINED.
Doing it this way allowed me to find another bug in the code in
gateway/gw/wap_push_pap_compiler.c:parse_attribute(). Down in the
code, there's a check to see if set_attribute_value() returns -1 or
not. Well, set_attribute_value() cannot return -1. It can only
return [-2,0,1,2,3]. They correspond to the values returned by
parse_requirements(), parse_priority(), and parse_delivery_method().
**
** Proposed Remedy:
** 1) Add the definition:
**#define IS_UNDEFINED -1
** into gateway/gwlib/gwlib.h
** 2) Go through the code and change comparisions to '-1' into
** comparisions to IS_UNDEFINED.
** 3) Go through the code and change assignments to '-1' to
** assignments to the proper XXX_UNDEF for that variable.
**
** I voluntee to do this if everyone feels this type of code cleanup
** is desired. (yeah, this is annoying the heck out of me while I'm coding
** my statusbox stuff).
I've got most of it done. Will try compiling and running it now...
See ya...
d.c.