]> granicus.if.org Git - esp-idf/commitdiff
vfs: change fcntl argument to int (instead of va_list), add weak fcntl
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 11 Mar 2019 09:45:31 +0000 (17:45 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 19 Mar 2019 13:44:17 +0000 (21:44 +0800)
components/lwip/port/esp32/vfs_lwip.c
components/vfs/include/esp_vfs.h
components/vfs/vfs.c
components/vfs/vfs_uart.c

index 54d71912bb85230a9975ef04f41e6e1cc3580503..3610d2e175e44d2e4ebf9ac3dad83f93ac15cc7b 100644 (file)
@@ -40,9 +40,9 @@ static void lwip_stop_socket_select_isr(BaseType_t *woken)
     }
 }
 
-static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args)
+static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg)
 {
-    return lwip_fcntl_r(fd, cmd, va_arg(args, int));
+    return lwip_fcntl_r(fd, cmd, arg);
 }
 
 static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args)
index e383c4363237e66f9612f9b4264a263f1c2dc61c..49387dc5ff2aaa065948d7d5cf8aff5ccf4e3c28 100644 (file)
@@ -163,8 +163,8 @@ typedef struct
         int (*rmdir)(const char* name);
     };
     union {
-        int (*fcntl_p)(void* ctx, int fd, int cmd, va_list args);
-        int (*fcntl)(int fd, int cmd, va_list args);
+        int (*fcntl_p)(void* ctx, int fd, int cmd, int arg);
+        int (*fcntl)(int fd, int cmd, int arg);
     };
     union {
         int (*ioctl_p)(void* ctx, int fd, int cmd, va_list args);
index 45633cd03ab2366bd91e64940b0cda6076a90e32..61a8f706594c1a7bf43a942f596b6ad9c2543991 100644 (file)
@@ -657,21 +657,27 @@ int rmdir(const char* name)
     return ret;
 }
 
-int fcntl(int fd, int cmd, ...)
+int _fcntl_r(struct _reent *r, int fd, int cmd, int arg)
 {
     const vfs_entry_t* vfs = get_vfs_for_fd(fd);
     const int local_fd = get_local_fd(vfs, fd);
-    struct _reent* r = __getreent();
     if (vfs == NULL || local_fd < 0) {
         __errno_r(r) = EBADF;
         return -1;
     }
     int ret;
+    CHECK_AND_CALL(ret, r, vfs, fcntl, local_fd, cmd, arg);
+    return ret;
+}
+
+int __attribute__((weak)) fcntl(int fd, int cmd, ...)
+{
     va_list args;
     va_start(args, cmd);
-    CHECK_AND_CALL(ret, r, vfs, fcntl, local_fd, cmd, args);
+    int arg = va_arg(args, int);
     va_end(args);
-    return ret;
+    struct _reent* r = __getreent();
+    return _fcntl_r(r, fd, cmd, arg);
 }
 
 int ioctl(int fd, int cmd, ...)
index ebff91a879fe85771fc57ad0af552487894bef58..62308e424a5d5c9802c75764476badfa2fe4b624 100644 (file)
@@ -265,7 +265,7 @@ static int uart_close(int fd)
     return 0;
 }
 
-static int uart_fcntl(int fd, int cmd, va_list args)
+static int uart_fcntl(int fd, int cmd, int arg)
 {
     assert(fd >=0 && fd < 3);
     int result = 0;
@@ -274,7 +274,6 @@ static int uart_fcntl(int fd, int cmd, va_list args)
             result |= O_NONBLOCK;
         }
     } else if (cmd == F_SETFL) {
-        int arg = va_arg(args, int);
         s_non_blocking[fd] = (arg & O_NONBLOCK) != 0;
     } else {
         // unsupported operation