some coverity fixes.
[minix.git] / lib / libc / sys-minix / fcntl.c
blob59c37a6528a5a6d78bfd95e0596aa10be506a904
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <fcntl.h>
6 #include <stdarg.h>
8 #ifdef __weak_alias
9 __weak_alias(fcntl, _fcntl)
10 #endif
12 int fcntl(int fd, int cmd, ...)
14 va_list argp;
15 message m;
17 va_start(argp, cmd);
19 /* Set up for the sensible case where there is no variable parameter. This
20 * covers F_GETFD, F_GETFL and invalid commands.
22 m.m1_i3 = 0;
23 m.m1_p1 = NULL;
25 /* Adjust for the stupid cases. */
26 switch(cmd) {
27 case F_DUPFD:
28 case F_SETFD:
29 case F_SETFL:
30 m.m1_i3 = va_arg(argp, int);
31 break;
32 case F_GETLK:
33 case F_SETLK:
34 case F_SETLKW:
35 case F_FREESP:
36 m.m1_p1 = (char *) va_arg(argp, struct flock *);
37 break;
40 /* Clean up and make the system call. */
41 va_end(argp);
42 m.m1_i1 = fd;
43 m.m1_i2 = cmd;
44 return(_syscall(VFS_PROC_NR, FCNTL, &m));