]> git.ipfire.org Git - pakfire.git/commitdiff
tests: Have pipe return an error if it could not write
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 12:33:31 +0000 (12:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 12:33:31 +0000 (12:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/stub/command.c

index 3656ce391d92aad87deacd8863f741f5962a96c9..9fdcce41c80037f7be9ebb097ec205d2dce3096a 100644 (file)
@@ -358,15 +358,17 @@ static int _pipe(int argc, char* argv[]) {
 
                // Write the character to stdout
                r = fputc(c, stdout);
-               if (r == EOF) {
-                       fprintf(stderr, "Could not write to stdout: %m\n");
-                       break;
-               }
+               switch (r) {
+                       case EOF:
+                               fprintf(stderr, "Could not write to stdout: %m\n");
+                               return 1;
 
-               r = 0;
+                       default:
+                               break;
+               }
        }
 
-       return r;
+       return 0;
 }
 
 /*