QAPI patches for 2017-07-12
[Qemu-devel] [PULL 1/3] qobject: Catch another straggler for use of qdict_put_str()
In reply to Markus ArmbrusterFrom: Eric Blake <[email protected]>
Dan's addition of key-secret improvements in commit 29cf9336 was developed prior to the addition of QDict scalar insertion macros, but merged after the general cleanup in commit 46f5ac20. Patch created mechanically by rerunning:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-placeMessage-Id: <[email protected]>
--- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +1 -1
@@ -355,7 +355,7 @@ static int img_add_key_secrets(void *opaque,QDict *options = opaque;if (g_str_has_suffix (name,"key-secret" )) { -qdict_put (options, name,qstring_from_str (value)); +qdict_put_str (options, name, value); }return 0 ;
Signature · 1 line
2.7.5
The following changes since commit aa916e409c04cb614ec2fee8b6b33836bf5998bb:
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170711' into staging (2017-07-11 16:34:09 +0100)
are available in the git repository at:
git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2017-07-12
for you to fetch changes up to 086ee7a6200fa5ad795b12110b5b3d5a93dcac3e:
scripts: use build_ prefix for string not piped through cgen() (2017-07-12 17:51:54 +0200)
----------------------------------------------------------------
QAPI patches for 2017-07-12
----------------------------------------------------------------
Eric Blake (2):
qobject: Catch another straggler for use of qdict_put_str()
qobject: Update coccinelle script to catch Q{INC, DEC}REF
Marc-André Lureau (1):
scripts: use build_ prefix for string not piped through cgen()
monitor.c | 2 +- qemu-img.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ scripts/qapi-commands.py | 8 ++++---- scripts/qapi-event.py | 12 ++++++------ scripts/qapi.py | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-)
Signature · 1 line
2.7.5
[Qemu-devel] [PULL 2/3] qobject: Update coccinelle script to catch Q{INC, DEC}REF
From: Eric Blake <[email protected]>
The recent commit b097efc0 used qobject_decref(QOBJECT(E)), even though we already have QDECREF(E) for that purpose. We can update our coccinelle script to catch any future relapses; with that in place, the rest of the patch is generated with:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-placeMessage-Id: <[email protected]>
--- monitor.c | 2 +- scripts/coccinelle/qobject.cocci | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
monitor.c +1 -1
@@ -3842,7 +3842,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) req_json =qobject_to_json (req);trace_handle_qmp_command (mon,qstring_get_str (req_json)); -qobject_decref (QOBJECT (req_json)); +QDECREF (req_json); rsp =qmp_dispatch (cur_mon->qmp.commands, req);
scripts/coccinelle/qobject.cocci +6 -0
@@ -3,6 +3,12 @@ expression Obj, Key, E; @@ ( +- qobject_incref(QOBJECT(E)); ++ QINCREF(E); +| +- qobject_decref(QOBJECT(E)); ++ QDECREF(E); +| - qdict_put_obj(Obj, Key, QOBJECT(E)); + qdict_put(Obj, Key, E); |
Signature · 1 line
2.7.5
[Qemu-devel] [PULL 3/3] scripts: use build_ prefix for string not piped through cgen()
In reply to Markus ArmbrusterFrom: Marc-André Lureau <[email protected]>
The gen_ prefix is awkward. Generated C should go through cgen() exactly once (see commit 1f9a7a1). The common way to get this wrong is passing a foo=gen_foo() keyword argument to mcgen(). I'd like us to adopt a naming convention where gen_ means "something that's been piped through cgen(), and thus must not be passed to cgen() or mcgen()". Requires renaming gen_params(), gen_marshal_proto() and gen_event_send_proto().
Message-Id: <[email protected]>
--- scripts/qapi-commands.py | 8 ++++---- scripts/qapi-event.py | 12 ++++++------ scripts/qapi.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
scripts/qapi-commands.py +4 -4
@@ -21,7 +21,7 @@ def gen_command_decl(name, arg_type, boxed, ret_type): ''', c_type=(ret_type and ret_type.c_type()) or 'void', c_name=c_name(name), - params=gen_params(arg_type, boxed, 'Error **errp')) + params=build_params(arg_type, boxed, 'Error **errp')) def gen_call(name, arg_type, boxed, ret_type):
@@ -82,7 +82,7 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, c_type=ret_type.c_type(), c_name=ret_type.c_name()) -def gen_marshal_proto(name): +def build_marshal_proto(name): return ('void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name))
@@ -91,7 +91,7 @@ def gen_marshal_decl(name): return mcgen(''' %(proto)s; ''', - proto=gen_marshal_proto(name)) + proto=build_marshal_proto(name)) def gen_marshal(name, arg_type, boxed, ret_type):
@@ -103,7 +103,7 @@ def gen_marshal(name, arg_type, boxed, ret_type): { Error *err = NULL; ''', - proto=gen_marshal_proto(name)) + proto=build_marshal_proto(name)) if ret_type: ret += mcgen('''
scripts/qapi-event.py +6 -6
@@ -14,10 +14,10 @@ from qapi import * -def gen_event_send_proto(name, arg_type, boxed): +def build_event_send_proto(name, arg_type, boxed): return 'void qapi_event_send_%(c_name)s(%(param)s)' % { 'c_name': c_name(name.lower()), - 'param': gen_params(arg_type, boxed, 'Error **errp')} + 'param': build_params(arg_type, boxed, 'Error **errp')} def gen_event_send_decl(name, arg_type, boxed):
@@ -25,10 +25,10 @@ def gen_event_send_decl(name, arg_type, boxed): %(proto)s; ''', - proto=gen_event_send_proto(name, arg_type, boxed)) + proto=build_event_send_proto(name, arg_type, boxed)) -# Declare and initialize an object 'qapi' using parameters from gen_params() +# Declare and initialize an object 'qapi' using parameters from build_params() def gen_param_var(typ): assert not typ.variants ret = mcgen('''
@@ -42,7 +42,7 @@ def gen_param_var(typ): if memb.optional: ret += 'has_' + c_name(memb.name) + sep if memb.type.name == 'str': - # Cast away const added in gen_params() + # Cast away const added in build_params() ret += '(char *)' ret += c_name(memb.name) ret += mcgen('''
@@ -72,7 +72,7 @@ def gen_event_send(name, arg_type, boxed): Error *err = NULL; QMPEventFuncEmit emit; ''', - proto=gen_event_send_proto(name, arg_type, boxed)) + proto=build_event_send_proto(name, arg_type, boxed)) if arg_type and not arg_type.is_empty(): ret += mcgen('''
scripts/qapi.py +1 -1
@@ -1897,7 +1897,7 @@ extern const char *const %(c_name)s_lookup[]; return ret -def gen_params(arg_type, boxed, extra): +def build_params(arg_type, boxed, extra): if not arg_type: assert not boxed return extra
Signature · 1 line
2.7.5
Peter Maydell
AppliedQuoted 15 lines · Markus Armbruster
The following changes since commit
aa916e409c04cb614ec2fee8b6b33836bf5998bb:Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.10-20170711' into staging (2017-07-11 16:34:09 +0100)
are available in the git repository at:
git://repo.or.cz/qemu/armbru.gittags/pull-qapi-2017-07-12for you to fetch changes up to
086ee7a6200fa5ad795b12110b5b3d5a93dcac3e:scripts: use
build_prefix for string not piped throughcgen()(2017-07-12 17:51:54 +0200)----------------------------------------------------------------
QAPI patches for 2017-07-12
Quoted 8 lines
----------------------------------------------------------------
Eric Blake (2):
qobject: Catch another straggler for use ofqdict_put_str()
qobject: Update coccinelle script to catch Q{INC, DEC}REFMarc-André Lureau (1):
scripts: usebuild_prefix for string not piped throughcgen()
Applied, thanks.
-- PMM