sample: sockets: can: Update error handle flow
This patch updates error handle flows for socket apis. Fix: #13859 Coverity-CID: 190956 Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
This commit is contained in:
parent
fa49e3e4c7
commit
4063b3b149
|
@ -110,9 +110,9 @@ static int setup_socket(void)
|
|||
|
||||
fd = socket(AF_CAN, SOCK_RAW, CAN_RAW);
|
||||
if (fd < 0) {
|
||||
ret = errno;
|
||||
LOG_ERR("Cannot create CAN socket (%d)", -ret);
|
||||
return -ret;
|
||||
ret = -errno;
|
||||
LOG_ERR("Cannot create CAN socket (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
can_addr.can_ifindex = net_if_get_by_iface(iface);
|
||||
|
@ -121,11 +121,16 @@ static int setup_socket(void)
|
|||
ret = bind(fd, (struct sockaddr *)&can_addr, sizeof(can_addr));
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG_ERR("Cannot bind CAN socket (%d)", -ret);
|
||||
LOG_ERR("Cannot bind CAN socket (%d)", ret);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
setsockopt(fd, SOL_CAN_RAW, CAN_RAW_FILTER, &filter, sizeof(filter));
|
||||
ret = setsockopt(fd, SOL_CAN_RAW, CAN_RAW_FILTER, &filter, sizeof(filter));
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG_ERR("Cannot set CAN sockopt (%d)", ret);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Delay TX startup so that RX is ready to receive */
|
||||
tx_tid = k_thread_create(&tx_data, tx_stack,
|
||||
|
|
Loading…
Reference in a new issue