summaryrefslogtreecommitdiffstats
path: root/lib/tests/test_opts1.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests/test_opts1.c')
-rw-r--r--lib/tests/test_opts1.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/tests/test_opts1.c b/lib/tests/test_opts1.c
index 99da5596..fa95c4d4 100644
--- a/lib/tests/test_opts1.c
+++ b/lib/tests/test_opts1.c
@@ -40,15 +40,16 @@ void my_free(int *argc, char **newargv, char **argv) {
40#else 40#else
41void my_free(int *argc, char **newargv, char **argv) { 41void my_free(int *argc, char **newargv, char **argv) {
42 /* Free stuff (and print while we're at it) */ 42 /* Free stuff (and print while we're at it) */
43 int i, freeflag = 1; 43 bool freeflag = true;
44 printf(" Arg(%i): ", *argc + 1); 44 printf(" Arg(%i): ", *argc + 1);
45 printf("'%s' ", newargv[0]); 45 printf("'%s' ", newargv[0]);
46 for (i = 1; i < *argc; i++) { 46
47 for (int i = 1; i < *argc; i++) {
47 printf("'%s' ", newargv[i]); 48 printf("'%s' ", newargv[i]);
48 /* Stop freeing when we get to the start of the original array */ 49 /* Stop freeing when we get to the start of the original array */
49 if (freeflag) { 50 if (freeflag) {
50 if (newargv[i] == argv[1]) { 51 if (newargv[i] == argv[1]) {
51 freeflag = 0; 52 freeflag = false;
52 } else { 53 } else {
53 free(newargv[i]); 54 free(newargv[i]);
54 } 55 }
@@ -64,13 +65,12 @@ void my_free(int *argc, char **newargv, char **argv) {
64#endif 65#endif
65 66
66int array_diff(int i1, char **a1, int i2, char **a2) { 67int array_diff(int i1, char **a1, int i2, char **a2) {
67 int i;
68
69 if (i1 != i2) { 68 if (i1 != i2) {
70 printf(" Argument count doesn't match!\n"); 69 printf(" Argument count doesn't match!\n");
71 return 0; 70 return 0;
72 } 71 }
73 for (i = 0; i <= i1; i++) { 72
73 for (int i = 0; i <= i1; i++) {
74 if (a1[i] == NULL && a2[i] == NULL) { 74 if (a1[i] == NULL && a2[i] == NULL) {
75 continue; 75 continue;
76 } 76 }
@@ -87,11 +87,10 @@ int array_diff(int i1, char **a1, int i2, char **a2) {
87} 87}
88 88
89int main(int argc, char **argv) { 89int main(int argc, char **argv) {
90 char **argv_new = NULL;
91 int i, argc_test;
92
93 plan_tests(5); 90 plan_tests(5);
94 91
92 char **argv_new = NULL;
93 int argc_test;
95 { 94 {
96 char *argv_test[] = {"prog_name", (char *)NULL}; 95 char *argv_test[] = {"prog_name", (char *)NULL};
97 argc_test = 1; 96 argc_test = 1;