Skip to content

Commit 3653d62

Browse files
committed
TCP: Replace unnecessary comma operators
Use of comma as statement separator is discouraged and reported as warning by clang with -Wcomma. The use of ';' to separate two assignments is more appropriate than ','. The warnings were like: print-tcp.c:306:54: warning: possible misuse of comma operator here [-Wcomma] th->ack = seq, th->seq = ack - 1; ^
1 parent bb5ca2b commit 3653d62

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

print-tcp.c

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,21 @@ tcp_print(netdissect_options *ndo,
302302
"%s: calloc", __func__);
303303
}
304304
th->addr = tha;
305-
if (rev)
306-
th->ack = seq, th->seq = ack - 1;
307-
else
308-
th->seq = seq, th->ack = ack - 1;
305+
if (rev) {
306+
th->ack = seq;
307+
th->seq = ack - 1;
308+
} else {
309+
th->seq = seq;
310+
th->ack = ack - 1;
311+
}
309312
} else {
310-
if (rev)
311-
seq -= th->ack, ack -= th->seq;
312-
else
313-
seq -= th->seq, ack -= th->ack;
313+
if (rev) {
314+
seq -= th->ack;
315+
ack -= th->seq;
316+
} else {
317+
seq -= th->seq;
318+
ack -= th->ack;
319+
}
314320
}
315321

316322
thseq = th->seq;
@@ -360,15 +366,21 @@ tcp_print(netdissect_options *ndo,
360366
"%s: calloc", __func__);
361367
}
362368
th->addr = tha;
363-
if (rev)
364-
th->ack = seq, th->seq = ack - 1;
365-
else
366-
th->seq = seq, th->ack = ack - 1;
369+
if (rev) {
370+
th->ack = seq;
371+
th->seq = ack - 1;
372+
} else {
373+
th->seq = seq;
374+
th->ack = ack - 1;
375+
}
367376
} else {
368-
if (rev)
369-
seq -= th->ack, ack -= th->seq;
370-
else
371-
seq -= th->seq, ack -= th->ack;
377+
if (rev) {
378+
seq -= th->ack;
379+
ack -= th->seq;
380+
} else {
381+
seq -= th->seq;
382+
ack -= th->ack;
383+
}
372384
}
373385

374386
thseq = th->seq;

0 commit comments

Comments
 (0)