mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! commands: cat: add support for concatenating into file
Date: Thu, 26 Feb 2026 10:40:30 +0100	[thread overview]
Message-ID: <20260226094031.1692607-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2026-02-26  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26  9:40 Ahmad Fatoum [this message]
2026-02-26 12:06 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260226094031.1692607-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox