some coverity fixes.
[minix.git] / lib / libc / sys-minix / open.c
blob47dd6247741245031abb7f5c3273ddaba616eacb
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <fcntl.h>
6 #include <stdarg.h>
7 #include <string.h>
9 #ifdef __weak_alias
10 __weak_alias(open, _open)
11 #endif
13 int open(const char *name, int flags, ...)
15 va_list argp;
16 message m;
18 va_start(argp, flags);
19 if (flags & O_CREAT) {
20 m.m1_i1 = strlen(name) + 1;
21 m.m1_i2 = flags;
22 /* Since it's a vararg parameter that is smaller than
23 * an int, the mode was passed as an int.
25 m.m1_i3 = va_arg(argp, int);
26 m.m1_p1 = (char *) __UNCONST(name);
27 } else {
28 _loadname(name, &m);
29 m.m3_i2 = flags;
31 va_end(argp);
32 return (_syscall(VFS_PROC_NR, OPEN, &m));