Skip to content

Commit

Permalink
drivers: nsos: add missing 'break' in switch statements
Browse files Browse the repository at this point in the history
There are 2-level switch statements (one switch inside another) which were
not properly terminated with 'break' statements, leading to implicit
fallthrough. Fix that.

Signed-off-by: Marcin Niestroj <[email protected]>
  • Loading branch information
mniestroj authored and nashif committed Jul 3, 2024
1 parent 0c1301e commit 248e54f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/nsos_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ int nsos_adapt_getsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
return nsos_adapt_getsockopt_int(fd, SOL_SOCKET, SO_KEEPALIVE,
nsos_mid_optval, nsos_mid_optlen);
}
break;

case NSOS_MID_IPPROTO_TCP:
switch (nsos_mid_optname) {
Expand All @@ -641,13 +642,15 @@ int nsos_adapt_getsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
return nsos_adapt_getsockopt_int(fd, IPPROTO_TCP, TCP_KEEPCNT,
nsos_mid_optval, nsos_mid_optlen);
}
break;

case NSOS_MID_IPPROTO_IPV6:
switch (nsos_mid_optname) {
case NSOS_MID_IPV6_V6ONLY:
return nsos_adapt_getsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY,
nsos_mid_optval, nsos_mid_optlen);
}
break;
}

return -NSOS_MID_EOPNOTSUPP;
Expand Down Expand Up @@ -727,6 +730,7 @@ int nsos_adapt_setsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
return nsos_adapt_setsockopt_int(fd, SOL_SOCKET, SO_KEEPALIVE,
nsos_mid_optval, nsos_mid_optlen);
}
break;

case NSOS_MID_IPPROTO_TCP:
switch (nsos_mid_optname) {
Expand All @@ -743,13 +747,15 @@ int nsos_adapt_setsockopt(int fd, int nsos_mid_level, int nsos_mid_optname,
return nsos_adapt_setsockopt_int(fd, IPPROTO_TCP, TCP_KEEPCNT,
nsos_mid_optval, nsos_mid_optlen);
}
break;

case NSOS_MID_IPPROTO_IPV6:
switch (nsos_mid_optname) {
case NSOS_MID_IPV6_V6ONLY:
return nsos_adapt_setsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY,
nsos_mid_optval, nsos_mid_optlen);
}
break;
}

return -NSOS_MID_EOPNOTSUPP;
Expand Down
6 changes: 6 additions & 0 deletions drivers/net/nsos_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ static int nsos_getsockopt(void *obj, int level, int optname,
NSOS_MID_SOL_SOCKET, NSOS_MID_SO_KEEPALIVE,
optval, optlen);
}
break;

case IPPROTO_TCP:
switch (optname) {
Expand All @@ -1115,6 +1116,7 @@ static int nsos_getsockopt(void *obj, int level, int optname,
NSOS_MID_IPPROTO_TCP, NSOS_MID_TCP_KEEPCNT,
optval, optlen);
}
break;

case IPPROTO_IPV6:
switch (optname) {
Expand All @@ -1123,6 +1125,7 @@ static int nsos_getsockopt(void *obj, int level, int optname,
NSOS_MID_IPPROTO_IPV6, NSOS_MID_IPV6_V6ONLY,
optval, optlen);
}
break;
}

errno = EOPNOTSUPP;
Expand Down Expand Up @@ -1261,6 +1264,7 @@ static int nsos_setsockopt(void *obj, int level, int optname,
NSOS_MID_SOL_SOCKET, NSOS_MID_SO_KEEPALIVE,
optval, optlen);
}
break;

case IPPROTO_TCP:
switch (optname) {
Expand All @@ -1281,6 +1285,7 @@ static int nsos_setsockopt(void *obj, int level, int optname,
NSOS_MID_IPPROTO_TCP, NSOS_MID_TCP_KEEPCNT,
optval, optlen);
}
break;

case IPPROTO_IPV6:
switch (optname) {
Expand All @@ -1289,6 +1294,7 @@ static int nsos_setsockopt(void *obj, int level, int optname,
NSOS_MID_IPPROTO_IPV6, NSOS_MID_IPV6_V6ONLY,
optval, optlen);
}
break;
}

errno = EOPNOTSUPP;
Expand Down

0 comments on commit 248e54f

Please sign in to comment.