[PATCH] tests: add explicit permissions to open() call

7 views
Skip to first unread message

Khem Raj

unread,
Feb 26, 2020, 1:15:41 AM2/26/20
to libhug...@googlegroups.com, Khem Raj
Fixes
gethugepagesizes.c:227:35: error: open with O_CREAT in second argument needs 3 arguments
| fd = open(fname, O_WRONLY|O_CREAT);
| ^

Signed-off-by: Khem Raj <raj....@gmail.com>
---
tests/gethugepagesizes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/gethugepagesizes.c b/tests/gethugepagesizes.c
index 9551b38..5777265 100644
--- a/tests/gethugepagesizes.c
+++ b/tests/gethugepagesizes.c
@@ -223,7 +223,7 @@ void setup_fake_data(long sizes[], int n_elem)
FAIL("mkdtemp: %s", strerror(errno));

sprintf(fname, "%s/meminfo-none", fake_meminfo);
- fd = open(fname, O_WRONLY|O_CREAT);
+ fd = open(fname, O_WRONLY|O_CREAT, 0600);
if (fd < 0)
FAIL("open: %s", strerror(errno));
if (write(fd, meminfo_base,
@@ -233,7 +233,7 @@ void setup_fake_data(long sizes[], int n_elem)
FAIL("close: %s", strerror(errno));

sprintf(fname, "%s/meminfo-hugepages", fake_meminfo);
- fd = open(fname, O_WRONLY|O_CREAT);
+ fd = open(fname, O_WRONLY|O_CREAT, 0600);
if (fd < 0)
FAIL("open: %s", strerror(errno));
if (write(fd, meminfo_base,

Eric B Munson

unread,
Feb 26, 2020, 9:37:14 AM2/26/20
to Khem Raj, libhug...@googlegroups.com
On Tue, 25 Feb 2020, Khem Raj wrote:

> Fixes
> gethugepagesizes.c:227:35: error: open with O_CREAT in second argument needs 3 arguments
> | fd = open(fname, O_WRONLY|O_CREAT);
> | ^
>
> Signed-off-by: Khem Raj <raj....@gmail.com>

Applied, Thanks

Eric
Reply all
Reply to author
Forward
0 new messages