Skip to content

Commit b5cfd9a

Browse files
pfalconnashif
authored andcommitted
net: context: Operations on unused context should lead to EBADF.
Semantics of ENOENT error as used previously is "named entity not found", whereas for "I/O handle is not valid", there's EBADF. For example, POSIX/SUSV2 doesn't even list ENOENT as a possible error for accept(), connect(), recv(), etc. whereas it lists EBADF, e.g.: http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html Signed-off-by: Paul Sokolovsky <[email protected]>
1 parent 078bf1c commit b5cfd9a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

subsys/net/ip/net_context.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ int net_context_listen(struct net_context *context, int backlog)
646646
NET_ASSERT(PART_OF_ARRAY(contexts, context));
647647

648648
if (!net_context_is_used(context)) {
649-
return -ENOENT;
649+
return -EBADF;
650650
}
651651

652652
#if defined(CONFIG_NET_OFFLOAD)
@@ -1064,7 +1064,7 @@ int net_context_connect(struct net_context *context,
10641064
#endif
10651065

10661066
if (!net_context_is_used(context)) {
1067-
return -ENOENT;
1067+
return -EBADF;
10681068
}
10691069

10701070
if (addr->family != net_context_get_family(context)) {
@@ -1577,7 +1577,7 @@ int net_context_accept(struct net_context *context,
15771577
NET_ASSERT(PART_OF_ARRAY(contexts, context));
15781578

15791579
if (!net_context_is_used(context)) {
1580-
return -ENOENT;
1580+
return -EBADF;
15811581
}
15821582

15831583
#if defined(CONFIG_NET_OFFLOAD)
@@ -1748,7 +1748,7 @@ static int sendto(struct net_pkt *pkt,
17481748
int ret;
17491749

17501750
if (!net_context_is_used(context)) {
1751-
return -ENOENT;
1751+
return -EBADF;
17521752
}
17531753

17541754
#if defined(CONFIG_NET_TCP)
@@ -2051,7 +2051,7 @@ int net_context_recv(struct net_context *context,
20512051
NET_ASSERT(context);
20522052

20532053
if (!net_context_is_used(context)) {
2054-
return -ENOENT;
2054+
return -EBADF;
20552055
}
20562056

20572057
#if defined(CONFIG_NET_OFFLOAD)

0 commit comments

Comments
 (0)