Merge pull request #251 from neheb/clng

custom if statement reordering
This commit is contained in:
Marc Kleine-Budde
2020-10-13 08:55:34 +02:00
committed by GitHub
4 changed files with 21 additions and 22 deletions
+13 -10
View File
@@ -480,17 +480,20 @@ 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,
dplace = strlen(tmp2); tmp1) != 3)
if (verbose)
printf("decimal place %d, e.g. '%s'\n", dplace, tmp2);
if (dplace < 4 || dplace > 6) {
printf("invalid dplace %d (must be 4, 5 or 6)!\n", dplace);
return 1;
}
} else
continue; /* dplace remains zero until first found CAN frame */ continue; /* dplace remains zero until first found CAN frame */
}
dplace = strlen(tmp2);
if (verbose)
printf("decimal place %d, e.g. '%s'\n", dplace,
tmp2);
if (dplace < 4 || dplace > 6) {
printf("invalid dplace %d (must be 4, 5 or 6)!\n",
dplace);
return 1;
}
}
/* the representation of a valid CAN frame is known here */ /* the representation of a valid CAN frame is known here */
/* so try to get CAN frames and ErrorFrames and convert them */ /* so try to get CAN frames and ErrorFrames and convert them */
+2 -4
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) {
+4 -4
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 */
+2 -4
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) {