qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] nbd/server: improve nbd_negotiate_send_rep_list


From: Eric Blake
Subject: Re: [PATCH] nbd/server: improve nbd_negotiate_send_rep_list
Date: Tue, 7 Jan 2020 16:01:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1

On 12/26/19 2:15 AM, Vladimir Sementsov-Ogievskiy wrote:
Don't try to write zero-lenght strings.

length


Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
  nbd/server.c | 16 ++++++++++------
  1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 24ebc1a805..28a915f5a2 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -392,14 +392,18 @@ static int nbd_negotiate_send_rep_list(NBDClient *client, 
NBDExport *exp,
          return -EINVAL;
      }
- if (nbd_write(ioc, name, name_len, errp) < 0) {
-        error_prepend(errp, "write failed (name buffer): ");
-        return -EINVAL;
+    if (name_len > 0) {
+        if (nbd_write(ioc, name, name_len, errp) < 0) {

What's the rationale for this change? nbd_write() should be a no-op for a zero length write, at which point this is a micro-optimization (fewer CPU cycles, but no semantic change).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]