Skip to content

Commit

Permalink
src/mark: avoid scan-build false positive
Browse files Browse the repository at this point in the history
Previously, scan-build thought that ierror->message could be a null pointer
dereference, because it doesn't know that g_error_matches returns false in that
case.

Signed-off-by: Jan Luebbe <[email protected]>
  • Loading branch information
jluebbe committed Apr 22, 2020
1 parent 62d343e commit a6755e4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ gboolean mark_run(const gchar *state,
*message = res ? g_strdup_printf("marked slot %s as bad", slot->name) : g_strdup(ierror->message);
} else if (!g_strcmp0(state, "active")) {
mark_active(slot, &ierror);
if (g_error_matches(ierror, R_INSTALL_ERROR, R_INSTALL_ERROR_MARK_BOOTABLE)) {
if (!ierror) {
res = TRUE;
*message = g_strdup_printf("activated slot %s", slot->name);
} else if (g_error_matches(ierror, R_INSTALL_ERROR, R_INSTALL_ERROR_MARK_BOOTABLE)) {
res = FALSE;
*message = g_strdup(ierror->message);
} else if (g_error_matches(ierror, R_INSTALL_ERROR, R_INSTALL_ERROR_FAILED)) {
res = TRUE;
*message = g_strdup_printf("activated slot %s, but failed to write status file: %s",
slot->name, ierror->message);
} else if (ierror) {
} else {
res = FALSE;
*message = g_strdup_printf("unexpected error while trying to activate slot %s: %s",
slot->name, ierror->message);
} else {
res = TRUE;
*message = g_strdup_printf("activated slot %s", slot->name);
}
g_clear_error(&ierror);
} else {
Expand Down

0 comments on commit a6755e4

Please sign in to comment.