From: Eric Blake <eblake@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org
Cc: lvivier@redhat.com,
Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 5/5] tests: qgraph API for the qtest driver framework
Date: Fri, 18 Jan 2019 10:58:55 -0600 [thread overview]
Message-ID: <7e96fe73-93e6-e80d-320c-f8316a9dda96@redhat.com> (raw)
In-Reply-To: <a4424580-d38d-492f-e996-f58a58485e81@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]
On 1/18/19 10:39 AM, Thomas Huth wrote:
>> + QOSGraphEdge *edge = g_new0(QOSGraphEdge, 1);
>> + edge->type = type;
>> + edge->dest = g_strdup(dest);
>> + edge->edge_name = g_strdup(opts->edge_name ? : dest);
>
> I think I'd write the elvis operator rather as "?:", without the space
> inbetween. (or does our checkpatch script dislike that?)
$ git grep '? :' | wc
15 121 1059
$ git grep '?:' | wc
270 1418 19542
>> +bool qos_graph_has_edge(const char *start, const char *dest)
>> +{
>> + QOSGraphEdgeList *list = get_edgelist(start);
>> + QOSGraphEdge *e = search_list_edges(list, dest);
>> + if (e) {
>> + return TRUE;
>> + }
>> + return FALSE;
>> +}
>
> I'm surprised that TRUE and FALSE are also still available with capital
> letters these days ... The spelling from stdbool.h is lowercase.
All caps versions are from glib's gboolean type (which is NOT a good
substitute for C99 bool), and should be avoided for any use that does
not specifically require gboolean due to type compatibility.
>
> Anyway, maybe rather:
>
> return e != NULL;
Or return !!e
>> +void qos_add_test(const char *name, const char *interface,
>> + QOSTestFunc test_func, QOSGraphTestOptions *opts)
>> +{
>> + QOSGraphNode *node;
>> + char *test_name = g_strdup_printf("%s-tests/%s", interface, name);;
>> +
>> + if (!opts) {
>> + opts = &(QOSGraphTestOptions) { };
>
> Same as above ... is the pointer still valid after the next curly brace?
https://stackoverflow.com/questions/47691857/lifetime-of-a-compound-literal
says it is not strict C99, but that
"A far more reasonable rule would indicate that the lifetime of a
compound literal extends until code leaves the function in which it was
used, or the expression creating it is re-executed, whichever happens
first. Since the Standard allows compilers to extend the lifetime of
automatic objects however they see fit, the fact that a compiler does so
should not be considered a bug. On the other hand, a quality compiler
which is deliberately going to be more useful than the Standard requires
should probably explicitly document that fact. Otherwise future
maintainers may declare that any programs that rely upon such sensible
behavior are "defective", and that the compiler can be more "efficient"
if it ceases to support them."
I'm surprised there is not a defect against the C standard to make the
desired semantics explicit.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-01-18 16:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 18:19 [Qemu-devel] [PATCH 0/5] qtest driver framework (core only) Paolo Bonzini
2019-01-15 18:19 ` [Qemu-devel] [PATCH 1/5] tests/libqos: introduce virtio_start_device Paolo Bonzini
2019-01-16 17:16 ` Laurent Vivier
2019-01-18 11:46 ` Thomas Huth
2019-01-15 18:19 ` [Qemu-devel] [PATCH 2/5] tests/libqos: rename qpci_init_pc and qpci_init_spapr functions Paolo Bonzini
2019-01-16 19:55 ` Laurent Vivier
2019-01-18 12:23 ` Thomas Huth
2019-01-18 12:45 ` Paolo Bonzini
2019-01-15 18:19 ` [Qemu-devel] [PATCH 3/5] tests: remove rule for nonexisting qdev-monitor-test Paolo Bonzini
2019-01-16 5:43 ` Thomas Huth
2019-01-17 9:47 ` Laurent Vivier
2019-01-15 18:19 ` [Qemu-devel] [PATCH 4/5] tests/libqos: embed allocators instead of malloc-ing them separately Paolo Bonzini
2019-01-17 10:37 ` Laurent Vivier
2019-01-18 12:52 ` Thomas Huth
2019-01-18 12:59 ` Paolo Bonzini
2019-01-15 18:19 ` [Qemu-devel] [PATCH 5/5] tests: qgraph API for the qtest driver framework Paolo Bonzini
2019-01-18 16:39 ` Thomas Huth
2019-01-18 16:58 ` Eric Blake [this message]
2019-01-18 17:07 ` Paolo Bonzini
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=7e96fe73-93e6-e80d-320c-f8316a9dda96@redhat.com \
--to=eblake@redhat.com \
--cc=e.emanuelegiuseppe@gmail.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).