girepository: Make gi_repository_get_info() not nullable

Having it be nullable means the type system forces the caller to check
the result for nullability every time, even though it’s straightforward
for the caller to check the index argument in advance and guarantee a
non-`NULL` result.

Change `gi_repository_get_info()` to never return `NULL` to tidy this
up. This also brings it inline with other `gi_*_get_info()` functions,
which are not nullable.

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
This commit is contained in:
Philip Withnall 2024-01-05 12:05:26 +00:00
parent f9e54fc991
commit bbe9046ade

View File

@ -780,10 +780,10 @@ gi_repository_get_n_infos (GIRepository *repository,
* *
* The namespace must have already been loaded before calling this function. * The namespace must have already been loaded before calling this function.
* See [method@GIRepository.Repository.get_n_infos] to find the maximum number * See [method@GIRepository.Repository.get_n_infos] to find the maximum number
* of entries. * of entries. It is an error to pass an invalid @idx to this function.
* *
* Returns: (transfer full) (nullable): [class@GIRepository.BaseInfo] containing * Returns: (transfer full) (not nullable): [class@GIRepository.BaseInfo]
* metadata, or `NULL` if @idx was too high * containing metadata
* Since: 2.80 * Since: 2.80
*/ */
GIBaseInfo * GIBaseInfo *
@ -803,8 +803,8 @@ gi_repository_get_info (GIRepository *repository,
g_return_val_if_fail (typelib != NULL, NULL); g_return_val_if_fail (typelib != NULL, NULL);
entry = gi_typelib_get_dir_entry (typelib, idx + 1); entry = gi_typelib_get_dir_entry (typelib, idx + 1);
if (entry == NULL) g_return_val_if_fail (entry != NULL, NULL);
return NULL;
return gi_info_new_full (entry->blob_type, return gi_info_new_full (entry->blob_type,
repository, repository,
NULL, typelib, entry->offset); NULL, typelib, entry->offset);