diff mbox

[v2,14/17] net/dp8393x: correctly reset in_use field

Message ID 1432729200-5322-15-git-send-email-hpoussin@reactos.org
State New
Headers show

Commit Message

Hervé Poussineau May 27, 2015, 12:19 p.m. UTC
Don't write more than the field width, which is always 16 bit.
Fixes network in NetBSD 5.1/arc

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/net/dp8393x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Aurelien Jarno June 2, 2015, 11:04 a.m. UTC | #1
On 2015-05-27 14:19, Hervé Poussineau wrote:
> Don't write more than the field width, which is always 16 bit.
> Fixes network in NetBSD 5.1/arc
> 
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
>  hw/net/dp8393x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
> index 4184045..b72b0b1 100644
> --- a/hw/net/dp8393x.c
> +++ b/hw/net/dp8393x.c
> @@ -761,10 +761,10 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
>          /* EOL detected */
>          s->regs[SONIC_ISR] |= SONIC_ISR_RDE;
>      } else {
> -        data[0 * width] = 0; /* in_use */
> +        uint16_t in_use = 0;
>          address_space_rw(&s->as,
>              ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof(uint16_t) * 6 * width,
> -            MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 1);
> +            MEMTXATTRS_UNSPECIFIED, (uint8_t *)&in_use, sizeof(uint16_t), 1);

Why not initialising both data[0] and data[1] to 0 and a fixed size of 2
bytes instead of using a new variable?

>          s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA];
>          s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
>          s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);

That said:
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Hervé Poussineau June 2, 2015, 6:05 p.m. UTC | #2
Le 02/06/2015 13:04, Aurelien Jarno a écrit :
> On 2015-05-27 14:19, Hervé Poussineau wrote:
>> Don't write more than the field width, which is always 16 bit.
>> Fixes network in NetBSD 5.1/arc
>>
>> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
>> ---
>>   hw/net/dp8393x.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
>> index 4184045..b72b0b1 100644
>> --- a/hw/net/dp8393x.c
>> +++ b/hw/net/dp8393x.c
>> @@ -761,10 +761,10 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
>>           /* EOL detected */
>>           s->regs[SONIC_ISR] |= SONIC_ISR_RDE;
>>       } else {
>> -        data[0 * width] = 0; /* in_use */
>> +        uint16_t in_use = 0;
>>           address_space_rw(&s->as,
>>               ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof(uint16_t) * 6 * width,
>> -            MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 1);
>> +            MEMTXATTRS_UNSPECIFIED, (uint8_t *)&in_use, sizeof(uint16_t), 1);
>
> Why not initialising both data[0] and data[1] to 0 and a fixed size of 2
> bytes instead of using a new variable?

I'll do that if a v3 is required.

>
>>           s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA];
>>           s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
>>           s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);
>
> That said:
> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
>

Hervé
diff mbox

Patch

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 4184045..b72b0b1 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -761,10 +761,10 @@  static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
         /* EOL detected */
         s->regs[SONIC_ISR] |= SONIC_ISR_RDE;
     } else {
-        data[0 * width] = 0; /* in_use */
+        uint16_t in_use = 0;
         address_space_rw(&s->as,
             ((s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]) + sizeof(uint16_t) * 6 * width,
-            MEMTXATTRS_UNSPECIFIED, (uint8_t *)data, size, 1);
+            MEMTXATTRS_UNSPECIFIED, (uint8_t *)&in_use, sizeof(uint16_t), 1);
         s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA];
         s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
         s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff);