* [patch] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 6:17 ` Dan Carpenter
0 siblings, 0 replies; 11+ messages in thread
From: Dan Carpenter @ 2011-11-21 6:17 UTC (permalink / raw)
To: Sjur Braendeland; +Cc: David S. Miller, netdev, kernel-janitors
The "tmp" variable here is used to store the result of cpu_to_le16()
so it should be a u16 instead of an int. We want the high bits set
and the current code works on little endian systems but not on big
endian systems.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is a static checker thing. I haven't tested it. Please review
carefully.
diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c
index f399211..2b46c48 100644
--- a/net/caif/cffrml.c
+++ b/net/caif/cffrml.c
@@ -136,10 +136,11 @@ static int cffrml_receive(struct cflayer *layr, struct cfpkt *pkt)
static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
{
- int tmp;
+ u16 tmp;
u16 chks;
u16 len;
struct cffrml *this = container_obj(layr);
+
if (this->dofcs) {
chks = cfpkt_iterate(pkt, cffrml_checksum, 0xffff);
tmp = cpu_to_le16(chks);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [patch] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 6:17 ` Dan Carpenter
0 siblings, 0 replies; 11+ messages in thread
From: Dan Carpenter @ 2011-11-21 6:17 UTC (permalink / raw)
To: Sjur Braendeland; +Cc: David S. Miller, netdev, kernel-janitors
The "tmp" variable here is used to store the result of cpu_to_le16()
so it should be a u16 instead of an int. We want the high bits set
and the current code works on little endian systems but not on big
endian systems.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is a static checker thing. I haven't tested it. Please review
carefully.
diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c
index f399211..2b46c48 100644
--- a/net/caif/cffrml.c
+++ b/net/caif/cffrml.c
@@ -136,10 +136,11 @@ static int cffrml_receive(struct cflayer *layr, struct cfpkt *pkt)
static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
{
- int tmp;
+ u16 tmp;
u16 chks;
u16 len;
struct cffrml *this = container_obj(layr);
+
if (this->dofcs) {
chks = cfpkt_iterate(pkt, cffrml_checksum, 0xffff);
tmp = cpu_to_le16(chks);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [patch] caif: fix endian conversion in cffrml_transmit()
2011-11-21 6:17 ` Dan Carpenter
(?)
@ 2011-11-21 6:33 ` Al Viro
2011-11-21 19:50 ` Dan Carpenter
-1 siblings, 1 reply; 11+ messages in thread
From: Al Viro @ 2011-11-21 6:33 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Sjur Braendeland, David S. Miller, netdev, kernel-janitors
On Mon, Nov 21, 2011 at 09:17:22AM +0300, Dan Carpenter wrote:
> The "tmp" variable here is used to store the result of cpu_to_le16()
> so it should be a u16 instead of an int. We want the high bits set
> and the current code works on little endian systems but not on big
> endian systems.
Charming... On b-e we end up feeding zeroes instead of the value we want.
However, that u16 clearly ought to be __le16 - it's there for purpose.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [patch] caif: fix endian conversion in cffrml_transmit()
2011-11-21 6:17 ` Dan Carpenter
@ 2011-11-21 14:36 ` Sjur BRENDELAND
-1 siblings, 0 replies; 11+ messages in thread
From: Sjur BRENDELAND @ 2011-11-21 14:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David S. Miller, netdev, kernel-janitors
Hi Dan,
> The "tmp" variable here is used to store the result of cpu_to_le16()
> so it should be a u16 instead of an int. We want the high bits set
> and the current code works on little endian systems but not on big
> endian systems.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Looks OK by me, unless you want to make sparse with __CHECK_ENDIAN__
shut up, then you should use __le16 ;-)
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Regards,
Sjur
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [patch] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 14:36 ` Sjur BRENDELAND
0 siblings, 0 replies; 11+ messages in thread
From: Sjur BRENDELAND @ 2011-11-21 14:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David S. Miller, netdev, kernel-janitors
Hi Dan,
> The "tmp" variable here is used to store the result of cpu_to_le16()
> so it should be a u16 instead of an int. We want the high bits set
> and the current code works on little endian systems but not on big
> endian systems.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Looks OK by me, unless you want to make sparse with __CHECK_ENDIAN__
shut up, then you should use __le16 ;-)
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Regards,
Sjur
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [patch v2] caif: fix endian conversion in cffrml_transmit()
2011-11-21 6:33 ` Al Viro
@ 2011-11-21 19:50 ` Dan Carpenter
0 siblings, 0 replies; 11+ messages in thread
From: Dan Carpenter @ 2011-11-21 19:50 UTC (permalink / raw)
To: Al Viro; +Cc: Sjur Braendeland, David S. Miller, netdev, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
The "tmp" variable here is used to store the result of cpu_to_le16()
so it should be an __le16 instead of an int. We want the high bits
set and the current code works on little endian systems but not on
big endian systems.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: In v1 I used a u16 instead of an __le16. Also I've changed the
name to "data" instead of "tmp".
diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c
index f399211..d3ca87b 100644
--- a/net/caif/cffrml.c
+++ b/net/caif/cffrml.c
@@ -136,20 +136,21 @@ static int cffrml_receive(struct cflayer *layr, struct cfpkt *pkt)
static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
{
- int tmp;
u16 chks;
u16 len;
+ __le16 data;
+
struct cffrml *this = container_obj(layr);
if (this->dofcs) {
chks = cfpkt_iterate(pkt, cffrml_checksum, 0xffff);
- tmp = cpu_to_le16(chks);
- cfpkt_add_trail(pkt, &tmp, 2);
+ data = cpu_to_le16(chks);
+ cfpkt_add_trail(pkt, &data, 2);
} else {
cfpkt_pad_trail(pkt, 2);
}
len = cfpkt_getlen(pkt);
- tmp = cpu_to_le16(len);
- cfpkt_add_head(pkt, &tmp, 2);
+ data = cpu_to_le16(len);
+ cfpkt_add_head(pkt, &data, 2);
cfpkt_info(pkt)->hdr_len += 2;
if (cfpkt_erroneous(pkt)) {
pr_err("Packet is erroneous!\n");
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [patch v2] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 19:50 ` Dan Carpenter
0 siblings, 0 replies; 11+ messages in thread
From: Dan Carpenter @ 2011-11-21 19:50 UTC (permalink / raw)
To: Al Viro; +Cc: Sjur Braendeland, David S. Miller, netdev, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
The "tmp" variable here is used to store the result of cpu_to_le16()
so it should be an __le16 instead of an int. We want the high bits
set and the current code works on little endian systems but not on
big endian systems.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: In v1 I used a u16 instead of an __le16. Also I've changed the
name to "data" instead of "tmp".
diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c
index f399211..d3ca87b 100644
--- a/net/caif/cffrml.c
+++ b/net/caif/cffrml.c
@@ -136,20 +136,21 @@ static int cffrml_receive(struct cflayer *layr, struct cfpkt *pkt)
static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
{
- int tmp;
u16 chks;
u16 len;
+ __le16 data;
+
struct cffrml *this = container_obj(layr);
if (this->dofcs) {
chks = cfpkt_iterate(pkt, cffrml_checksum, 0xffff);
- tmp = cpu_to_le16(chks);
- cfpkt_add_trail(pkt, &tmp, 2);
+ data = cpu_to_le16(chks);
+ cfpkt_add_trail(pkt, &data, 2);
} else {
cfpkt_pad_trail(pkt, 2);
}
len = cfpkt_getlen(pkt);
- tmp = cpu_to_le16(len);
- cfpkt_add_head(pkt, &tmp, 2);
+ data = cpu_to_le16(len);
+ cfpkt_add_head(pkt, &data, 2);
cfpkt_info(pkt)->hdr_len += 2;
if (cfpkt_erroneous(pkt)) {
pr_err("Packet is erroneous!\n");
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [patch v2] caif: fix endian conversion in cffrml_transmit()
2011-11-21 19:50 ` Dan Carpenter
@ 2011-11-21 21:20 ` Sjur Brændeland
-1 siblings, 0 replies; 11+ messages in thread
From: Sjur Brændeland @ 2011-11-21 21:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Al Viro, David S. Miller, netdev, kernel-janitors
> The "tmp" variable here is used to store the result of cpu_to_le16()
> so it should be an __le16 instead of an int. We want the high bits
> set and the current code works on little endian systems but not on
> big endian systems.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: In v1 I used a u16 instead of an __le16. Also I've changed the
> name to "data" instead of "tmp".
Thanks Dan, good catch - this would have failed badly on a b_e architecture.
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Regards,
Sjur
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch v2] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 21:20 ` Sjur Brændeland
0 siblings, 0 replies; 11+ messages in thread
From: Sjur Brændeland @ 2011-11-21 21:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Al Viro, David S. Miller, netdev, kernel-janitors
> The "tmp" variable here is used to store the result of cpu_to_le16()
> so it should be an __le16 instead of an int. We want the high bits
> set and the current code works on little endian systems but not on
> big endian systems.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: In v1 I used a u16 instead of an __le16. Also I've changed the
> name to "data" instead of "tmp".
Thanks Dan, good catch - this would have failed badly on a b_e architecture.
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Regards,
Sjur
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch v2] caif: fix endian conversion in cffrml_transmit()
2011-11-21 21:20 ` Sjur Brændeland
@ 2011-11-21 21:46 ` David Miller
-1 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2011-11-21 21:46 UTC (permalink / raw)
To: sjurbren; +Cc: dan.carpenter, viro, netdev, kernel-janitors
From: Sjur Brændeland <sjurbren@gmail.com>
Date: Mon, 21 Nov 2011 22:20:09 +0100
>> The "tmp" variable here is used to store the result of cpu_to_le16()
>> so it should be an __le16 instead of an int. We want the high bits
>> set and the current code works on little endian systems but not on
>> big endian systems.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> v2: In v1 I used a u16 instead of an __le16. Also I've changed the
>> name to "data" instead of "tmp".
>
> Thanks Dan, good catch - this would have failed badly on a b_e architecture.
>
> Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Applied, thanks guys.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch v2] caif: fix endian conversion in cffrml_transmit()
@ 2011-11-21 21:46 ` David Miller
0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2011-11-21 21:46 UTC (permalink / raw)
To: sjurbren; +Cc: dan.carpenter, viro, netdev, kernel-janitors
From: Sjur Brændeland <sjurbren@gmail.com>
Date: Mon, 21 Nov 2011 22:20:09 +0100
>> The "tmp" variable here is used to store the result of cpu_to_le16()
>> so it should be an __le16 instead of an int. We want the high bits
>> set and the current code works on little endian systems but not on
>> big endian systems.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>> v2: In v1 I used a u16 instead of an __le16. Also I've changed the
>> name to "data" instead of "tmp".
>
> Thanks Dan, good catch - this would have failed badly on a b_e architecture.
>
> Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Applied, thanks guys.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-11-21 21:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 6:17 [patch] caif: fix endian conversion in cffrml_transmit() Dan Carpenter
2011-11-21 6:17 ` Dan Carpenter
2011-11-21 6:33 ` Al Viro
2011-11-21 19:50 ` [patch v2] " Dan Carpenter
2011-11-21 19:50 ` Dan Carpenter
2011-11-21 21:20 ` Sjur Brændeland
2011-11-21 21:20 ` Sjur Brændeland
2011-11-21 21:46 ` David Miller
2011-11-21 21:46 ` David Miller
2011-11-21 14:36 ` [patch] " Sjur BRENDELAND
2011-11-21 14:36 ` Sjur BRENDELAND
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.