httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject Re: cvs commit: apache-2.0/src/modules/standard mod_include.c
Date Mon, 12 Jun 2000 19:04:40 GMT
> Date: Mon, 12 Jun 2000 11:36:42 -0700
> From: Greg Stein <gstein@lyra.org>
> 
> On Sun, Jun 11, 2000 at 10:50:58AM -0400, Jeff Trawick wrote:
> > > From: ben@locus.apache.org
> > > Date: 11 Jun 2000 14:04:53 -0000
> > > 
> > > ben         00/06/11 07:04:53
> > > 
> > >   Modified:    src/modules/standard mod_include.c
> > >   Log:
> > >   Do printf formatting properly.
> > >   
> > >                        int l, x;
> > >   -#if defined(AP_OFF_T_IS_QUAD)
> > >   -                    ap_snprintf(tag, sizeof(tag), "%qd", finfo.size);
> > >   -#else
> > >   -                    ap_snprintf(tag, sizeof(tag), "%ld", (long)finfo.size);
> > >   -#endif
> > >   +                    ap_snprintf(tag, sizeof(tag), "%" APR_OFF_T_FMT, finfo.size);
> > >                        l = strlen(tag);    /* grrr */
> > 
> > As of this commit we now have warnings on Linux.  Did you see the
> > discussion (or rather, me explaining why I couldn't proceed with
> > Ryan's sugession) yesterday?
> > 
> > What's the plan on getting APR_OFF_T_FMT defined properly?  
> > 
> > I don't know how to work around the problem I described to Ryan
> > yesterday.  How can we safely check during autoconfiguration whether
> > off_t is long int or just int when the size is the same?  Unless this
> > is resolved, I don't see the value in AP_OFF_T_FMT unless there is
> > also an AP_OFF_T_CAST which is used to avoid warnings.  That
> > combination isn't pretty, but at least it avoids the old need to check
> > AP_OFF_T_IS_QUAD.
> 
> We can enable "warnings are errors" in GCC, then try to compile a test
> fragment. If the "%d" and off_t sizes are wrong, then we get an error.
> 
> Of course, this will be specific to GCC, so there would need to be
> mechanisms for other compilers (most compilers have a similar flag), or we
> would need to use the hints.m4 file to patch up the resulting value.
> 
> How's that sound?
> 
> Cheers,
> -g

I think most non-gcc compilers won't be able to validate %d vs off_t
but hopefully most compilers can validate pointer assignment:

#include <sys/types.h>

int main(void)
{
  long *l;
  off_t *o = 0;

  l = o;

  return 0;
}
  
If off_t isn't a long, the statement "l = o;" will generate a warning.

One could imagine an autoconf macro which sets a shell variable to the
format string needed for a given type.

APR_SET_FMT([#include <sys/types.h>], off_t, ac_cv_off_t_fmt)

This would try to compile a little program like the one above with
different types for l, and then set the shell variable to "u", "ld",
"d", or whatever.  Where art thou Sascha? :) 

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Mime
View raw message