]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
json: Remove invalid typedef redefinition
authorPatrick Steinhardt <ps@pks.im>
Mon, 7 Sep 2020 15:27:32 +0000 (17:27 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 11 Sep 2020 13:46:55 +0000 (15:46 +0200)
The C standard does not allow for typedef redefinitions, even if they
map to the same underlying type. In order to avoid including the
jsmn.h in json.h and thus exposing jsmn's internals, we have exactly
such a forward-declaring typedef in json.h. If enforcing the GNU99 C
standard, clang may generate a warning about this non-standard
construct.

Fix the issue by using a simple "struct jsmntok" forward declaration
instead of using a typedef.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Tested-by: Chuck Tuffli <chuck@freebsd.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/lib/json/json.h

index 01614f6dff429bf64dc39fb788e015a4257779b4..4ea2a22d893a2f217061f5b370c74aee587056b9 100644 (file)
@@ -36,13 +36,14 @@ enum grub_json_type
 };
 typedef enum grub_json_type grub_json_type_t;
 
-typedef struct jsmntok jsmntok_t;
+/* Forward-declaration to avoid including jsmn.h. */
+struct jsmntok;
 
 struct grub_json
 {
-  jsmntok_t   *tokens;
-  char       *string;
-  grub_size_t idx;
+  struct jsmntok *tokens;
+  char          *string;
+  grub_size_t   idx;
 };
 typedef struct grub_json grub_json_t;