Skip to contentSkip to conversation

qapi/error: Make error_vprepend() static

PATCH-for-5.2 Philippe Mathieu-Daudé 3 participants 3 messages Jul 23, 2020

lore
Share & tools
lore
#0 lore raw

error_vprepend() is only used by util/error.c where it is defined. Make it static to reduce its scope.

---
 include/qapi/error.h | 6 ------
 util/error.c         | 6 +++++-
 2 files changed, 5 insertions(+), 7 deletions(-)
include/qapi/error.h +0 -6
index 7932594dce..fa2308dedd 100644
@@ -384,12 +384,6 @@ void error_propagate(Error **dst_errp, Error *local_err);
 void error_propagate_prepend(Error **dst_errp, Error *local_err,
                              const char *fmt, ...);
 
-/*
- * Prepend some text to @errp's human-readable error message.
- * The text is made by formatting @fmt, @ap like vprintf().
- */
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
-
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, ... like printf().
util/error.c +5 -1
index b6c89d1412..3990b741ff 100644
@@ -121,7 +121,11 @@ void error_setg_file_open_internal(Error **errp,
                               "Could not open '%s'", filename);
 }
 
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
+/*
+ * Prepend some text to @errp's human-readable error message.
+ * The text is made by formatting @fmt, @ap like vprintf().
+ */
+static void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
 {
     GString *newmsg;
 
Signature · 1 line
2.21.3
Reviewed-by
#1 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé <[email protected]> 于2020年7月23日周四 下午6:15写道:

error_vprepend() is only used by util/error.c where it is defined. Make it static to reduce its scope.

Quoted 43 lines
---
 include/qapi/error.h | 6 ------
 util/error.c         | 6 +++++-
 2 files changed, 5 insertions(+), 7 deletions(-)
include/qapi/error.h +0 -6
index 7932594dce..fa2308dedd 100644
@@ -384,12 +384,6 @@ void error_propagate(Error **dst_errp, Error *local_err);
 void error_propagate_prepend(Error **dst_errp, Error *local_err,
                              const char *fmt, ...);
 
-/*
- * Prepend some text to @errp's human-readable error message.
- * The text is made by formatting @fmt, @ap like vprintf().
- */
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
-
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, ... like printf().
util/error.c +5 -2
index b6c89d1412..3990b741ff 100644
@@ -121,7 +121,11 @@ void error_setg_file_open_internal(Error **errp,
                               "Could not open '%s'", filename);
 }
 
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
+/*
+ * Prepend some text to @errp's human-readable error message.
+ * The text is made by formatting @fmt, @ap like vprintf().
+ */
+static void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
 {
     GString *newmsg;
 
--

2.21.3

#2 lore raw

In reply to Philippe Mathieu-Daudé
Quoted 32 lines · Philippe Mathieu-Daudé

error_vprepend() is only used by util/error.c where it is defined. Make it static to reduce its scope.

---
 include/qapi/error.h | 6 ------
 util/error.c         | 6 +++++-
 2 files changed, 5 insertions(+), 7 deletions(-)
include/qapi/error.h +0 -6
index 7932594dce..fa2308dedd 100644
@@ -384,12 +384,6 @@ void error_propagate(Error **dst_errp, Error *local_err);
 void error_propagate_prepend(Error **dst_errp, Error *local_err,
                              const char *fmt, ...);
 
-/*
- * Prepend some text to @errp's human-readable error message.
- * The text is made by formatting @fmt, @ap like vprintf().
- */
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
-
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, ... like printf().
util/error.c +0 -0
index b6c89d1412..3990b741ff 100644
@@ -121,7 +121,11 @@ void error_setg_file_open_internal(Error **errp,
                               "Could not open '%s'", filename);

util/error.c void error_setg_file_open_internal(Error **errp, · line 130

Quoted 10 lines
util/error.c +5 -1
 }
 
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
+/*
+ * Prepend some text to @errp's human-readable error message.
+ * The text is made by formatting @fmt, @ap like vprintf().
+ */
+static void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
 {
     GString *newmsg;

I prefer to keep error_vprepend() in error.h even though it's only used in error.c at the moment.

In an external library interface, every ... function needs a va_list buddy.

This is an internal interface, where providing only a ... function is just fine. I happily do that when I have no use fo the va_list function. But when the va_list function exists, hiding it buys us nothing.