apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <ad...@rowe-clan.net>
Subject Re: Buckets code question
Date Wed, 11 Apr 2001 14:51:17 GMT

----- Original Message ----- 
From: <rbb@covalent.net>
To: "William A. Rowe, Jr." <wrowe@rowe-clan.net>
Cc: <dev@apr.apache.org>
Sent: Wednesday, April 11, 2001 9:32 AM
Subject: Re: Buckets code question


> On Wed, 11 Apr 2001, William A. Rowe, Jr. wrote:
> 
> > Have finished win32 vc5's equivilant of -wall (/W4) ... found many patches to
> > apply shortly (some my own oversights), but here's one odd one I discovered.
> >
> > Oh buckets macro designer, is this is what we expected?
> >
> > apr-util\buckets\apr_buckets_socket.c(142) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_simple.c(115) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_simple.c(149) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_pool.c(159) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_pipe.c(147) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_mmap.c(111) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_heap.c(120) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_flush.c(84) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_file.c(195) : warning C4702: unreachable code
> > apr-util\buckets\apr_buckets_eos.c(84) : warning C4702: unreachable code
> >
> > Hopefully :-)
> 
> That looks like a bug in the compiler.  That code is definately reachable.

APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p)
{
    apr_bucket_do_create(apr_bucket_socket_make(b, p));
}
---expands to---
APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p)
{
    do {     
        apr_bucket *b, *ap__b;   
        b = calloc(1, sizeof(*b));  
        if (b == NULL) {   
            return NULL;   
        }     
        ap__b = apr_bucket_socket_make(b, p);   
        if (ap__b == NULL) {   
            free(b);    
            return NULL;   
        }     
        APR_RING_ELEM_INIT(ap__b, link); 
        return ap__b;    
    } while(0);
}
---expands to---
APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p)
{
    do {     
        apr_bucket *b, *ap__b;   
        b = calloc(1, sizeof(*b));  
        if (b == NULL) {   
            return NULL;   
        }     
        ap__b = apr_bucket_socket_make(b, p);   
        if (ap__b == NULL) {   
            free(b);    
            return NULL;   
        }
        do {    
            ((ap__b))->link.next = (ap__b);    
            ((ap__b))->link.prev = (ap__b);    
        } while (0);
        return ap__b;    
    } while(0);
}

So the final While(0); is definately unreachable.  No compiler error.

My only question, why do {} while(0); rather than {} ?

Bill


Mime
View raw message