Andres Salomon <[EMAIL PROTECTED]> wrote: > Package: libc6-dev > Version: 2.3.2.ds1-12 > Severity: normal > > I'm seeing some very odd behavior with dev_t (defined in linux/kdev_t.h) > and varargs. I have the following source file: > > #include <stdio.h> > #include <sys/types.h> > #include <linux/kdev_t.h> > > > int main(void) > { > dev_t x = 0x3af; > printf("%x %x\n", ((x)>>8), ((x)&0xff)); > return 0; > } > > > One would think that this would print out "3 af"; however, it displays > "3 0". If I change that printf to: > printf("%x %x %x\n", ((x)>>8), ((x)&0xff));
Please review the C promotion rules. The 2nd and 3rd arguments are 64-bits long, and therefore they get pushed onto the stack as 64-bit values. Your use of the %x conversion is therefore incorrect. In fact, gcc -Wall should've told you about it. -- Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt