[GEDI] [RFC v2 3/9] errp: rename errp to errp_in where it is IN-argument
Vladimir Sementsov-Ogievskiy
vsementsov at virtuozzo.com
Mon Sep 23 16:12:25 UTC 2019
Error **errp is almost always OUT-argument: it's assumed to be NULL, or
pointer to NULL-initialized pointer, or pointer to error_abort or
error_fatal, for callee to report error.
But very few functions (most of the are error API) instead get Error
**errp as IN-argument: it's assumed to be set, and callee should clean
it. In such cases, rename errp to errp_in.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov at virtuozzo.com>
---
include/monitor/hmp.h | 2 +-
include/qapi/error.h | 8 ++++----
ui/vnc.h | 2 +-
monitor/hmp-cmds.c | 8 ++++----
ui/vnc.c | 10 +++++-----
util/error.c | 2 +-
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index a0e9511440..f929814f1a 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -16,7 +16,7 @@
#include "qemu/readline.h"
-void hmp_handle_error(Monitor *mon, Error **errp);
+void hmp_handle_error(Monitor *mon, Error **errp_in);
void hmp_info_name(Monitor *mon, const QDict *qdict);
void hmp_info_version(Monitor *mon, const QDict *qdict);
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 551385aa91..4264d22223 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -283,7 +283,7 @@ void error_free(Error *err);
/*
* Convenience function to assert that *@errp is set, then silently free it.
*/
-void error_free_or_abort(Error **errp);
+void error_free_or_abort(Error **errp_in);
/*
* Convenience function to warn_report() and free @err.
@@ -301,19 +301,19 @@ void error_report_err(Error *err);
* Functions to clean Error **errp: call corresponding Error *err cleaning
* function an set pointer to NULL
*/
-static inline void error_free_errp(Error **errp)
+static inline void error_free_errp(Error **errp_in)
{
error_free(*errp_in);
*errp_in = NULL;
}
-static inline void error_report_errp(Error **errp)
+static inline void error_report_errp(Error **errp_in)
{
error_report_err(*errp_in);
*errp_in = NULL;
}
-static inline void warn_report_errp(Error **errp)
+static inline void warn_report_errp(Error **errp_in)
{
warn_report_err(*errp_in);
*errp_in = NULL;
diff --git a/ui/vnc.h b/ui/vnc.h
index fea79c2fc9..00e0b48f2f 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
/* Protocol stage functions */
void vnc_client_error(VncState *vs);
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in);
void start_client_init(VncState *vs);
void start_auth_vnc(VncState *vs);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index b2551c16d1..941d5d0a45 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -60,11 +60,11 @@
#include <spice/enums.h>
#endif
-void hmp_handle_error(Monitor *mon, Error **errp)
+void hmp_handle_error(Monitor *mon, Error **errp_in)
{
- assert(errp);
- if (*errp) {
- error_reportf_err(*errp, "Error: ");
+ assert(errp_in);
+ if (*errp_in) {
+ error_reportf_err(*errp_in, "Error: ");
}
}
diff --git a/ui/vnc.c b/ui/vnc.c
index 87b8045afe..9d6384d9b1 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs)
g_free(vs);
}
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in)
{
if (ret <= 0) {
if (ret == 0) {
@@ -1320,14 +1320,14 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
vnc_disconnect_start(vs);
} else if (ret != QIO_CHANNEL_ERR_BLOCK) {
trace_vnc_client_io_error(vs, vs->ioc,
- errp ? error_get_pretty(*errp) :
+ errp_in ? error_get_pretty(*errp_in) :
"Unknown");
vnc_disconnect_start(vs);
}
- if (errp) {
- error_free(*errp);
- *errp = NULL;
+ if (errp_in) {
+ error_free(*errp_in);
+ *errp_in = NULL;
}
return 0;
}
diff --git a/util/error.c b/util/error.c
index dfba091757..b3ff3832d6 100644
--- a/util/error.c
+++ b/util/error.c
@@ -271,7 +271,7 @@ void error_free(Error *err)
}
}
-void error_free_or_abort(Error **errp)
+void error_free_or_abort(Error **errp_in)
{
assert(errp_in && *errp_in);
error_free(*errp_in);
--
2.21.0
More information about the integration
mailing list