mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fixup! commands: cat: add support for concatenating into file
@ 2026-02-26  9:40 Ahmad Fatoum
  2026-02-26 12:06 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-02-26  9:40 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

commands: cat: move mode flags to open call with O_CREAT

To placate static analysis, 0666 was added to the open call, but at the
wrong callsite: It should be added for the open that has O_CREAT as
open flag.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 commands/cat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/cat.c b/commands/cat.c
index e29d39225c71..57cf532fac24 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -55,7 +55,7 @@ static int do_cat(int argc, char *argv[])
 		return COMMAND_ERROR_USAGE;
 
 	if (outfile) {
-		outfd = open(outfile, oflags);
+		outfd = open(outfile, oflags, 0666);
 		if (outfd < 0) {
 			perror("open");
 			return 1;
@@ -65,7 +65,7 @@ static int do_cat(int argc, char *argv[])
 	buf = xmalloc(BUFSIZE);
 
 	for (int args = 0; args < argc; args++) {
-		fd = open(argv[args], O_RDONLY, 0666);
+		fd = open(argv[args], O_RDONLY);
 		if (fd < 0) {
 			err = 1;
 			printf("could not open %s: %m\n", argv[args]);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-26 12:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26  9:40 [PATCH] fixup! commands: cat: add support for concatenating into file Ahmad Fatoum
2026-02-26 12:06 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox