[libvirt] [PATCH 25/46] util: error: use #pragma once in headers

Jonathon Jongsma jjongsma at redhat.com
Tue Jun 18 16:12:55 UTC 2019


Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 src/util/virerror.h     | 41 +++++++++++++++++++----------------------
 src/util/virerrorpriv.h |  5 +----
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/src/util/virerror.h b/src/util/virerror.h
index 8f51510dc2..4cfb0c18dd 100644
--- a/src/util/virerror.h
+++ b/src/util/virerror.h
@@ -19,13 +19,12 @@
  *
  */
 
-#ifndef LIBVIRT_VIRERROR_H
-# define LIBVIRT_VIRERROR_H
+#pragma once
 
-# include "internal.h"
-# include "virautoclean.h"
+#include "internal.h"
+#include "virautoclean.h"
 
-# define VIR_ERROR_MAX_LENGTH 1024
+#define VIR_ERROR_MAX_LENGTH 1024
 
 extern virErrorFunc virErrorHandler;
 extern void *virUserData;
@@ -65,13 +64,13 @@ void virReportSystemErrorFull(int domcode,
                               const char *fmt, ...)
     ATTRIBUTE_FMT_PRINTF(6, 7);
 
-# define virReportSystemError(theerrno, fmt,...) \
+#define virReportSystemError(theerrno, fmt,...) \
     virReportSystemErrorFull(VIR_FROM_THIS, \
                              (theerrno), \
                              __FILE__, __FUNCTION__, __LINE__, \
                              (fmt), __VA_ARGS__)
 
-# define virReportInvalidNullArg(argname) \
+#define virReportInvalidNullArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -82,7 +81,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must be NULL"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidNonNullArg(argname) \
+#define virReportInvalidNonNullArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -93,7 +92,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must not be NULL"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidEmptyStringArg(argname) \
+#define virReportInvalidEmptyStringArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -104,7 +103,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("string %s in %s must not be empty"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidPositiveArg(argname) \
+#define virReportInvalidPositiveArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -115,7 +114,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must be greater than zero"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidNonZeroArg(argname) \
+#define virReportInvalidNonZeroArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -126,7 +125,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must not be zero"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidZeroArg(argname) \
+#define virReportInvalidZeroArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -137,7 +136,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must be zero"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidNonNegativeArg(argname) \
+#define virReportInvalidNonNegativeArg(argname) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -148,7 +147,7 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       _("%s in %s must be zero or greater"), \
                       #argname, __FUNCTION__)
-# define virReportInvalidArg(argname, fmt, ...) \
+#define virReportInvalidArg(argname, fmt, ...) \
     virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \
                       VIR_FROM_THIS, \
                       VIR_ERR_INVALID_ARG, \
@@ -159,10 +158,10 @@ void virReportSystemErrorFull(int domcode,
                       0, 0, \
                       (fmt), __VA_ARGS__)
 
-# define virReportUnsupportedError() \
+#define virReportUnsupportedError() \
     virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_NO_SUPPORT, \
                          __FILE__, __FUNCTION__, __LINE__, __FUNCTION__)
-# define virReportRestrictedError(...) \
+#define virReportRestrictedError(...) \
     virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_OPERATION_DENIED, \
                          __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
 /* The sizeof(...) comparison here is a hack to catch typos
@@ -170,7 +169,7 @@ void virReportSystemErrorFull(int domcode,
  * as detecting if you passed a typename that refers to a function
  * or struct type, instead of an enum. It should get optimized away
  * since sizeof() is known at compile time  */
-# define virReportEnumRangeError(typname, value) \
+#define virReportEnumRangeError(typname, value) \
     virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, \
                          __FILE__, __FUNCTION__, __LINE__, \
                          "Unexpected enum value %d for %s", \
@@ -181,14 +180,14 @@ void virReportOOMErrorFull(int domcode,
                            const char *funcname,
                            size_t linenr);
 
-# define virReportOOMError() \
+#define virReportOOMError() \
     virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
 
-# define virReportError(code, ...) \
+#define virReportError(code, ...) \
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
                          __FUNCTION__, __LINE__, __VA_ARGS__)
 
-# define virReportErrorObject(obj) \
+#define virReportErrorObject(obj) \
     virRaiseErrorObject(__FILE__, __FUNCTION__, __LINE__, obj)
 
 int virSetError(virErrorPtr newerr);
@@ -207,5 +206,3 @@ void virErrorPreserveLast(virErrorPtr *saveerr);
 void virErrorRestore(virErrorPtr *savederr);
 
 VIR_DEFINE_AUTOPTR_FUNC(virError, virFreeError);
-
-#endif /* LIBVIRT_VIRERROR_H */
diff --git a/src/util/virerrorpriv.h b/src/util/virerrorpriv.h
index 8e482f2e40..66acf0b4be 100644
--- a/src/util/virerrorpriv.h
+++ b/src/util/virerrorpriv.h
@@ -18,11 +18,8 @@
 # error "virerrorpriv.h may only be included by virerror.c or its test suite"
 #endif /* LIBVIRT_VIRERRORPRIV_H_ALLOW */
 
-#ifndef LIBVIRT_VIRERRORPRIV_H
-# define LIBVIRT_VIRERRORPRIV_H
+#pragma once
 
 const char *
 virErrorMsg(virErrorNumber error,
             const char *info);
-
-#endif /* LIBVIRT_VIRERRORPRIV_H */
-- 
2.20.1




More information about the libvir-list mailing list