[yess@xxxxxxxxxxx: Re: Wrong operators for the binary.]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




--- Begin Message ---
On Tue, Dec 03, 2002 at 01:00:39PM -0800, Jose Luis Alarcon wrote:
> --- Tadeusz Andrzej Kad?ubowski <yess@hell.org.pl> wrote:
> >On Tue, Dec 03, 2002 at 11:52:03AM -0800, Jose Luis Alarcon wrote:
> >>   Hi all.
> >> 
> >>   I am trying compile a module that contains this line:
> >> 
> >>      printk("Device: %d.%d\n", inode->i_rdev >> 8, inode->i_rdev & 0xFF);
> >> 
> >> and the result is that gcc 3.2.1 says that '>>' and '&' are wrong operators for
> >> the binary. Why?
> >
> >My guess:
> >i_rdev in inode structure is of type kdev_t, which is defined in
> >include/linux/kdev_t.h and contains one member - unsigned short value. Maybe
> >try shifting/bitwise anding not on the structure, but on that particular member
> >of the structure.
> >Then if inode is a pointer to the inode struct, then it would be something
> >like:
> >
> >printk("Device: %d.%d\n", (inode->i_rdev).value >> 8, (inode->i_rdev) & 0xff);
> >
> >This guess obviously may occur wrong. Please tell, if it worked.
> >-- 
> >tadeusz a. kadlubowski
> >
> 
>   Hi Tadeusz, and thanks for your answer.
> 
>   Your proposed line:
> 
>    printk("Device: %d.%d\n", (inode->i_rdev).value >> 8, (inode->i_rdev) & 0xff);
> 
> gets solve the problem for '>>' but not for '&'. I paste here down the output:
> 
> chardev.c:91: wrong operators for the binary &
> 
>   Why gcc think that & is a binary?. I suppose Ori Pomerantz use '>>' and '&' like
> bits level operators.
> 


Blah!
It's my mistake. I meant changing inode->i_rdev to (inode->i_rdev).value in
both cases, not in just first one. I feel embarassed.
Gcc thinks & is binary because it *is* binary. That word simply tells that &
operates on bits.

I also have one more idea about your code - I actually don't know the code in
which this printk works, but I feel, that both numbers are unsigned. If I'm
right, change the both %d's into %u - which is the proper format of unsigned
decimal. %d means signed decimal. If it is the case, changing the format would
fix one compile-time warning.

Good luck,
-- 
tadeusz a. kadlubowski
--- End Message ---

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux