Skip to content

Commit

Permalink
mesa_uart: fix unreachable error check code.
Browse files Browse the repository at this point in the history
  • Loading branch information
andypugh committed Feb 6, 2025
1 parent 55fb1a0 commit 2bf8cfc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/hal/drivers/mesa-hostmot2/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,29 @@ int hm2_uart_read(char *name, unsigned char data[])
case 1:
r = hm2->llio->read(hm2->llio, hm2->uart.instance[inst].rx1_addr,
&buff, sizeof(rtapi_u32));
if (r < 0) {
HM2_ERR("UART READ: hm2->llio->read failure %s\n", name);
return r;
}
data[c] = (buff & 0x000000FF);
return c + 1;
case 2:
r = hm2->llio->read(hm2->llio, hm2->uart.instance[inst].rx2_addr,
&buff, sizeof(rtapi_u32));
if (r < 0) {
HM2_ERR("UART READ: hm2->llio->read failure %s\n", name);
return r;
}
data[c] = (buff & 0x000000FF);
data[c+1] = (buff & 0x0000FF00) >> 8;
return c + 2;
case 3:
r = hm2->llio->read(hm2->llio, hm2->uart.instance[inst].rx3_addr,
&buff, sizeof(rtapi_u32));
if (r < 0) {
HM2_ERR("UART READ: hm2->llio->read failure %s\n", name);
return r;
}
data[c] = (buff & 0x000000FF);
data[c+1] = (buff & 0x0000FF00) >> 8;
data[c+2] = (buff & 0x00FF0000) >> 16;
Expand All @@ -334,12 +346,6 @@ int hm2_uart_read(char *name, unsigned char data[])
HM2_ERR("UART READ: Error in buffer parsing.\n");
return -EINVAL;
}
/* FIXME: Unreachable. Should be checked after assignment of 'r' above.
if (r < 0) {
HM2_ERR("UART READ: hm2->llio->write failure %s\n", name);
return -EINVAL;
}
*/
}

void hm2_uart_print_module(hostmot2_t *hm2){
Expand Down

0 comments on commit 2bf8cfc

Please sign in to comment.