gitypeinfo: Remove invalid return value from gi_type_info_get_array_type()

`-1` isn’t part of `GIArrayType`, so it’s not particularly type safe to
return it from `gi_type_info_get_array_type()`. Instead, make it an
error to call that function on a type which isn’t an array type.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
This commit is contained in:
Philip Withnall
2024-01-16 23:17:19 +00:00
parent 6a7806da4d
commit 33f157bd6b

View File

@@ -350,10 +350,12 @@ gi_type_info_is_zero_terminated (GITypeInfo *info)
* *
* Obtain the array type for this type. * Obtain the array type for this type.
* *
* See [enum@GIRepository.ArrayType] for a list of possible values. If the type * See [enum@GIRepository.ArrayType] for a list of possible values.
* tag of this type is not array, `-1` will be returned.
* *
* Returns: the array type or `-1` * It is an error to call this on an @info which is not an array type. Use
* [method@GIRepository.TypeInfo.get_tag] to check.
*
* Returns: the array type
* Since: 2.80 * Since: 2.80
*/ */
GIArrayType GIArrayType
@@ -375,7 +377,8 @@ gi_type_info_get_array_type (GITypeInfo *info)
return blob->array_type; return blob->array_type;
} }
return -1; /* Not an array type */
g_assert_not_reached ();
} }
/** /**