apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject Re: Buckets code question
Date Wed, 11 Apr 2001 14:35:03 GMT
On Wed, 11 Apr 2001, William A. Rowe, Jr. wrote:

> Oh buckets macro designer, is this is what we expected?
>
> apr-util\buckets\apr_buckets_socket.c(142) : warning C4702: unreachable code
> ...

Not exactly.  I've never seen a compiler complain about this macro before.

To save the others a little homework, it's complaining about
apr_bucket_do_create(), which is a macro that looks like this:

    do {                                        \
        apr_bucket *b, *ap__b;                  \
        b = calloc(1, sizeof(*b));              \
        if (b == NULL) {                        \
            return NULL;                        \
        }                                       \
        ap__b = do_make;                        \
        if (ap__b == NULL) {                    \
            free(b);                            \
            return NULL;                        \
        }                                       \
        APR_RING_ELEM_INIT(ap__b, link);        \
        return ap__b;                           \
    } while(0)

The only "unreachable code" that I see is the while(0), which is supposed
to get compiled away anyhow.  do {} while(0) is the preferred way to do
multiline macros (to allow the macro user to place a semicolon after the
macro invocation without causing a syntax error), so I'll agree with
Ryan: it's a bug in your compiler.

--Cliff


--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA




Mime
View raw message