summaryrefslogtreecommitdiff
path: root/userland/minibox/utilities/cat.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-12-12 16:03:08 +0100
committerAnton Kling <anton@kling.gg>2024-12-12 16:03:08 +0100
commitb033314bf1901d436dc71d41d5e1f37dda47e511 (patch)
tree120bd137888a7f96904a47af7d20422608ffe225 /userland/minibox/utilities/cat.c
parentdcbcdbdc5bcfb86eca05fb655e3bf009d89e39e0 (diff)
formatting: Use clang-format on all projects
This commit also add braces to all `if` statements.
Diffstat (limited to 'userland/minibox/utilities/cat.c')
-rw-r--r--userland/minibox/utilities/cat.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/userland/minibox/utilities/cat.c b/userland/minibox/utilities/cat.c
index 736aee6..a425392 100644
--- a/userland/minibox/utilities/cat.c
+++ b/userland/minibox/utilities/cat.c
@@ -13,10 +13,12 @@
int fd_to_stdout(int fd) {
int rc;
for (char buffer[CAT_BUFFER]; (rc = read(fd, &buffer, sizeof(buffer)));) {
- if (-1 == rc)
+ if (-1 == rc) {
return 0;
- if (-1 == write(fd_stdout, buffer, rc))
+ }
+ if (-1 == write(fd_stdout, buffer, rc)) {
return 0;
+ }
}
return 1;
}
@@ -35,8 +37,9 @@ int cat_main(int argc, char **argv) {
// If a file is '-', the cat utility shall read from the standard
// input at that point in the sequence.
if (0 == strcmp(*argv, "-")) {
- if (!fd_to_stdout(0))
+ if (!fd_to_stdout(0)) {
return 1;
+ }
continue;
}
@@ -46,8 +49,9 @@ int cat_main(int argc, char **argv) {
perror(*argv);
return 1;
}
- if (!fd_to_stdout(fd))
+ if (!fd_to_stdout(fd)) {
return 1;
+ }
close(fd);
}
return 0;