On Wed, 19 Sep 2007 15:07:55 -0700 (PDT)
David Miller <[EMAIL PROTECTED]> wrote:

> From: Stephen Hemminger <[EMAIL PROTECTED]>
> Date: Wed, 19 Sep 2007 14:59:00 -0700
> 

...

> > > +static int niu_wait_bits_clear_mac(struct niu *np, unsigned long reg, 
> > > u64 bits,
> > > +                            int limit, int delay)
> > > +{
> > > + BUILD_BUG_ON(limit <= 0 || delay < 0);
> > 
> > There is no way compiler can evaluate limit or delay.
> 
> Check the callers, they all pass contant values.

GCC is not as smart as you think... Try the following test:
--------------------
#include <stdio.h>

#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#define ENODEV -10

static int niu_wait_bits_clear_mac(void *np, unsigned long reg,
                                   int limit, int delay)
{
        BUILD_BUG_ON(limit <= 0 || delay < 0);

        if (limit < 0)
                return -ENODEV;
        while (limit > 0)
                sleep(delay);
        
        return 0;
}

int main(int argc, char **argv) {
        printf("start\n");
        niu_wait_bits_clear_mac(NULL, 0, 10, 1);

        niu_wait_bits_clear_mac(NULL, 0, -1, 0);
        
        niu_wait_bits_clear_mac(NULL, 0, 0, -1);
        return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to