diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-01-21 12:34:16 +1100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-01-29 17:10:40 +1100 |
commit | dc0ecd1477fcabd247b17c99c9558cae40daa04b (patch) | |
tree | 8d22ee2fd0e6892ccf2aa812143fea0a5ea40beb /clients | |
parent | f344ef9b22390816966149a9892fcebcfa42f704 (diff) | |
download | SLOF-dc0ecd1477fcabd247b17c99c9558cae40daa04b.zip SLOF-dc0ecd1477fcabd247b17c99c9558cae40daa04b.tar.gz SLOF-dc0ecd1477fcabd247b17c99c9558cae40daa04b.tar.bz2 |
ethernet: Fix gcc warnings
This fixes gcc warnings but unlike other places, this does not change
the type of bytes_received as recv() may return a negative value;
instead this adds:
1) casting to size_t when comparing the size;
2) an additional check for a negative value returned from recv().
The make command used to test:
make qemu WARNFLAGS=-Wextra
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'clients')
-rw-r--r-- | clients/net-snk/app/netlib/ethernet.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clients/net-snk/app/netlib/ethernet.c b/clients/net-snk/app/netlib/ethernet.c index c24d64f..1e03a0b 100644 --- a/clients/net-snk/app/netlib/ethernet.c +++ b/clients/net-snk/app/netlib/ethernet.c @@ -117,7 +117,10 @@ int32_t receive_ether(int fd) if (!bytes_received) // No messages return 0; - if (bytes_received < sizeof(struct ethhdr)) + if (bytes_received < 0) + return -1; /* recv() failed */ + + if ((size_t) bytes_received < sizeof(struct ethhdr)) return -1; // packet is too small ethh = (struct ethhdr *) ether_packet; |