Eric Blake wrote:
While this indeed accesses a parameter not passed by the caller, it is a
harmless access.
Although this is true on all practical platforms, in theory a POSIX
implementation could have trouble with this implementation. Frank, does the
attached (untested) patch pacify KLEE?
diff --git a/lib/fcntl.c b/lib/fcntl.c
index be6583565..d12997c3c 100644
--- a/lib/fcntl.c
+++ b/lib/fcntl.c
@@ -394,6 +394,21 @@ rpl_fcntl (int fd, int action, /* arg */...)
} /* F_GETFD */
#endif /* !HAVE_FCNTL */
+#if HAVE_FCNTL
+ case F_GETFD:
+ case F_GETFL:
+# ifdef F_GETLEASE
+ case F_GETLEASE:
+# endif
+ case F_GETOWN:
+# ifdef F_GETSIG
+ case F_GETSIG:
+# endif
+ /* Call fcntl without a trailing arg, to pacify static checkers. */
+ result = fcntl (fd, action);
+ break;
+#endif
+
/* Implementing F_SETFD on mingw is not trivial - there is no
API for changing the O_NOINHERIT bit on an fd, and merely
changing the HANDLE_FLAG_INHERIT bit on the underlying handle
@@ -405,6 +420,8 @@ rpl_fcntl (int fd, int action, /* arg */...)
default:
{
#if HAVE_FCNTL
+ /* Pass a pointer as a trailing argument. Although this is
+ not strictly kosher in theory, in practice it's good enough. */
void *p = va_arg (arg, void *);
result = fcntl (fd, action, p);
#else