Просмотр исходного кода

u-a: Use alternative_get_fileset() instead of open-coding it

Guillem Jover лет назад: 13
Родитель
Сommit
adb64dabac
1 измененных файлов с 9 добавлено и 12 удалено
  1. 9 12
      utils/update-alternatives.c

+ 9 - 12
utils/update-alternatives.c

@@ -1197,12 +1197,10 @@ alternative_parse_fileset(struct alternative *a, struct altdb_context *ctx)
 		return false;
 	}
 
-	for (fs = a->choices; fs; fs = fs->next) {
-		if (strcmp(fs->master_file, master_file) == 0) {
-			free(master_file);
-			ctx->bad_format(ctx, _("duplicate path %s"),
-			                fs->master_file);
-		}
+	fs = alternative_get_fileset(a, master_file);
+	if (fs) {
+		free(master_file);
+		ctx->bad_format(ctx, _("duplicate path %s"), master_file);
 	}
 
 	if (stat(master_file, &st)) {
@@ -1600,12 +1598,11 @@ alternative_select_choice(struct alternative *a)
 			}
 		} else {
 			/* Look up by name */
-			for (fs = a->choices; fs; fs = fs->next) {
-				if (strcmp(fs->master_file, selection) == 0) {
-					alternative_set_status(a, ALT_ST_MANUAL);
-					free(current);
-					return xstrdup(selection);
-				}
+			fs = alternative_get_fileset(a, selection);
+			if (fs) {
+				alternative_set_status(a, ALT_ST_MANUAL);
+				free(current);
+				return xstrdup(selection);
 			}
 		}
 	}