From 0ca117a756a79c0f93c9030b5c5a92982e3b0ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 28 Oct 2021 16:18:25 +0100 Subject: monitor: make hmp_handle_error return a boolean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This turns the pattern if (err) { hmp_handle_error(mon, err); return; } into if (hmp_handle_error(mon, err)) { return; } Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- monitor/hmp-cmds.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'monitor') diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index bcaa413..9031cea 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -62,11 +62,13 @@ #include #endif -void hmp_handle_error(Monitor *mon, Error *err) +bool hmp_handle_error(Monitor *mon, Error *err) { if (err) { error_reportf_err(err, "Error: "); + return true; } + return false; } /* @@ -577,8 +579,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) info2l = qmp_query_vnc_servers(&err); info2l_head = info2l; - if (err) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } if (!info2l) { @@ -693,8 +694,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict) Error *err = NULL; info = qmp_query_balloon(&err); - if (err) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -1065,8 +1065,7 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) int i; data = qmp_ringbuf_read(chardev, size, false, 0, &err); - if (err) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -1582,8 +1581,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, true, resume, &err); - if (err) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -1917,8 +1915,7 @@ void hmp_rocker(Monitor *mon, const QDict *qdict) Error *err = NULL; rocker = qmp_query_rocker(name, &err); - if (err != NULL) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -1936,8 +1933,7 @@ void hmp_rocker_ports(Monitor *mon, const QDict *qdict) Error *err = NULL; list = qmp_query_rocker_ports(name, &err); - if (err != NULL) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -1965,8 +1961,7 @@ void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict) Error *err = NULL; list = qmp_query_rocker_of_dpa_flows(name, tbl_id != -1, tbl_id, &err); - if (err != NULL) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } @@ -2115,8 +2110,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) Error *err = NULL; list = qmp_query_rocker_of_dpa_groups(name, type != 9, type, &err); - if (err != NULL) { - hmp_handle_error(mon, err); + if (hmp_handle_error(mon, err)) { return; } -- cgit v1.1