custom if statement reordering
It makes more sense to return before hitting else. Signed-off-by: Rosen Penev <rosenp@gmail.com>pull/251/head
parent
7759b00c58
commit
f766174677
13
asc2log.c
13
asc2log.c
|
|
@ -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 */
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue