* [PATCH] nbd/server: improve nbd_negotiate_send_rep_list
@ 2019-12-26 8:15 Vladimir Sementsov-Ogievskiy
2020-01-07 22:01 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-12-26 8:15 UTC (permalink / raw)
To: qemu-block; +Cc: vsementsov, qemu-devel
Don't try to write zero-lenght strings.
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) {
+ error_prepend(errp, "write failed (name buffer): ");
+ return -EINVAL;
+ }
}
- if (nbd_write(ioc, desc, desc_len, errp) < 0) {
- error_prepend(errp, "write failed (description buffer): ");
- return -EINVAL;
+ if (desc_len > 0) {
+ if (nbd_write(ioc, desc, desc_len, errp) < 0) {
+ error_prepend(errp, "write failed (description buffer): ");
+ return -EINVAL;
+ }
}
return 0;
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd/server: improve nbd_negotiate_send_rep_list
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
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2020-01-07 22:01 UTC (permalink / raw)
To: Vladimir Sementsov-Ogievskiy, qemu-block; +Cc: qemu-devel
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 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd/server: improve nbd_negotiate_send_rep_list
2020-01-07 22:01 ` Eric Blake
@ 2020-01-09 11:28 ` Vladimir Sementsov-Ogievskiy
0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2020-01-09 11:28 UTC (permalink / raw)
To: Eric Blake, qemu-block; +Cc: qemu-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-09 11:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.