custom if statement reordering

It makes more sense to return before hitting else.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2020-10-12 23:48:38 -07:00
parent 7759b00c58
commit f766174677
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 */
if (sscanf(buf, "%lu.%s %s ", &tmp_tv.tv_sec, tmp2, tmp1) == 3){
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;
}
} else
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);
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 */
/* so try to get CAN frames and ErrorFrames and convert them */