X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fheap-test.c;h=642ce7e05a0c3a5c904945ccc161d41e12679142;hb=7693a37f77880e38d26af908cdb21710d631ad5a;hp=34ece38aebbb91a370d7d940395b9a41c8279d62;hpb=756e3feab0a2dab6be0a96164079fce2a2d8f9b4;p=pspp diff --git a/tests/libpspp/heap-test.c b/tests/libpspp/heap-test.c index 34ece38aeb..642ce7e05a 100644 --- a/tests/libpspp/heap-test.c +++ b/tests/libpspp/heap-test.c @@ -126,10 +126,13 @@ swap (int *a, int *b) /* Reverses the order of the CNT integers starting at VALUES. */ static void -reverse (int *values, size_t cnt) +reverse (int *values, size_t cnt) { - for (; cnt > 1; cnt -= 2, values++) - swap (values, &values[cnt - 1]); + size_t i = 0; + size_t j = cnt; + + while (j > i) + swap (&values[i++], &values[--j]); } /* Arranges the CNT elements in VALUES into the lexicographically @@ -166,10 +169,10 @@ next_permutation (int *values, size_t cnt) } /* Returns N!. */ -static unsigned -factorial (unsigned n) +static unsigned int +factorial (unsigned int n) { - unsigned value = 1; + unsigned int value = 1; while (n > 1) value *= n--; return value; @@ -178,11 +181,11 @@ factorial (unsigned n) /* Returns the number of permutations of the CNT values in VALUES. If VALUES contains duplicates, they must be adjacent. */ -static unsigned +static unsigned int expected_perms (int *values, size_t cnt) { size_t i, j; - unsigned perm_cnt; + unsigned int perm_cnt; perm_cnt = factorial (cnt); for (i = 0; i < cnt; i = j)