Skip to content

Commit 6c18fd3

Browse files
jukkarnashif
authored andcommitted
net: sockets: Remove Posix header file includes
Do not include Posix header files inside network stack as we should not depend on Posix symbols in net stack. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 354e117 commit 6c18fd3

File tree

7 files changed

+17
-25
lines changed

7 files changed

+17
-25
lines changed

subsys/net/lib/sockets/socketpair.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <zephyr/kernel.h>
88
#include <zephyr/net/socket.h>
9-
#include <zephyr/posix/fcntl.h>
109
#include <zephyr/internal/syscall_handler.h>
1110
#include <zephyr/sys/__assert.h>
1211
#include <zephyr/sys/fdtable.h>
@@ -929,19 +928,19 @@ static int spair_ioctl(void *obj, unsigned int request, va_list args)
929928
have_local_sem = true;
930929

931930
switch (request) {
932-
case F_GETFL: {
931+
case ZVFS_F_GETFL: {
933932
if (sock_is_nonblock(spair)) {
934-
flags |= O_NONBLOCK;
933+
flags |= ZVFS_O_NONBLOCK;
935934
}
936935

937936
res = flags;
938937
goto out;
939938
}
940939

941-
case F_SETFL: {
940+
case ZVFS_F_SETFL: {
942941
flags = va_arg(args, int);
943942

944-
if (flags & O_NONBLOCK) {
943+
if (flags & ZVFS_O_NONBLOCK) {
945944
spair->flags |= SPAIR_FLAG_NONBLOCK;
946945
} else {
947946
spair->flags &= ~SPAIR_FLAG_NONBLOCK;

subsys/net/lib/sockets/sockets_can.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#include <stdbool.h>
9-
#include <zephyr/posix/fcntl.h>
109

1110
#include <zephyr/logging/log.h>
1211
LOG_MODULE_REGISTER(net_sock_can, CONFIG_NET_SOCKETS_LOG_LEVEL);

subsys/net/lib/sockets/sockets_inet.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LOG_MODULE_DECLARE(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL);
1919
#include <zephyr/tracing/tracing.h>
2020
#include <zephyr/net/socket.h>
2121
#include <zephyr/net/socket_types.h>
22-
#include <zephyr/posix/fcntl.h>
2322
#include <zephyr/sys/fdtable.h>
2423
#include <zephyr/sys/math_extras.h>
2524
#include <zephyr/sys/iterable_sections.h>
@@ -3045,19 +3044,19 @@ static int sock_ioctl_vmeth(void *obj, unsigned int request, va_list args)
30453044
switch (request) {
30463045

30473046
/* In Zephyr, fcntl() is just an alias of ioctl(). */
3048-
case F_GETFL:
3047+
case ZVFS_F_GETFL:
30493048
if (sock_is_nonblock(obj)) {
3050-
return O_NONBLOCK;
3049+
return ZVFS_O_NONBLOCK;
30513050
}
30523051

30533052
return 0;
30543053

3055-
case F_SETFL: {
3054+
case ZVFS_F_SETFL: {
30563055
int flags;
30573056

30583057
flags = va_arg(args, int);
30593058

3060-
if (flags & O_NONBLOCK) {
3059+
if (flags & ZVFS_O_NONBLOCK) {
30613060
sock_set_flag(obj, SOCK_NONBLOCK, SOCK_NONBLOCK);
30623061
} else {
30633062
sock_set_flag(obj, SOCK_NONBLOCK, 0);

subsys/net/lib/sockets/sockets_net_mgmt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#include <stdbool.h>
8-
#include <zephyr/posix/fcntl.h>
98

109
#include <zephyr/logging/log.h>
1110
LOG_MODULE_REGISTER(net_sock_mgmt, CONFIG_NET_SOCKETS_LOG_LEVEL);

subsys/net/lib/sockets/sockets_packet.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#include <stdbool.h>
9-
#include <zephyr/posix/fcntl.h>
109

1110
#include <zephyr/logging/log.h>
1211
LOG_MODULE_REGISTER(net_sock_packet, CONFIG_NET_SOCKETS_LOG_LEVEL);

subsys/net/lib/sockets/sockets_tls.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#include <stdbool.h>
9-
#include <zephyr/posix/fcntl.h>
109

1110
#include <zephyr/logging/log.h>
1211
LOG_MODULE_REGISTER(net_sock_tls, CONFIG_NET_SOCKETS_LOG_LEVEL);
@@ -797,13 +796,13 @@ static int wait_for_reason(int sock, int timeout, int reason)
797796

798797
static bool is_blocking(int sock, int flags)
799798
{
800-
int sock_flags = zsock_fcntl(sock, F_GETFL, 0);
799+
int sock_flags = zsock_fcntl(sock, ZVFS_F_GETFL, 0);
801800

802801
if (sock_flags == -1) {
803802
return false;
804803
}
805804

806-
return !((flags & ZSOCK_MSG_DONTWAIT) || (sock_flags & O_NONBLOCK));
805+
return !((flags & ZSOCK_MSG_DONTWAIT) || (sock_flags & ZVFS_O_NONBLOCK));
807806
}
808807

809808
static int timeout_to_ms(k_timeout_t *timeout)
@@ -2362,15 +2361,15 @@ int ztls_connect_ctx(struct tls_context *ctx, const struct net_sockaddr *addr,
23622361
int sock_flags;
23632362
bool is_non_block;
23642363

2365-
sock_flags = zsock_fcntl(ctx->sock, F_GETFL, 0);
2364+
sock_flags = zsock_fcntl(ctx->sock, ZVFS_F_GETFL, 0);
23662365
if (sock_flags < 0) {
23672366
return -EIO;
23682367
}
23692368

2370-
is_non_block = sock_flags & O_NONBLOCK;
2369+
is_non_block = sock_flags & ZVFS_O_NONBLOCK;
23712370
if (is_non_block) {
2372-
(void)zsock_fcntl(ctx->sock, F_SETFL,
2373-
sock_flags & ~O_NONBLOCK);
2371+
(void)zsock_fcntl(ctx->sock, ZVFS_F_SETFL,
2372+
sock_flags & ~ZVFS_O_NONBLOCK);
23742373
}
23752374

23762375
ret = zsock_connect(ctx->sock, addr, addrlen);
@@ -2379,7 +2378,7 @@ int ztls_connect_ctx(struct tls_context *ctx, const struct net_sockaddr *addr,
23792378
}
23802379

23812380
if (is_non_block) {
2382-
(void)zsock_fcntl(ctx->sock, F_SETFL, sock_flags);
2381+
(void)zsock_fcntl(ctx->sock, ZVFS_F_SETFL, sock_flags);
23832382
}
23842383

23852384
#if defined(CONFIG_NET_SOCKETS_ENABLE_DTLS)
@@ -3919,8 +3918,8 @@ static int tls_sock_ioctl_vmeth(void *obj, unsigned int request, va_list args)
39193918

39203919
switch (request) {
39213920
/* fcntl() commands */
3922-
case F_GETFL:
3923-
case F_SETFL: {
3921+
case ZVFS_F_GETFL:
3922+
case ZVFS_F_SETFL: {
39243923
const struct fd_op_vtable *vtable;
39253924
struct k_mutex *lock;
39263925
void *fd_obj;

tests/drivers/wifi/nrf_wifi/prj.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ CONFIG_REBOOT=y
5353
CONFIG_LOG=y
5454
CONFIG_PRINTK=y
5555
CONFIG_SHELL=y
56-
CONFIG_SHELL_GETOPT=y
5756
CONFIG_DEVICE_SHELL=y
5857
CONFIG_POSIX_TIMERS=y
5958
CONFIG_DATE_SHELL=y
6059
CONFIG_NET_CONFIG_AUTO_INIT=n
61-
CONFIG_POSIX_API=y
6260

6361
# printing of scan results puts pressure on queues in new locking
6462
# design in net_mgmt. So, use a higher timeout for a crowded

0 commit comments

Comments
 (0)