Skip to contentSkip to conversation

qapi/util: Include missing 'qapi/error.h' header

PATCH-for-9.1? Philippe Mathieu-Daudé 2 participants 2 messages Aug 6, 2024

lore
Share & tools
lore
#0 lore raw

qapi_enum_parse() uses the Error type which is declared in "qapi/error.h". Include "qapi/error.h" in order to avoid:

include/qapi/util.h:27:30: error: unknown type name 'Error'

                    int def, Error **errp);
                             ^

Note we include it after the QEnumLookup declaration to avoid:

In file included from include/qapi/error.h:275:
qapi/qapi-types-error.h:30:14: error: unknown type name 'QEnumLookup'

  extern const QEnumLookup QapiErrorClass_lookup;
               ^
---
 include/qapi/util.h | 2 ++
 1 file changed, 2 insertions(+)
include/qapi/util.h +2 -0
index b8254247b8..568f31ac9e 100644
@@ -22,6 +22,8 @@ typedef struct QEnumLookup {
     const int size;
 } QEnumLookup;
 
+#include "qapi/error.h"
+
 const char *qapi_enum_lookup(const QEnumLookup *lookup, int val);
 int qapi_enum_parse(const QEnumLookup *lookup, const char *buf,
                     int def, Error **errp);
Signature · 1 line
2.45.2
#1 lore raw
Quoted 26 lines · Philippe Mathieu-Daudé

qapi_enum_parse() uses the Error type which is declared in "qapi/error.h". Include "qapi/error.h" in order to avoid:

   include/qapi/util.h:27:30: error: unknown type name 'Error'
                     int def, Error **errp);
                              ^

Note we include it after the QEnumLookup declaration to avoid:

In file included from include/qapi/error.h:275:

   qapi/qapi-types-error.h:30:14: error: unknown type name 'QEnumLookup'
   extern const QEnumLookup QapiErrorClass_lookup;
                ^
---
  include/qapi/util.h | 2 ++
  1 file changed, 2 insertions(+)
include/qapi/util.h +0 -0
index b8254247b8..568f31ac9e 100644

include/qapi/util.h typedef struct QEnumLookup { · line 29

Quoted 8 lines
include/qapi/util.h +2 -0
@@ -22,6 +22,8 @@ typedef struct QEnumLookup {
      const int size;
  } QEnumLookup;
 
+#include "qapi/error.h"
+
  const char *qapi_enum_lookup(const QEnumLookup *lookup, int val);
  int qapi_enum_parse(const QEnumLookup *lookup, const char *buf,
                      int def, Error **errp);

Error is in qemu/typedefs.h, which is included from qemu/osdeps.h, which is always first.

There is should be no need for this patch. Why do you think it is needed?

r~