Skip to content

Commit

Permalink
lib: remove obsolete brackets
Browse files Browse the repository at this point in the history
From review feedback.

Signed-off-by: Oliver Hartkopp <[email protected]>
  • Loading branch information
hartkopp committed Mar 6, 2024
1 parent 7905b63 commit 8e13140
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int parse_canframe(char *cs, cu_t *cu)
for (i = 0; i < 3; i++) {
if ((tmp = asc2nibble(cs[i])) > 0x0F)
return 0;
cu->cc.can_id |= (tmp << (2 - i) * 4);
cu->cc.can_id |= tmp << (2 - i) * 4;
}

} else if (cs[5] == CANID_DELIM) { /* 5 digits CAN XL VCID/PRIO*/
Expand All @@ -187,7 +187,7 @@ int parse_canframe(char *cs, cu_t *cu)
for (i = 0; i < 5; i++) {
if ((tmp = asc2nibble(cs[i])) > 0x0F)
return 0;
cu->xl.prio |= (tmp << (4 - i) * 4);
cu->xl.prio |= tmp << (4 - i) * 4;
}

/* the VCID starts at bit position 16 */
Expand All @@ -201,7 +201,7 @@ int parse_canframe(char *cs, cu_t *cu)
for (i = 0; i < 8; i++) {
if ((tmp = asc2nibble(cs[i])) > 0x0F)
return 0;
cu->cc.can_id |= (tmp << (7 - i) * 4);
cu->cc.can_id |= tmp << (7 - i) * 4;
}
if (!(cu->cc.can_id & CAN_ERR_FLAG)) /* 8 digits but no errorframe? */
cu->cc.can_id |= CAN_EFF_FLAG; /* then it is an extended frame */
Expand All @@ -227,7 +227,6 @@ int parse_canframe(char *cs, cu_t *cu)
}

if (cs[idx] == CANID_DELIM) { /* CAN FD frame escape char '##' */

maxdlen = CANFD_MAX_DLEN;
mtu = CANFD_MTU;

Expand All @@ -240,7 +239,6 @@ int parse_canframe(char *cs, cu_t *cu)
idx += 2;

} else if (cs[idx + 14] == CANID_DELIM) { /* CAN XL frame '#80:00:11223344#' */

maxdlen = CANXL_MAX_DLEN;
mtu = CANXL_MTU;
data = cu->xl.data; /* fill CAN XL data */
Expand All @@ -250,7 +248,7 @@ int parse_canframe(char *cs, cu_t *cu)

if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
cu->xl.flags = (tmp << 4);
cu->xl.flags = tmp << 4;
if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
cu->xl.flags |= tmp;
Expand All @@ -262,7 +260,7 @@ int parse_canframe(char *cs, cu_t *cu)

if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
cu->xl.sdt = (tmp << 4);
cu->xl.sdt = tmp << 4;
if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
cu->xl.sdt |= tmp;
Expand All @@ -272,7 +270,7 @@ int parse_canframe(char *cs, cu_t *cu)
for (i = 0; i < 8; i++) {
if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
cu->xl.af |= (tmp << (7 - i) * 4);
cu->xl.af |= tmp << (7 - i) * 4;
}

idx++; /* skip CANID_DELIM */
Expand All @@ -287,7 +285,7 @@ int parse_canframe(char *cs, cu_t *cu)

if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
data[i] = (tmp << 4);
data[i] = tmp << 4;
if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
return 0;
data[i] |= tmp;
Expand Down Expand Up @@ -362,7 +360,7 @@ int sprint_canframe(char *buf, cu_t *cu, int sep)
}

/* CAN CC frames may have RTR enabled. There are no ERR frames with RTR */
if (!(is_canfd) && cu->fd.can_id & CAN_RTR_FLAG) {
if (!is_canfd && cu->fd.can_id & CAN_RTR_FLAG) {
buf[offset++] = 'R';
/* print a given CAN 2.0B DLC if it's not zero */
if (len && len <= CAN_MAX_DLEN) {
Expand Down Expand Up @@ -399,7 +397,7 @@ int sprint_canframe(char *buf, cu_t *cu, int sep)
}

/* check for extra DLC when having a Classic CAN with 8 bytes payload */
if (!(is_canfd) && (len == CAN_MAX_DLEN)) {
if (!is_canfd && (len == CAN_MAX_DLEN)) {
unsigned char dlc = cu->cc.len8_dlc;

if ((dlc > CAN_MAX_DLEN) && (dlc <= CAN_MAX_RAW_DLC)) {
Expand Down Expand Up @@ -485,7 +483,7 @@ int sprint_long_canframe(char *buf, cu_t *cu, int view)
}

/* The len value is sanitized (see above) */
if (!(is_canfd)) {
if (!is_canfd) {
if (view & CANLIB_VIEW_LEN8_DLC) {
unsigned char dlc = cu->cc.len8_dlc;

Expand Down

0 comments on commit 8e13140

Please sign in to comment.