From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, jdurgin@redhat.com,
jcody@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH for-2.9 3/5] rbd: Rewrite the code to extract list-valued options
Date: Thu, 23 Mar 2017 14:18:03 -0500 [thread overview]
Message-ID: <385d2fa4-a7ec-e22c-e89d-5387cccc2ca4@redhat.com> (raw)
In-Reply-To: <878tnv6e6q.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 2504 bytes --]
On 03/23/2017 01:27 PM, Markus Armbruster wrote:
>>> -
>>> - num_entries = qdict_array_entries(options, prefix);
>>> + for (i = 0;; i++) {
>>> + sprintf(keybuf, "auth-supported.%d.auth", i);
>>
>> By my count, and including a trailing NUL, this is 21 bytes + the
>> maximum size of a formatted int to fit in keybuf[32]; 32-bit INT_MIN is
>> indeed 11 bytes. Cutting it close there, but I don't see an overflow
>> (if gcc 7's new -Wformat-truncation spots something, then gcc is too
>> strict.)
>
> 11 decimal digits take a hell of a list :)
>
> Could double the buffer if it makes anyone sleep better.
I'm okay with its current size.
>>> - value = host;
>>> - if (port) {
>>> - /* check for ipv6 */
>>> - if (strchr(host, ':')) {
>>> - strbuf = g_strdup_printf("[%s]:%s", host, port);
>>> - } else {
>>> - strbuf = g_strdup_printf("%s:%s", host, port);
>>
>> The old code only prints port information if it is present...
>>
>>> + host = qstring_get_str(qobject_to_qstring(val));
>>> + sprintf(keybuf, "server.%d.port", i);
>>> + port = qdict_get_str(options, keybuf);
>>>
>>> -
>>> - /* each iteration in the for loop will build upon the string, and if
>>> - * rados_str is NULL then it is our first pass */
>>> - if (rados_str) {
>>> - /* separate options with ';', as that is what rados_conf_set()
>>> - * requires */
>>> - rados_str_tmp = rados_str;
>>> - rados_str = g_strdup_printf("%s;%s", rados_str_tmp, value);
>>> - g_free(rados_str_tmp);
>>> + if (strchr(host, ':')) {
>>> + vals[i] = g_strdup_printf("[%s]:%s", host, port);
>>> } else {
>>> - rados_str = g_strdup(value);
>>> + vals[i] = g_strdup_printf("%s:%s", host, port);
>>
>> ...but the new code unconditionally prints port information, even when
>> port == NULL. Oops.
>
> How can port be null? SocketAddress member port is mandatory...
Indeed. Does that mean the old code had a dead branch? Looks like it!
So, if I'm not overlooking something, that means you've resolved all my
open questions, and can submit the patch as written with:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2017-03-23 19:18 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 10:55 [Qemu-devel] [PATCH for-2.9 0/5] rbd: Clean up API and code Markus Armbruster
2017-03-23 10:55 ` [Qemu-devel] [PATCH for-2.9 1/5] rbd: Clean up runtime_opts Markus Armbruster
2017-03-23 14:03 ` Eric Blake
2017-03-23 20:49 ` Kevin Wolf
2017-03-23 10:55 ` [Qemu-devel] [PATCH for-2.9 2/5] rbd: Clean up qemu_rbd_create()'s detour through QemuOpts Markus Armbruster
2017-03-23 14:47 ` Eric Blake
2017-03-23 20:50 ` Kevin Wolf
2017-03-23 10:55 ` [Qemu-devel] [PATCH for-2.9 3/5] rbd: Rewrite the code to extract list-valued options Markus Armbruster
2017-03-23 17:39 ` Eric Blake
2017-03-23 18:27 ` Markus Armbruster
2017-03-23 19:18 ` Eric Blake [this message]
2017-03-23 20:51 ` Eric Blake
2017-03-24 6:36 ` Markus Armbruster
2017-03-23 20:38 ` Kevin Wolf
2017-03-24 6:40 ` Markus Armbruster
2017-03-24 8:25 ` Markus Armbruster
2017-03-24 13:31 ` Eric Blake
2017-03-24 16:44 ` Kevin Wolf
2017-03-23 10:55 ` [Qemu-devel] [PATCH for-2.9 4/5] rbd: Peel off redundant RbdAuthMethod wrapper struct Markus Armbruster
2017-03-23 18:10 ` Eric Blake
2017-03-23 20:59 ` Eric Blake
2017-03-23 21:43 ` Eric Blake
2017-03-23 21:56 ` Eric Blake
2017-03-24 3:55 ` Jeff Cody
2017-03-24 7:05 ` Markus Armbruster
2017-03-24 12:42 ` Jeff Cody
2017-03-24 13:49 ` Eric Blake
2017-03-24 14:10 ` Jeff Cody
2017-03-24 14:31 ` Eric Blake
2017-03-27 5:58 ` Markus Armbruster
2017-03-27 16:41 ` Jeff Cody
2017-03-27 18:20 ` Markus Armbruster
2017-04-03 11:25 ` Daniel P. Berrange
2017-04-03 19:03 ` Eric Blake
2017-03-24 17:54 ` Kevin Wolf
2017-03-23 20:52 ` Kevin Wolf
2017-03-23 10:55 ` [Qemu-devel] [PATCH for-2.9 5/5] rbd: Reject options server.*.{numeric, to, ipv4, ipv6} Markus Armbruster
2017-03-23 18:12 ` Eric Blake
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=385d2fa4-a7ec-e22c-e89d-5387cccc2ca4@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=jcody@redhat.com \
--cc=jdurgin@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--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.