Skip to content
Snippets Groups Projects
Commit e479db6c authored by Frederic Danis's avatar Frederic Danis
Browse files

Fix errors when no boot state backend has been found


Current asserts on AumBootState object in aum_boot_state_*() functions
ends up when there is no boot state backend available, i.e. for UEFI AMD64
targets, by trying to rollback the OS.
Replacing those asserts by tests returning default values allows AUM to
handle this case gracefully and with better debug message.

Signed-off-by: default avatarFrédéric Danis <frederic.danis@collabora.com>
parent 63fef3b2
No related branches found
No related tags found
2 merge requests!71Merge changes from apertis/v2020-updates into apertis/v2020,!64Backport "Fix errors when no boot state backend has been found" to v2020
......@@ -30,7 +30,11 @@ aum_boot_state_default_init (AumBootStateInterface *iface)
gboolean
aum_boot_state_is_active (AumBootState *self)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), FALSE);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return FALSE;
}
return AUM_BOOT_STATE_GET_IFACE (self)->is_active (self);
}
......@@ -38,7 +42,11 @@ aum_boot_state_is_active (AumBootState *self)
const gchar*
aum_boot_state_get_name (AumBootState *self)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), FALSE);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return NULL;
}
return AUM_BOOT_STATE_GET_IFACE (self)->get_name (self);
}
......@@ -46,7 +54,12 @@ aum_boot_state_get_name (AumBootState *self)
gint
aum_boot_state_get_boot_count (AumBootState *self)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), -1);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return -1;
}
g_return_val_if_fail (AUM_BOOT_STATE_GET_IFACE (self)->get_boot_count != NULL, -1);
return AUM_BOOT_STATE_GET_IFACE (self)->get_boot_count (self);
......@@ -55,7 +68,12 @@ aum_boot_state_get_boot_count (AumBootState *self)
gint
aum_boot_state_get_boot_limit (AumBootState *self)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), -1);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return 0;
}
g_return_val_if_fail (AUM_BOOT_STATE_GET_IFACE (self)->get_boot_limit != NULL, -1);
return AUM_BOOT_STATE_GET_IFACE (self)->get_boot_limit (self);
......@@ -64,7 +82,12 @@ aum_boot_state_get_boot_limit (AumBootState *self)
void
aum_boot_state_set_boot_limit (AumBootState *self, guint limit)
{
g_return_if_fail (AUM_IS_BOOT_STATE (self));
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return;
}
g_return_if_fail (AUM_BOOT_STATE_GET_IFACE (self)->set_boot_limit != NULL);
return AUM_BOOT_STATE_GET_IFACE (self)->set_boot_limit (self, limit);
......@@ -73,7 +96,12 @@ aum_boot_state_set_boot_limit (AumBootState *self, guint limit)
gboolean
aum_boot_state_get_update_available (AumBootState *self)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), -1);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return FALSE;
}
g_return_val_if_fail (AUM_BOOT_STATE_GET_IFACE (self)->get_update_available != NULL, -1);
return AUM_BOOT_STATE_GET_IFACE (self)->get_update_available (self);
......@@ -82,7 +110,12 @@ aum_boot_state_get_update_available (AumBootState *self)
gboolean
aum_boot_state_set_update_available (AumBootState *self, gboolean update_available)
{
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), -1);
if (!AUM_IS_BOOT_STATE (self))
{
g_debug("%s: No boot state backend available", __func__);
return TRUE;
}
g_return_val_if_fail (AUM_BOOT_STATE_GET_IFACE (self)->set_update_available != NULL, -1);
return AUM_BOOT_STATE_GET_IFACE (self)->set_update_available (self, update_available);
......@@ -93,7 +126,11 @@ gboolean boot_state_check_boot_successful (AumBootState *self)
gint count = 0;
gint limit = 0;
g_return_val_if_fail (AUM_IS_BOOT_STATE (self), FALSE);
if (!AUM_IS_BOOT_STATE (self))
{
g_message("No boot state backend available, consider boot successful");
return TRUE;
}
count = aum_boot_state_get_boot_count (self);
limit = aum_boot_state_get_boot_limit (self);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment