[libvirt] [PATCH 04/10] util: error: Export virErrorMsg for use in testsuite

Peter Krempa posted 10 patches 7 years, 2 months ago
[libvirt] [PATCH 04/10] util: error: Export virErrorMsg for use in testsuite
Posted by Peter Krempa 7 years, 2 months ago
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/Makefile.am          |  1 +
 src/libvirt_private.syms |  1 +
 src/util/Makefile.inc.am |  1 +
 src/util/virerror.c      |  5 ++++-
 src/util/virerrorpriv.h  | 28 ++++++++++++++++++++++++++++
 5 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 src/util/virerrorpriv.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 33ff280d78..0bb3ff8fc8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -951,6 +951,7 @@ libvirt_nss_la_SOURCES = \
 		util/vircommand.h \
 		util/virerror.c \
 		util/virerror.h \
+		util/virerrorpriv.h \
 		util/virfile.c \
 		util/virfile.h \
 		util/virhash.c \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fd63c9ca61..6184030d59 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1752,6 +1752,7 @@ ebtablesRemoveForwardAllowIn;
 virDispatchError;
 virErrorCopyNew;
 virErrorInitialize;
+virErrorMsg;
 virErrorPreserveLast;
 virErrorRestore;
 virErrorSetErrnoFromLastError;
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index cffbb357bc..4295babac3 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -50,6 +50,7 @@ UTIL_SOURCES = \
 	util/virendian.h \
 	util/virerror.c \
 	util/virerror.h \
+	util/virerrorpriv.h \
 	util/virevent.c \
 	util/virevent.h \
 	util/vireventpoll.c \
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 64be00dc75..be23712a60 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -31,6 +31,9 @@
 #include "virutil.h"
 #include "virstring.h"

+#define __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__
+#include "virerrorpriv.h"
+
 VIR_LOG_INIT("util.error");

 virThreadLocal virLastErr;
@@ -910,7 +913,7 @@ void virRaiseErrorObject(const char *filename,
  *
  * Returns the constant string associated to @error
  */
-static const char *
+const char *
 virErrorMsg(virErrorNumber error, const char *info)
 {
     const char *errmsg = NULL;
diff --git a/src/util/virerrorpriv.h b/src/util/virerrorpriv.h
new file mode 100644
index 0000000000..bc214393e6
--- /dev/null
+++ b/src/util/virerrorpriv.h
@@ -0,0 +1,28 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__
+# error "virerrorpriv.h may only be included by virerror.c or its test suite"
+#endif
+
+#ifndef __VIR_ERROR_PRIV_H__
+# define __VIR_ERROR_PRIV_H__
+
+const char *
+virErrorMsg(virErrorNumber error,
+            const char *info);
+
+#endif /* __VIR_ERROR_PRIV_H__ */
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/10] util: error: Export virErrorMsg for use in testsuite
Posted by Erik Skultety 7 years, 2 months ago
On Wed, Dec 05, 2018 at 05:47:45PM +0100, Peter Krempa wrote:
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/Makefile.am          |  1 +
>  src/libvirt_private.syms |  1 +
>  src/util/Makefile.inc.am |  1 +
>  src/util/virerror.c      |  5 ++++-
>  src/util/virerrorpriv.h  | 28 ++++++++++++++++++++++++++++
>  5 files changed, 35 insertions(+), 1 deletion(-)
>  create mode 100644 src/util/virerrorpriv.h
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 33ff280d78..0bb3ff8fc8 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -951,6 +951,7 @@ libvirt_nss_la_SOURCES = \
>  		util/vircommand.h \
>  		util/virerror.c \
>  		util/virerror.h \
> +		util/virerrorpriv.h \

Unrelated to the commit message and compiles fine without it.

>  		util/virfile.c \
>  		util/virfile.h \
>  		util/virhash.c \
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index fd63c9ca61..6184030d59 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1752,6 +1752,7 @@ ebtablesRemoveForwardAllowIn;
>  virDispatchError;
>  virErrorCopyNew;
>  virErrorInitialize;
> +virErrorMsg;
>  virErrorPreserveLast;
>  virErrorRestore;
>  virErrorSetErrnoFromLastError;
> diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
> index cffbb357bc..4295babac3 100644
> --- a/src/util/Makefile.inc.am
> +++ b/src/util/Makefile.inc.am
> @@ -50,6 +50,7 @@ UTIL_SOURCES = \
>  	util/virendian.h \
>  	util/virerror.c \
>  	util/virerror.h \
> +	util/virerrorpriv.h \
>  	util/virevent.c \
>  	util/virevent.h \
>  	util/vireventpoll.c \
> diff --git a/src/util/virerror.c b/src/util/virerror.c
> index 64be00dc75..be23712a60 100644
> --- a/src/util/virerror.c
> +++ b/src/util/virerror.c
> @@ -31,6 +31,9 @@
>  #include "virutil.h"
>  #include "virstring.h"
>
> +#define __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__
> +#include "virerrorpriv.h"

>From consistency POV, you also want:
#undefine __VIR_ERROR_ALLOW_INCLUDE_PRIV_H__

With the proposed adjustments:
Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list