| File: | src/fcntl/fcntl.c |
| Location: | line 22, column 18 |
| Description: | The left operand of '==' is a garbage value |
| 1 | #define _GNU_SOURCE | |||
| 2 | #include <fcntl.h> | |||
| 3 | #include <stdarg.h> | |||
| 4 | #include <errno(*__errno_location()).h> | |||
| 5 | #include "syscall.h" | |||
| 6 | #include "libc.h" | |||
| 7 | ||||
| 8 | int fcntl(int fd, int cmd, ...) | |||
| 9 | { | |||
| 10 | unsigned long arg; | |||
| 11 | va_list ap; | |||
| 12 | va_start(ap, cmd)__builtin_va_start(ap,cmd); | |||
| 13 | arg = va_arg(ap, unsigned long)__builtin_va_arg(ap,unsigned long); | |||
| 14 | va_end(ap)__builtin_va_end(ap); | |||
| 15 | if (cmd == F_SETFL4) arg |= O_LARGEFILE0400000; | |||
| ||||
| 16 | if (cmd == F_SETLKW14) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg)__syscall_ret((__syscall_cp)(221,((long) (fd)),((long) (cmd)) ,((long) ((void *)arg)),0,0,0)); | |||
| 17 | if (cmd == F_GETOWN9) { | |||
| 18 | struct f_owner_ex ex; | |||
| 19 | int ret = __syscall(SYS_fcntl, fd, F_GETOWN_EX, &ex)__syscall3(221,((long) (fd)),((long) (16)),((long) (&ex)) ); | |||
| 20 | if (ret == -EINVAL22) return __syscall(SYS_fcntl, fd, cmd, (void *)arg)__syscall3(221,((long) (fd)),((long) (cmd)),((long) ((void *) arg))); | |||
| 21 | if (ret) return __syscall_ret(ret); | |||
| 22 | return ex.type == F_OWNER_PGRP2 ? -ex.pid : ex.pid; | |||
| ||||
| 23 | } | |||
| 24 | if (cmd == F_DUPFD_CLOEXEC1030) { | |||
| 25 | int ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, arg)__syscall3(221,((long) (fd)),((long) (1030)),((long) (arg))); | |||
| 26 | if (ret != -EINVAL22) { | |||
| 27 | if (ret >= 0) | |||
| 28 | __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC)__syscall3(221,((long) (ret)),((long) (2)),((long) (1))); | |||
| 29 | return __syscall_ret(ret); | |||
| 30 | } | |||
| 31 | ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, 0)__syscall3(221,((long) (fd)),((long) (1030)),((long) (0))); | |||
| 32 | if (ret != -EINVAL22) { | |||
| 33 | if (ret >= 0) __syscall(SYS_close, ret)__syscall1(6,((long) (ret))); | |||
| 34 | return __syscall_ret(-EINVAL22); | |||
| 35 | } | |||
| 36 | ret = __syscall(SYS_fcntl, fd, F_DUPFD, arg)__syscall3(221,((long) (fd)),((long) (0)),((long) (arg))); | |||
| 37 | if (ret >= 0) __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC)__syscall3(221,((long) (ret)),((long) (2)),((long) (1))); | |||
| 38 | return __syscall_ret(ret); | |||
| 39 | } | |||
| 40 | switch (cmd) { | |||
| 41 | case F_SETLK13: | |||
| 42 | case F_GETLK12: | |||
| 43 | case F_GETOWN_EX16: | |||
| 44 | case F_SETOWN_EX15: | |||
| 45 | return syscall(SYS_fcntl, fd, cmd, (void *)arg)__syscall_ret(__syscall3(221,((long) (fd)),((long) (cmd)),((long ) ((void *)arg)))); | |||
| 46 | default: | |||
| 47 | return syscall(SYS_fcntl, fd, cmd, arg)__syscall_ret(__syscall3(221,((long) (fd)),((long) (cmd)),((long ) (arg)))); | |||
| 48 | } | |||
| 49 | } |