Merge pull request #2463 from cgwalters/fix-fanalyzer

Fix various mostly theoretical gcc `-fanalyzer` issues
This commit is contained in:
Luca Bruno 2021-10-14 08:30:25 +00:00 committed by GitHub
commit 6b8295ada1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 19 deletions

View File

@ -374,9 +374,9 @@ ostree_deployment_new (int index,
OstreeDeployment *self;
/* index may be -1 */
g_return_val_if_fail (osname != NULL, NULL);
g_return_val_if_fail (csum != NULL, NULL);
g_return_val_if_fail (deployserial >= 0, NULL);
g_assert (osname != NULL);
g_assert (csum != NULL);
g_assert (deployserial >= 0);
/* We can have "disconnected" deployments that don't have a
bootcsum/serial */

View File

@ -183,7 +183,7 @@ static OstreeFetcherPendingURI *
pending_uri_ref (OstreeFetcherPendingURI *pending)
{
gint refcount;
g_return_val_if_fail (pending != NULL, NULL);
g_assert (pending);
refcount = g_atomic_int_add (&pending->ref_count, 1);
g_assert (refcount > 0);
return pending;

View File

@ -65,8 +65,8 @@ ostree_remote_new_dynamic (const gchar *name,
{
OstreeRemote *remote;
g_return_val_if_fail (name != NULL && *name != '\0', NULL);
g_return_val_if_fail (refspec_name == NULL || *refspec_name != '\0', NULL);
g_assert (name != NULL && *name != '\0');
g_assert (refspec_name == NULL || *refspec_name != '\0');
remote = g_slice_new0 (OstreeRemote);
remote->ref_count = 1;

View File

@ -1235,12 +1235,15 @@ ostree_sysroot_get_subbootversion (OstreeSysroot *self)
* ostree_sysroot_get_booted_deployment:
* @self: Sysroot
*
* This function may only be called if the sysroot is loaded.
*
* Returns: (transfer none) (nullable): The currently booted deployment, or %NULL if none
*/
OstreeDeployment *
ostree_sysroot_get_booted_deployment (OstreeSysroot *self)
{
g_return_val_if_fail (self->loadstate == OSTREE_SYSROOT_LOAD_STATE_LOADED, NULL);
g_assert (self);
g_assert (self->loadstate == OSTREE_SYSROOT_LOAD_STATE_LOADED);
return self->booted_deployment;
}
@ -1390,7 +1393,8 @@ ostree_sysroot_get_repo (OstreeSysroot *self,
OstreeRepo *
ostree_sysroot_repo (OstreeSysroot *self)
{
g_return_val_if_fail (self->loadstate >= OSTREE_SYSROOT_LOAD_STATE_LOADED, NULL);
g_assert (self);
g_assert (self->loadstate >= OSTREE_SYSROOT_LOAD_STATE_LOADED);
g_assert (self->repo);
return self->repo;
}

View File

@ -82,10 +82,13 @@ ot_gfile_ensure_unlinked (GFile *path,
GCancellable *cancellable,
GError **error)
{
if (unlink (gs_file_get_path_cached (path)) != 0)
g_assert (path);
const char *pathc = gs_file_get_path_cached (path);
g_assert (pathc);
if (unlink (pathc) != 0)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "unlink(%s)", gs_file_get_path_cached (path));
return glnx_throw_errno_prefix (error, "unlink(%s)", pathc);
}
return TRUE;
}

View File

@ -909,6 +909,7 @@ ot_variant_builder_pre_add (OtVariantBuilderInfo *info,
const GVariantMemberInfo *member_info;
member_info = g_variant_type_info_member_info (info->type_info, info->n_children);
g_assert (member_info);
alignment = member_info->type_info->alignment;
}
else if (g_variant_type_is_array (info->type))
@ -959,6 +960,7 @@ ot_variant_builder_post_add (OtVariantBuilderInfo *info,
const GVariantMemberInfo *member_info;
member_info = g_variant_type_info_member_info (info->type_info, info->n_children);
g_assert (member_info);
if (member_info->ending_type == G_VARIANT_MEMBER_ENDING_OFFSET)
ot_variant_builder_add_child_end (info);
}
@ -1085,16 +1087,13 @@ ot_variant_builder_open (OtVariantBuilder *builder,
OtVariantBuilderInfo *info = builder->head;
OtVariantBuilderInfo *new_info;
g_return_val_if_fail (info->n_children < info->max_items,
FALSE);
g_return_val_if_fail (!info->expected_type ||
g_assert (info->n_children < info->max_items);
g_assert (!info->expected_type ||
g_variant_type_is_subtype_of (type,
info->expected_type),
FALSE);
g_return_val_if_fail (!info->prev_item_type ||
info->expected_type));
g_assert (!info->prev_item_type ||
g_variant_type_is_subtype_of (info->prev_item_type,
type),
FALSE);
type));
if (!ot_variant_builder_pre_add (info, type, error))
return FALSE;

View File

@ -669,7 +669,7 @@ ostree_builtin_static_delta (int argc, char **argv, OstreeCommandInvocation *inv
return TRUE; /* Note early return */
}
if (!command->fn)
if (!command || !command->fn)
{
static_delta_usage (argv, TRUE);
return glnx_throw (error, "Unknown \"static-delta\" subcommand '%s'", cmdname);