]> Git Repo - qemu.git/commit - nbd/client.c
nbd/client: Drop pointless buf variable
authorEric Blake <[email protected]>
Sat, 15 Dec 2018 13:53:10 +0000 (07:53 -0600)
committerEric Blake <[email protected]>
Sat, 5 Jan 2019 13:53:22 +0000 (07:53 -0600)
commitef2e35fcc8e14bcc9366df5fdf53f65d679f8dca
tree9566fc73deb06530ce8ef5207748ea2ba3c40f82
parent3c1fa35d74aabe9c3ab642d2591b087e53d7a616
nbd/client: Drop pointless buf variable

There's no need to read into a temporary buffer (oversized
since commit 7d3123e1) followed by a byteswap into a uint64_t
to check for a magic number via memcmp(), when the code
immediately below demonstrates reading into the uint64_t then
byteswapping in place and checking for a magic number via
integer math.  What's more, having a different error message
when the server's first reply byte is 0 is unusual - it's no
different from any other wrong magic number, and we already
detected short reads. That whole strlen() issue has been
present and useless since commit 1d45f8b5 in 2010; perhaps it
was leftover debugging (since the correct magic number happens
to be ASCII)?  Make the error messages more consistent and
detailed while touching things.

Signed-off-by: Eric Blake <[email protected]>
Reviewed-by: Richard W.M. Jones <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <20181215135324[email protected]>
nbd/client.c
nbd/nbd-internal.h
This page took 0.023705 seconds and 4 git commands to generate.