Skip to content

Commit 25e27e3

Browse files
committed
[nrf fromlist] zperf: moving declaration of variable to top of function
Declaration of variables after a label inside a switch statement is a c23 extension, not c99. This results in the following warning when compiling with clang: > .../subsys/net/lib/zperf/zperf_shell.c:912:4: warning: label followed > by a declaration is a C23 extension [-Wc23-extensions] > 912 | int seconds = parse_arg(&i, argc, argv); > | ^ > .../subsys/net/lib/zperf/zperf_shell.c:1145:4: warning: label followed > by a declaration is a C23 extension [-Wc23-extensions] > 1145 | int seconds = parse_arg(&i, argc, argv); > | ^ > 2 warnings generated. There are no practical reasons why the variable should be declared inside the switch statement, therefore move the declaration and place it together with declaration of other variables. Upstream PR #: 88403 Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 8e6457e commit 25e27e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/net/lib/zperf/zperf_shell.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
842842
int start = 0;
843843
size_t opt_cnt = 0;
844844
int ret;
845+
int seconds;
845846

846847
param.options.priority = -1;
847848
is_udp = proto == IPPROTO_UDP;
@@ -909,7 +910,7 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
909910
break;
910911

911912
case 'i':
912-
int seconds = parse_arg(&i, argc, argv);
913+
seconds = parse_arg(&i, argc, argv);
913914

914915
if (is_udp) {
915916
shell_fprintf(sh, SHELL_WARNING,
@@ -1076,6 +1077,7 @@ static int shell_cmd_upload2(const struct shell *sh, size_t argc,
10761077
bool async = false;
10771078
int start = 0;
10781079
size_t opt_cnt = 0;
1080+
int seconds;
10791081

10801082
is_udp = proto == IPPROTO_UDP;
10811083

@@ -1142,7 +1144,7 @@ static int shell_cmd_upload2(const struct shell *sh, size_t argc,
11421144
break;
11431145

11441146
case 'i':
1145-
int seconds = parse_arg(&i, argc, argv);
1147+
seconds = parse_arg(&i, argc, argv);
11461148

11471149
if (is_udp) {
11481150
shell_fprintf(sh, SHELL_WARNING,

0 commit comments

Comments
 (0)