All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH] nbd/server: improve nbd_negotiate_send_rep_list
Date: Thu, 9 Jan 2020 11:28:51 +0000	[thread overview]
Message-ID: <b20e8507-8fe3-3cd8-c144-18819936f738@virtuozzo.com> (raw)
In-Reply-To: <22eee419-ba2e-512a-568d-e8bd348f592a@redhat.com>

08.01.2020 1:01, Eric Blake wrote:
> 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 <vsementsov@virtuozzo.com>
>> ---
>>   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

I looked through the code and it seems for me that nobody does this check,
so it would not be a no-op, at least it would be extra syscall..

> for a zero length write, at which point this is a micro-optimization (fewer CPU cycles, but no semantic change).
> 



-- 
Best regards,
Vladimir


      reply	other threads:[~2020-01-09 11:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26  8:15 [PATCH] nbd/server: improve nbd_negotiate_send_rep_list Vladimir Sementsov-Ogievskiy
2020-01-07 22:01 ` Eric Blake
2020-01-09 11:28   ` Vladimir Sementsov-Ogievskiy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b20e8507-8fe3-3cd8-c144-18819936f738@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.