Re: A C language question

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

 



> Sorry, I don't know if it is appropriate to ask such question here.
>
> (((*((__u32 *)&((__sk)->dport)))== (__ports))
>

> In above code, what is difference if I replace ( * ( (__u32 *)
> &((__sk)->dport) ) )

refer a __u32 (sizeof(__u32)   bytes) starting from address   &__sk->dport

> with ((__u32)(__sk->dport))

read __sk->dport (sizeof __sk->dport  bytes starting from address
&__sk->dport) and convert the value read to a __u32 value.

If sizeof (__u32) is 4
and sizeof __sk->dport is 2
and 4 bytes starting from &__sk->dport are 0x01  0x01  0x01 0x01

then

then value of ( * ( (__u32 *) &((__sk)->dport) ) ) is 0x01010101

while the value of ((__u32)(__sk->dport)) is 0x00000101

Sourav

>
> Thanks.
>
> Haiguang
>
>


-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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