Quellcode durchsuchen

tests/sched_policies: use a nice for loop instead of the ugly while loop (if you like pointer arithmetic ...)

Nathalie Furmento vor 12 Jahren
Ursprung
Commit
f79a3a7873
2 geänderte Dateien mit 10 neuen und 20 gelöschten Zeilen
  1. 4 9
      tests/sched_policies/execute_all_tasks.c
  2. 6 11
      tests/sched_policies/simple_deps.c

+ 4 - 9
tests/sched_policies/execute_all_tasks.c

@@ -93,22 +93,17 @@ run(struct starpu_sched_policy *p)
 int
 main(void)
 {
-	int i;
 	struct starpu_sched_policy **policies;
+	struct starpu_sched_policy **policy;
 
 	policies = starpu_sched_get_predefined_policies();
-	i = 0;
-	struct starpu_sched_policy *policy = policies[i];
-
-	while (policy != NULL)
+	for(policy=policies ; *policy!=NULL ; policy++)
 	{
-		FPRINTF(stderr, "Running with policy %s.\n", policy->policy_name);
+		FPRINTF(stderr, "Running with policy %s.\n", (*policy)->policy_name);
 		int ret;
-		ret = run(policy);
+		ret = run(*policy);
 		if (ret == 1)
 			return EXIT_FAILURE;
-		i++;
-		policy = policies[i];
 	}
 
 	return EXIT_SUCCESS;

+ 6 - 11
tests/sched_policies/simple_deps.c

@@ -86,26 +86,21 @@ enodev:
 int
 main(void)
 {
-	int i;
 	struct starpu_sched_policy **policies;
+	struct starpu_sched_policy **policy;
 
 	policies = starpu_sched_get_predefined_policies();
-	i = 0;
-	struct starpu_sched_policy *policy = policies[i];
-
-	while (policy != NULL)
+	policies = starpu_sched_get_predefined_policies();
+	for(policy=policies ; *policy!=NULL ; policy++)
 	{
-		FPRINTF(stderr, "Running with policy %s.\n",
-			policy->policy_name);
 		int ret;
-		ret = run(policy);
+
+		FPRINTF(stderr, "Running with policy %s.\n", (*policy)->policy_name);
+		ret = run(*policy);
 		if (ret == -ENODEV)
 			return STARPU_TEST_SKIPPED;
 		if (ret == 1)
 			return EXIT_FAILURE;
-
-		i++;
-		policy = policies[i];
 	}
 
 	return EXIT_SUCCESS;