diff mbox

[2/8] hw/net/cadence_gem: Remove dead code

Message ID 1399574818-19349-3-git-send-email-peter.maydell@linaro.org
State New
Headers show

Commit Message

Peter Maydell May 8, 2014, 6:46 p.m. UTC
Commit 191946c moved the code to handle padding to minimum
length from after the handling of the CRC to before it.
This means that the CRC code doesn't need to cope with the
possibility that the size is less than 60; remove this
dead code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/net/cadence_gem.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Peter Crosthwaite May 9, 2014, 10:50 p.m. UTC | #1
On Fri, May 9, 2014 at 4:46 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Commit 191946c moved the code to handle padding to minimum
> length from after the handling of the CRC to before it.
> This means that the CRC code doesn't need to cope with the
> possibility that the size is less than 60; remove this
> dead code.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

> ---
>  hw/net/cadence_gem.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index cdb1825..afddc8a 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -717,7 +717,6 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
>          rxbuf_ptr = (void *)buf;
>      } else {
>          unsigned crc_val;
> -        int      crc_offset;
>
>          /* The application wants the FCS field, which QEMU does not provide.
>           * We must try and caclculate one.
> @@ -727,12 +726,7 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
>          memset(rxbuf + size, 0, sizeof(rxbuf) - size);
>          rxbuf_ptr = rxbuf;
>          crc_val = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60)));
> -        if (size < 60) {
> -            crc_offset = 60;
> -        } else {
> -            crc_offset = size;
> -        }
> -        memcpy(rxbuf + crc_offset, &crc_val, sizeof(crc_val));
> +        memcpy(rxbuf + size, &crc_val, sizeof(crc_val));
>
>          bytes_to_copy += 4;
>          size += 4;
> --
> 1.9.2
>
>
diff mbox

Patch

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index cdb1825..afddc8a 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -717,7 +717,6 @@  static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         rxbuf_ptr = (void *)buf;
     } else {
         unsigned crc_val;
-        int      crc_offset;
 
         /* The application wants the FCS field, which QEMU does not provide.
          * We must try and caclculate one.
@@ -727,12 +726,7 @@  static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         memset(rxbuf + size, 0, sizeof(rxbuf) - size);
         rxbuf_ptr = rxbuf;
         crc_val = cpu_to_le32(crc32(0, rxbuf, MAX(size, 60)));
-        if (size < 60) {
-            crc_offset = 60;
-        } else {
-            crc_offset = size;
-        }
-        memcpy(rxbuf + crc_offset, &crc_val, sizeof(crc_val));
+        memcpy(rxbuf + size, &crc_val, sizeof(crc_val));
 
         bytes_to_copy += 4;
         size += 4;