Selaa lähdekoodia

u-a: Switch from alternative_has_choice() to checking if fs is NULL

We are performing the same search twice, let's just reuse the fs pointer
to decide if we have found the choice.

This was confusing coverity, and making it think that
alternative_has_broken_slave() could get fs with a NULL value.

Warned-by: coverity
Guillem Jover 12 vuotta sitten
vanhempi
commit
c312296f67
1 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  1. 4 3
      utils/update-alternatives.c

+ 4 - 3
utils/update-alternatives.c

@@ -1935,11 +1935,12 @@ alternative_needs_update(struct alternative *a)
 	if (current == NULL)
 		return ALT_UPDATE_LINK_BROKEN;
 
-	if (!alternative_has_choice(a, current))
-		return ALT_UPDATE_NO;
-
 	fs = alternative_get_fileset(a, current);
 
+	/* Stop if we do not have the choice. */
+	if (fs == NULL)
+		return ALT_UPDATE_NO;
+
 	/* Check slaves */
 	for (sl = a->slaves; sl; sl = sl->next) {
 		if (alternative_has_broken_slave(sl, fs)) {