mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: Make LWIP_SOCKET_OFFSET signed, remove need for underflow check
This reverts commit 541493d877
.
This commit is contained in:
parent
22756b6c02
commit
e5ae0f5927
@ -431,9 +431,9 @@ typedef struct ip_mreq {
|
||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FDSETSAFESET(n, code) do { \
|
||||
if (n >= LWIP_SOCKET_OFFSET && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
#define FDSETSAFEGET(n, code) (n >= LWIP_SOCKET_OFFSET && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||
#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||
(code) : 0)
|
||||
#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
/* Internal declarations used to ingreate LWIP port layer
|
||||
to ESP-IDF VFS for POSIX I/O.
|
||||
*/
|
||||
extern unsigned lwip_socket_offset;
|
||||
extern int lwip_socket_offset;
|
||||
|
||||
void esp_vfs_lwip_sockets_register();
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
FDs that the user sees are the same FDs.
|
||||
*/
|
||||
|
||||
unsigned lwip_socket_offset;
|
||||
int lwip_socket_offset;
|
||||
|
||||
static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args);
|
||||
static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args);
|
||||
@ -54,14 +54,14 @@ void esp_vfs_lwip_sockets_register()
|
||||
.fcntl = &lwip_fcntl_r_wrapper,
|
||||
.ioctl = &lwip_ioctl_r_wrapper,
|
||||
};
|
||||
unsigned max_fd;
|
||||
int max_fd;
|
||||
|
||||
ESP_ERROR_CHECK(esp_vfs_register_socket_space(&vfs, NULL, &lwip_socket_offset, &max_fd));
|
||||
|
||||
/* LWIP can't be allowed to create more sockets than fit in the per-VFS fd space. Currently this isn't configurable
|
||||
* but it's set much larger than CONFIG_LWIP_MAX_SOCKETS should ever be (max 2^12 FDs).
|
||||
*/
|
||||
assert(CONFIG_LWIP_MAX_SOCKETS <= max_fd - lwip_socket_offset);
|
||||
assert(max_fd >= lwip_socket_offset && CONFIG_LWIP_MAX_SOCKETS <= max_fd - lwip_socket_offset);
|
||||
}
|
||||
|
||||
static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args)
|
||||
|
@ -205,7 +205,7 @@ esp_err_t esp_vfs_register(const char* base_path, const esp_vfs_t* vfs, void* ct
|
||||
* @return ESP_OK if successful, ESP_ERR_NO_MEM if too many VFSes are
|
||||
* registered.
|
||||
*/
|
||||
esp_err_t esp_vfs_register_socket_space(const esp_vfs_t *vfs, void *ctx, unsigned *p_min_fd, unsigned *p_max_fd);
|
||||
esp_err_t esp_vfs_register_socket_space(const esp_vfs_t *vfs, void *ctx, int *p_min_fd, int *p_max_fd);
|
||||
|
||||
/**
|
||||
* Unregister a virtual filesystem for given path prefix
|
||||
|
@ -54,7 +54,7 @@ typedef struct vfs_entry_ {
|
||||
static vfs_entry_t* s_vfs[VFS_MAX_COUNT] = { 0 };
|
||||
static size_t s_vfs_count = 0;
|
||||
|
||||
static esp_err_t esp_vfs_register_common(const char* base_path, size_t len, const esp_vfs_t* vfs, void* ctx, unsigned *p_minimum_fd, unsigned *p_maximum_fd)
|
||||
static esp_err_t esp_vfs_register_common(const char* base_path, size_t len, const esp_vfs_t* vfs, void* ctx, int *p_minimum_fd, int *p_maximum_fd)
|
||||
{
|
||||
if (len != LEN_PATH_PREFIX_IGNORED) {
|
||||
if ((len != 0 && len < 2) || (len > ESP_VFS_PATH_MAX)) {
|
||||
@ -107,7 +107,7 @@ esp_err_t esp_vfs_register(const char* base_path, const esp_vfs_t* vfs, void* ct
|
||||
return esp_vfs_register_common(base_path, strlen(base_path), vfs, ctx, NULL, NULL);
|
||||
}
|
||||
|
||||
esp_err_t esp_vfs_register_socket_space(const esp_vfs_t *vfs, void *ctx, unsigned *p_min_fd, unsigned *p_max_fd)
|
||||
esp_err_t esp_vfs_register_socket_space(const esp_vfs_t *vfs, void *ctx, int *p_min_fd, int *p_max_fd)
|
||||
{
|
||||
return esp_vfs_register_common("", LEN_PATH_PREFIX_IGNORED, vfs, ctx, p_min_fd, p_max_fd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user