httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: svn commit: r814091 - in /httpd/httpd/trunk: CHANGES support/htcacheclean.c
Date Tue, 15 Sep 2009 14:16:16 GMT
On Tue, Sep 15, 2009 at 9:45 AM, Graham Leggett <minfrin@sharp.fm> wrote:

> Jeff Trawick wrote:
>
> > Why does opt need to be cast to (int)?
>
> >From the printf man page:
>
>     c       The int argument is converted to an unsigned char, and the
>             resulting character is written.
>

That's what happens inside printf().  On the caller side, my understanding
is that the compiler already promotes the argument to int because of the ...
.

Sanity check: Why aren't we explicitly promoting char parameters in other
calls to *printf?


> > Why not simply zap all these checks of the form
> >
> > if (silly user specified no-argument option again) {
> >   remind them who is boss
> > }
> >
> > to avoid code bloat?
>
> Can you give an example?
>

Just zap the check since it is unnecessary.

Index: support/htcacheclean.c
===================================================================
--- support/htcacheclean.c      (revision 815331)
+++ support/htcacheclean.c      (working copy)
@@ -811,44 +811,26 @@
         else {
             switch (opt) {
             case 'i':
-                if (intelligent) {
-                    usage(apr_psprintf(pool, "The option '%c' cannot be
specified more than once", (int)opt));
-                }
                 intelligent = 1;
                 break;

             case 'D':
-                if (dryrun) {
-                    usage(apr_psprintf(pool, "The option '%c' cannot be
specified more than once", (int)opt));
-                }
                 dryrun = 1;
                 break;

             case 'n':
-                if (benice) {
-                    usage(apr_psprintf(pool, "The option '%c' cannot be
specified more than once", (int)opt));
-                }
                 benice = 1;
                 break;

and so on.

--/--

Ignoring the opinion that it isn't worth writing this code code for a
moment, isn't it a sign that something needs further work when the same
exact string occurs 9 times in the code?

Mime
View raw message