mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] libfile: open_and_lseek: don't imply O_RDONLY
@ 2018-08-09  8:33 Uwe Kleine-König
  2018-08-09  8:33 ` [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible Uwe Kleine-König
  2018-08-09  8:33 ` [PATCH 3/3] commands: teach commands that write to files to also create them Uwe Kleine-König
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2018-08-09  8:33 UTC (permalink / raw)
  To: barebox

There are several users that pass O_RDWR or O_WRONLY in mode to
open_and_lseek() and use the resulting file descriptor for writing. This
is no real issue becauce O_RDONLY is 0 and so can be dropped without
any side effects.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 lib/libfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index d22519b8f4bb..83c6399a5b39 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -501,7 +501,7 @@ int open_and_lseek(const char *filename, int mode, loff_t pos)
 {
 	int fd, ret;
 
-	fd = open(filename, mode | O_RDONLY);
+	fd = open(filename, mode);
 	if (fd < 0) {
 		perror("open");
 		return fd;
-- 
2.18.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-08-10  7:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09  8:33 [PATCH 1/3] libfile: open_and_lseek: don't imply O_RDONLY Uwe Kleine-König
2018-08-09  8:33 ` [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible Uwe Kleine-König
2018-08-10  6:22   ` Sascha Hauer
2018-08-10  7:14     ` Uwe Kleine-König
2018-08-09  8:33 ` [PATCH 3/3] commands: teach commands that write to files to also create them Uwe Kleine-König

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