qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_endianness()
Date: Fri, 18 Aug 2017 17:08:45 -0500	[thread overview]
Message-ID: <c8880b01-c9dd-50f9-66c4-db79e69b836e@redhat.com> (raw)
In-Reply-To: <a12d0bfc-4112-414c-6d19-8f9071b5f936@amsat.org>

[-- Attachment #1: Type: text/plain, Size: 1873 bytes --]

On 08/18/2017 04:46 PM, Philippe Mathieu-Daudé wrote:
> On 08/18/2017 06:15 PM, Eric Blake wrote:
>> There was only one caller; it's easier to inline things.
> 
> What's the benefit of this change? Having a separate function ease code
> reading. You might add the 'inline' qualifier but the compiler is smart
> enough to inline it.
> 
> Instead of this change I'd inline it and remove the return value, having
> a void function initializing s->big_endian. Matter of taste I think :)
> 
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>   tests/libqtest.c | 22 ++++++----------------
>>   1 file changed, 6 insertions(+), 16 deletions(-)

I think the diffstat shows that inlining is a win.  My other reason that
it is a win:

>> @@ -351,8 +338,11 @@ QTestState
>> *qtest_init_without_qmp_handshake(const char *extra_args)
>>       }
>>
>>       /* ask endianness of the target */
>> -
>> -    s->big_endian = qtest_query_target_endianness(s);
>> +    qtest_sendf(s, "endianness\n");
>> +    args = qtest_rsp(s, 1);

The old code has to pass an arbitrary QTestState *s down to a helper
function.  But I'm trying to get rid of as many functions as possible
that depend on arbitrary QTestState *s, particularly when callers end up
passing 'global_qtest' for 's'.  Inlining it makes it more obvious that
the changes in 10/13 are safely operating on global_qtest, which in turn
makes it possible for 12/13 to drop QTestState *s parameters from
qtest_sendf() and qtest_rsp().  If the function were not inlined, those
later cleanups would not be as trivial.  (Or put another way - I rebased
this patch to be earlier in the series precisely because of what I ran
into while writing those patches)

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2017-08-18 22:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 21:15 [Qemu-devel] [PATCH v5 00/13] Preliminary libqtest cleanups Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 01/13] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 02/13] qtest: Don't perform side effects inside assertion Eric Blake
2017-08-18 21:33   ` Philippe Mathieu-Daudé
2017-08-18 21:39     ` Eric Blake
2017-08-18 21:52       ` Philippe Mathieu-Daudé
2017-08-18 21:58       ` Eric Blake
2017-08-18 22:03         ` Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 03/13] libqtest: Remove dead qtest_instances variable Eric Blake
2017-08-18 21:33   ` Philippe Mathieu-Daudé
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 04/13] libqtest: Let socket_send() compute length Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 05/13] libqtest: Use qemu_strtoul() Eric Blake
2017-08-18 21:36   ` Philippe Mathieu-Daudé
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 06/13] libqtest: Topologically sort functions Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_endianness() Eric Blake
2017-08-18 21:46   ` Philippe Mathieu-Daudé
2017-08-18 22:08     ` Eric Blake [this message]
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 08/13] tests: Rely more on global_qtest Eric Blake
2017-08-18 21:33   ` John Snow
2017-08-19 16:34     ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-08-23 19:26       ` Eric Blake
2017-08-23 20:02         ` Paolo Bonzini
2017-08-23 21:30           ` Eric Blake
2017-08-23 21:50             ` Paolo Bonzini
2017-08-24  7:42               ` Markus Armbruster
2017-08-24  8:52                 ` Paolo Bonzini
2017-08-24 10:09                   ` Markus Armbruster
2017-08-24 10:20                     ` Paolo Bonzini
2017-08-24 12:07                       ` Markus Armbruster
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 09/13] libqtest: Shorten a couple more qtest_* functions Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 10/13] libqtest: Drop qtest_init() and qtest_qmp_discard_response() Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 11/13] libqtest: Drop many static inline qtest_ wrappers Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 12/13] libqtest: Use global_qtest in qtest_sendf() and qtest_rsp() Eric Blake
2017-08-18 21:15 ` [Qemu-devel] [PATCH v5 13/13] numa-test: Use hmp() Eric Blake
2017-08-18 21:56   ` Philippe Mathieu-Daudé

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=c8880b01-c9dd-50f9-66c4-db79e69b836e@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=f4bug@amsat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).