custom if statement reordering

It makes more sense to return before hitting else.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
pull/251/head
Rosen Penev 2020-10-12 23:46:58 -07:00
parent 7759b00c58
commit f766174677
No known key found for this signature in database
GPG Key ID: 36D31CFA845F0E3B
4 changed files with 21 additions and 22 deletions

View File

@ -480,16 +480,19 @@ int main(int argc, char **argv)
} }
/* check for decimal places length in valid CAN frames */ /* check for decimal places length in valid CAN frames */
if (sscanf(buf, "%lu.%s %s ", &tmp_tv.tv_sec, tmp2, tmp1) == 3){ if (sscanf(buf, "%lu.%s %s ", &tmp_tv.tv_sec, tmp2,
tmp1) != 3)
continue; /* dplace remains zero until first found CAN frame */
dplace = strlen(tmp2); dplace = strlen(tmp2);
if (verbose) if (verbose)
printf("decimal place %d, e.g. '%s'\n", dplace, tmp2); printf("decimal place %d, e.g. '%s'\n", dplace,
tmp2);
if (dplace < 4 || dplace > 6) { if (dplace < 4 || dplace > 6) {
printf("invalid dplace %d (must be 4, 5 or 6)!\n", dplace); printf("invalid dplace %d (must be 4, 5 or 6)!\n",
dplace);
return 1; return 1;
} }
} else
continue; /* dplace remains zero until first found CAN frame */
} }
/* the representation of a valid CAN frame is known here */ /* the representation of a valid CAN frame is known here */

View File

@ -197,11 +197,9 @@ int main(void)
while (1) { while (1) {
sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size); sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size);
if (sa > 0 ){ if (sa > 0 ){
if (!fork())
if (fork())
close(sa);
else
break; break;
close(sa);
} }
else { else {
if (errno != EINTR) { if (errno != EINTR) {

View File

@ -251,11 +251,11 @@ int main(int argc, char **argv)
n_pci = frame.data[rx_ext]; n_pci = frame.data[rx_ext];
/* check flow control PCI only */ /* check flow control PCI only */
if ((n_pci & 0xF0) == 0x30) { if ((n_pci & 0xF0) != 0x30)
continue;
bs = frame.data[rx_ext + 1]; bs = frame.data[rx_ext + 1];
stmin = frame.data[rx_ext + 2]; stmin = frame.data[rx_ext + 2];
} else
continue;
} }
/* data content starts and index datidx */ /* data content starts and index datidx */

View File

@ -317,11 +317,9 @@ int main(int argc, char **argv)
while (1) { while (1) {
sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size); sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size);
if (sa > 0 ){ if (sa > 0 ){
if (!fork())
if (fork())
close(sa);
else
break; break;
close(sa);
} }
else { else {
if (errno != EINTR) { if (errno != EINTR) {