[wplug] C compiling question

Rafael E. Herrera raffo at neuronet.pitt.edu
Tue Oct 1 07:21:51 EDT 2002


James O'Kane wrote:
> Did something like this ever work as expected with any version of gcc? I
> found this code in mod_throttle, an apache module to add quotas to remote
> users. I'm surprised that it is being distributed because at least for me,
> it doesn't do what I would want. I've changed things to strcmp(), so I'm
> all set in terms of getting it to work, but I'm curious if gcc ever
> compiled this so it would work?
> 
> 
> static const char true[] = "true";
> char *foo = NULL;
> 
> foo = setfoo();
> 
> if(foo == true){
> // do stuff if foo is true
> }


If the idea is to check whether setfoo() returned successfully, that 
piece of code is really wrong or just very poor coding style.

If a function needs to return a success status, make it just return a 0 
or 1.

-- 
      Rafael




More information about the wplug mailing list