You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stanley Gambarin <st...@cs.bu.edu> on 1997/07/21 18:32:39 UTC

code cleanup


	There is a lot of occurrences of the code in the form
#if defined(STUFF) 
	some_func()
#endif
	which is really "not good" especially if some_func() is 
invoked multiple times.  One of the possible solutions is to change 
the above to following:

#if defined (STUFF)
some_func() 
{
	...
}
#else
#define some_func() /* nop */
#endif

	this reduces the amount of ifdef's in the code, with no penalties.
Diffs below attempt to do this for some of the STATUS defines.
							Stanley.


*** http_main.c	Mon Jul 21 00:00:35 1997
--- http_main.c.bak	Sun Jul 13 23:46:03 1997
  
      put_scoreboard_info(child_num, &new_score_rec); 
  }
- #else
- void time_process_request (int child_num, int status) /* nop */
- static void increment_counts (int child_num, request_rec *r) /* nop */
  #endif
  
  
--- 1211,1216 ----
***************
*** 2296,2302 ****
--- 2292,2301 ----
              (void)update_child_status(child_num, SERVER_BUSY_WRITE, r);
  
              process_request(r);
+ 
+ #if defined(STATUS)
              increment_counts(child_num, r);
+ #endif
  
              if (!current_conn->keepalive || current_conn->aborted) 
                  break;
***************
*** 3049,3055 ****
--- 3037,3046 ----
              (void)update_child_status(child_num, SERVER_BUSY_WRITE, r);
  
              process_request(r);
+ 
+ #if defined(STATUS)
              increment_counts(child_num, r);
+ #endif
  
              if (!current_conn->keepalive || current_conn->aborted)
                  break;

Re: code cleanup

Posted by Marc Slemko <ma...@worldgate.com>.
This changes functions from doing x if y is enabled and having undefined
behavior otherwise to doing x if y is enabled, otherwise doing nothing.

It means that anywhere you need to do x, you simply do x() in the code; if
whatever uses x() isn't enabled in that server, it simply does nothing. 
This takes what ap_select does one step further.  I think I like the idea,
but if taken too far it can be more confusion than it is worth. 

On Mon, 21 Jul 1997 rasmus@bellglobal.com wrote:

> >      There is a lot of occurrences of the code in the form
> > #if defined(STUFF) 
> >      some_func()
> > #endif
> >      which is really "not good" especially if some_func() is 
> > invoked multiple times.  One of the possible solutions is to change 
> > the above to following:
> > 
> > #if defined (STUFF)
> > some_func() 
> > {
> >      ...
> > }
> > #else
> > #define some_func() /* nop */
> > #endif
> 
> But #if defined() is a preprocessor directive.  I don't understand the
> motivation for this one.
> 
> -Rasmus
> 


Re: code cleanup

Posted by ra...@bellglobal.com.
>      There is a lot of occurrences of the code in the form
> #if defined(STUFF) 
>      some_func()
> #endif
>      which is really "not good" especially if some_func() is 
> invoked multiple times.  One of the possible solutions is to change 
> the above to following:
> 
> #if defined (STUFF)
> some_func() 
> {
>      ...
> }
> #else
> #define some_func() /* nop */
> #endif

But #if defined() is a preprocessor directive.  I don't understand the
motivation for this one.

-Rasmus