Merge pull request #251 from neheb/clng

custom if statement reordering
pull/252/head
Marc Kleine-Budde 2020-10-13 08:55:34 +02:00 committed by GitHub
commit bda4b0ad8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
bs = frame.data[rx_ext+1];
stmin = frame.data[rx_ext+2];
} else
continue; continue;
bs = frame.data[rx_ext + 1];
stmin = frame.data[rx_ext + 2];
} }
/* 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) {