From e2340f111b1f548025ce6789d2068d7ca0020f1d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 29 Feb 2024 13:43:02 +0000 Subject: [PATCH] girepository: Annotate C99 flexible arrays with their dynamic lengths Using the new `G_COUNTED_BY` macro (i.e. the `__counted_by__` attribute). I found the declarations using: ```sh git grep '\[\];' | grep -v '=' ``` Signed-off-by: Philip Withnall --- girepository/girepository.c | 2 +- girepository/gitypelib-internal.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index 24d83ca25..896e960ec 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -78,7 +78,7 @@ typedef struct { size_t n_interfaces; - GIBaseInfo *interfaces[]; + GIBaseInfo *interfaces[] G_COUNTED_BY(n_interfaces); } GTypeInterfaceCache; static void diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index f7b928fe3..207df8c29 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -549,7 +549,7 @@ typedef struct { uint16_t n_arguments; - ArgBlob arguments[]; + ArgBlob arguments[] G_COUNTED_BY(n_arguments); } SignatureBlob; /** @@ -743,7 +743,7 @@ typedef struct { uint8_t reserved2; uint16_t n_types; - SimpleTypeBlob type[]; + SimpleTypeBlob type[] G_COUNTED_BY(n_types); } ParamTypeBlob; /** @@ -767,7 +767,7 @@ typedef struct { uint8_t reserved2; uint16_t n_domains; /* Must be 0 */ - uint16_t domains[]; + uint16_t domains[] G_COUNTED_BY(n_domains); } ErrorTypeBlob; /** @@ -989,7 +989,7 @@ typedef struct { uint32_t error_domain; - ValueBlob values[]; + ValueBlob values[] G_COUNTED_BY(n_values); } EnumBlob; #define ACCESSOR_SENTINEL 0x3ff @@ -1209,7 +1209,7 @@ typedef struct { uint32_t reserved3; uint32_t reserved4; - uint16_t interfaces[]; + uint16_t interfaces[] G_COUNTED_BY(n_interfaces); } ObjectBlob; /** @@ -1261,7 +1261,7 @@ typedef struct { uint32_t reserved2; uint32_t reserved3; - uint16_t prerequisites[]; + uint16_t prerequisites[] G_COUNTED_BY(n_prerequisites); } InterfaceBlob; /**