modules: BOOL vs. int
Christopher R. Hertel
crh at ubiqx.mn.org
Thu Mar 27 17:33:03 GMT 2003
Not that this is "correct" or anything... just my 2cents.
I tend in my own code to return negative integers to indicate warnings or
errors, with different negative values having different meaning (as
needed). That way, I can simply check for < 0 on return. If I want to
get specific about what the error was I can look more carefully at the
return value.
I spent a little time programming in Icon. Interesting language. Every
function returns a status code in addition to all other data.
Chris -)-----
On Thu, Mar 27, 2003 at 02:29:11PM +0100, Stefan (metze) Metzmacher wrote:
> At 12:12 27.03.2003 +0100, Jelmer Vernooij wrote:
> >> I noticed that all smb_register_*() fn's return BOOL
> >> and the init_module() fn's returns int
> >> so this is wrong:
> >I don't have problems with this. We only need the return value in
> >smb_probe_module() to check for failure, and False is defined to be
> >equal to 0. The current way is more flexible. Some functions return a
> >BOOL, but others return an int (such as in rpc).
>
> You're right but I think its confusing
>
> can't we name the return var
> BOOL when we use True or False
> or!!!
> int when we use 0 or -1
>
> because int 0 means often success and BOOL False (int 0) means failure
> (this is confusing and cries for bugs!!!)
>
> And just for a better coding style :-)
>
> And I want it to be equal for all smb_register_*() fn's
> >> int auth_sam_init(void)
> >> {
> >> smb_register_auth("samstrict_dc", auth_init_samstrict_dc,
> >> AUTH_INTERFACE_VERSION);
> >> smb_register_auth("samstrict", auth_init_samstrict,
> >> AUTH_INTERFACE_VERSION);
> >> smb_register_auth("sam", auth_init_sam, AUTH_INTERFACE_VERSION);
> >> return True;
> >> }
> >When would you want the function to fail ? If registering one of the
> >functions fails?
>
> ok don't fail but a warning would be good
>
>
>
> metze
> -----------------------------------------------------------------------------
> Stefan "metze" Metzmacher <metze at metzemix.de>
>
--
Samba Team -- http://www.samba.org/ -)----- Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/ -)----- ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/ -)----- crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/ -)----- crh at ubiqx.org
More information about the samba-technical
mailing list