summaryrefslogtreecommitdiff
path: root/nasmlib
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-05-15 13:20:38 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-05-15 13:20:38 -0700
commit1a254898e734366642f2aec0689b5795751ddf0b (patch)
tree891a2d650b07fd33f815702b82c9ec8b5d79776c /nasmlib
parent471120f48504300af5ace45f06980f6c049eb5b5 (diff)
downloadnasm-1a254898e734366642f2aec0689b5795751ddf0b.tar.gz
file.c: the "rb" os_fopen() flags are static in two places, simplify
We can still allocate these as a static array, just not a static string. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'nasmlib')
-rw-r--r--nasmlib/file.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/nasmlib/file.c b/nasmlib/file.c
index 55cfc372..2e662a19 100644
--- a/nasmlib/file.c
+++ b/nasmlib/file.c
@@ -216,6 +216,9 @@ FILE *nasm_open_write(const char *filename, enum file_flags flags)
return f;
}
+/* The appropriate "rb" strings for os_fopen() */
+static const os_fopenflag fopenflags_rb[3] = { 'r', 'b', 0 };
+
/*
* Report the existence of a file
*/
@@ -232,8 +235,7 @@ bool nasm_file_exists(const char *filename)
exists = os_access(osfname, R_OK) == 0;
#else
FILE *f;
-
- f = os_fopen(osfname, "rb");
+ f = os_fopen(osfname, fopenflags_rb);
exists = f != NULL;
if (f)
fclose(f);
@@ -292,18 +294,13 @@ off_t nasm_file_size_by_path(const char *pathname)
off_t len = -1;
os_struct_stat st;
FILE *fp;
- os_fopenflag fopen_flags[3];
osfname = os_mangle_filename(pathname);
if (!os_stat(osfname, &st) && S_ISREG(st.st_mode))
len = st.st_size;
- fopen_flags[0] = 'r';
- fopen_flags[1] = 'b';
- fopen_flags[2] = '\0';
-
- fp = os_fopen(osfname, fopen_flags);
+ fp = os_fopen(osfname, fopenflags_rb);
if (fp) {
len = nasm_file_size(fp);
fclose(fp);