On 1/4/07, David Miller <[EMAIL PROTECTED]> wrote:
From: "Paul Moore" <[EMAIL PROTECTED]>
Date: Thu, 04 Jan 2007 15:04:31 -0500
> From: Paul Moore <[EMAIL PROTECTED]>
>
> The inet_create() and inet6_create() functions incorrectly set the
> inet_sock->is_icsk field. Both functions assume that the is_icsk field is
> large enough to hold at least a INET_PROTOSW_ICSK value when it is actually
> only a single bit. This patch corrects the assignment by doing a boolean
> comparison whose result will safely fit into a single bit field.
>
> Signed-off-by: Paul Moore <[EMAIL PROTECTED]>
Applied, thanks a lot Paul.
Well spotted, gcc let me down on this one:
[EMAIL PROTECTED] ~]$ cat a.c
#include <stdio.h>
struct foo { int a_bit:1; };
int main(void) {
int trickme = 0x04;
struct foo oof;
oof.a_bit = trickme & 4;
printf("%u\n", oof.a_bit);
}
[EMAIL PROTECTED] ~]$ make a
cc a.c -o a
[EMAIL PROTECTED] ~]$ ./a
0
[EMAIL PROTECTED] ~]$
But...
[EMAIL PROTECTED] ~]$ cat a.c
#include <stdio.h>
struct foo { int a_bit:1; };
int main(void) {
struct foo oof;
oof.a_bit = 0x04;
printf("%u\n", oof.a_bit);
}
[EMAIL PROTECTED] ~]$ make a
cc a.c -o a
a.c: In function 'main':
a.c:8: warning: overflow in implicit constant conversion
[EMAIL PROTECTED] ~]$
I expected a warning since the and operation clearly could yield a
value that would overflow, just like in the constant case...
Anyway, thanks a lot Paul!
- Arnaldo
-
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