diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-09 14:04:58 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-09 14:22:32 +0000 |
commit | 3a975bd37b82a6e66a2cd5977544b03a6b24ce70 (patch) | |
tree | 24bf2f6cef03eeb84d2397868bbe50ff7bb08f56 | |
parent | 44477db354f67c4eacfced89fac5fbf3dbeaa3ff (diff) | |
download | busybox-w32-3a975bd37b82a6e66a2cd5977544b03a6b24ce70.tar.gz busybox-w32-3a975bd37b82a6e66a2cd5977544b03a6b24ce70.tar.bz2 busybox-w32-3a975bd37b82a6e66a2cd5977544b03a6b24ce70.zip |
win32: use open_read_close() where possible
-rw-r--r-- | win32/mingw.c | 8 | ||||
-rw-r--r-- | win32/process.c | 8 |
2 files changed, 4 insertions, 12 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index da77dee36..10169266d 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -327,7 +327,7 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd | |||
327 | */ | 327 | */ |
328 | static int has_exec_format(const char *name) | 328 | static int has_exec_format(const char *name) |
329 | { | 329 | { |
330 | int fd, n, sig; | 330 | int n, sig; |
331 | unsigned int offset; | 331 | unsigned int offset; |
332 | unsigned char buf[1024]; | 332 | unsigned char buf[1024]; |
333 | 333 | ||
@@ -336,11 +336,7 @@ static int has_exec_format(const char *name) | |||
336 | if (n > 4 && !strcasecmp(name+n-4, ".dll")) | 336 | if (n > 4 && !strcasecmp(name+n-4, ".dll")) |
337 | return 0; | 337 | return 0; |
338 | 338 | ||
339 | fd = open(name, O_RDONLY); | 339 | n = open_read_close(name, buf, sizeof(buf)); |
340 | if (fd < 0) | ||
341 | return 0; | ||
342 | n = read(fd, buf, sizeof(buf)-1); | ||
343 | close(fd); | ||
344 | if (n < 4) /* at least '#!/x' and not error */ | 340 | if (n < 4) /* at least '#!/x' and not error */ |
345 | return 0; | 341 | return 0; |
346 | 342 | ||
diff --git a/win32/process.c b/win32/process.c index f059bee18..20e73baee 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -55,13 +55,9 @@ static int | |||
55 | parse_interpreter(const char *cmd, interp_t *interp) | 55 | parse_interpreter(const char *cmd, interp_t *interp) |
56 | { | 56 | { |
57 | char *path, *t; | 57 | char *path, *t; |
58 | int n, fd; | 58 | int n; |
59 | 59 | ||
60 | fd = open(cmd, O_RDONLY); | 60 | n = open_read_close(cmd, interp->buf, sizeof(interp->buf)-1); |
61 | if (fd < 0) | ||
62 | return 0; | ||
63 | n = read(fd, interp->buf, sizeof(interp->buf)-1); | ||
64 | close(fd); | ||
65 | if (n < 4) /* at least '#!/x' and not error */ | 61 | if (n < 4) /* at least '#!/x' and not error */ |
66 | return 0; | 62 | return 0; |
67 | 63 | ||