[RFC] get rid of inconsistent -1 values

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Centrium GmbH
Message-ID <[email protected]>
Hi List,

at first I would like to know from Bruno anything about this _mess_:
Msg *msg_create(enum msg_type type)
{
    Msg *msg;

    msg = gw_malloc(sizeof(Msg));

    msg->type = type;
#define INTEGER(name) p->name = 0
#define OCTSTR(name) p->name = NULL
#define MSG(type, stmt) { struct type *p = &msg->type; stmt }
#include "msg-decl.h"

----------
    if(type == sms) { /* reset */
	msg->sms.sender = msg->sms.receiver = msg->sms.udhdata =
	    msg->sms.msgdata = msg->sms.smsc_id = msg->sms.service =
	    msg->sms.account = msg->sms.dlr_url = msg->sms.charset =
	    msg->sms.boxc_id = msg->sms.auth_code = msg->sms.hplmn = NULL;
	msg->sms.time = (time_t) -1;
	msg->sms.id = msg->sms.mclass = msg->sms.mwi = msg->sms.coding =
	    msg->sms.compress = msg->sms.validity = msg->sms.deferred =
	    msg->sms.dlr_mask = msg->sms.pid = msg->sms.alt_dcs =
	    msg->sms.rpi = -1;
    }
----------------------
 (if we start to _hack_ the code in such order, then we doesn't need 
msg-decl.h at all. I see this sniplet as: I want that UNDEF values are -1, 
but it doesn't work as I want, so I do simple hack rather as: heh I must fix 
all other messages types too and do it)

    return msg;
}

And now to these '-1' values. At first it's inconsistent to have -1 values 
only for sms values. If we want to have '-1' == UNDEF then _all_ message 
types should use it and not only sms and I do not see any goal to have these? 
am I wrong? then please explain why -1 should be better as 0 (zero)?
Only one thing I can see is: sendsms interface can use sms values (e.g. 
mclass) as is (0-3).

So (imo) we have 2 options:
	1) make all message types consistent, means using -1 as UNDEF values
	2) get rid of -1 UNDEF values for sms message type.


Comments and votes please....

-- 
Best regards / Mit besten Grüßen aus Düsseldorf

Dipl.-Ing.
Alexander Malysh
___________________________________________

Centrium GmbH
Vogelsanger Weg 80
40470 Düsseldorf

Fon: +49 (0211) 74 84 51 80
Fax: +49 (0211) 277 49 109

email: [email protected]
web: www.centrium.de
msn: [email protected]
icq: 98063111
___________________________________________

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.