Warning implies possible kerberos bug in krb5int_dns_nextans() in dnsglue.c

Russ Allbery rra at stanford.edu
Tue Mar 18 12:58:30 EDT 2008

Jeffrey Hutzelman <jhutz at cmu.edu> writes:

> Hrm.  Indeed, an explicit cast to a smaller type does not seem to
> generate a warning, in at least one compiler I tried.

It would surprise me if it did, given that that's a common idiom for doing
weird things like byte-swapping numbers.

> I believe it would be possible to work something out by taking advantage
> of implicit promotion of function call arguments, or even just
> eliminating the constant-ness of the second argument.  For example:
> int too_big(unsigned int arg) { return arg > INT_MAX; }
> int greater(unsigned short x, unsigned int y) { return x > y; }
> However, I'm not convinced it's worth the ugliness.

You can also wrap the whole block in an expression like:

    if (sizeof(short) == sizeof(int)) {
        /* ... */

and the compiler will kill it as dead code if it doesn't apply.  That's
probably the cleanest solution.

Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

More information about the krbdev mailing list