Skip to content

Commit

Permalink
caif: move from strlcpy with unused retval to strscpy
Browse files Browse the repository at this point in the history
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Wolfram Sang authored and kuba-moo committed Aug 23, 2022
1 parent 993e163 commit df207b0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion net/caif/caif_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ int caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
mutex_lock(&caifdevs->lock);
list_add_rcu(&caifd->list, &caifdevs->list);

strlcpy(caifd->layer.name, dev->name,
strscpy(caifd->layer.name, dev->name,
sizeof(caifd->layer.name));
caifd->layer.transmit = transmit;
res = cfcnfg_add_phy_layer(cfg,
Expand Down
2 changes: 1 addition & 1 deletion net/caif/caif_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static int cfusbl_device_notify(struct notifier_block *me, unsigned long what,
dev_add_pack(&caif_usb_type);
pack_added = true;

strlcpy(layer->name, dev->name, sizeof(layer->name));
strscpy(layer->name, dev->name, sizeof(layer->name));

return 0;
err:
Expand Down
4 changes: 2 additions & 2 deletions net/caif/cfcnfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ static int caif_connect_req_to_link_param(struct cfcnfg *cnfg,
case CAIFPROTO_RFM:
l->linktype = CFCTRL_SRV_RFM;
l->u.datagram.connid = s->sockaddr.u.rfm.connection_id;
strlcpy(l->u.rfm.volume, s->sockaddr.u.rfm.volume,
strscpy(l->u.rfm.volume, s->sockaddr.u.rfm.volume,
sizeof(l->u.rfm.volume));
break;
case CAIFPROTO_UTIL:
l->linktype = CFCTRL_SRV_UTIL;
l->endpoint = 0x00;
l->chtype = 0x00;
strlcpy(l->u.utility.name, s->sockaddr.u.util.service,
strscpy(l->u.utility.name, s->sockaddr.u.util.service,
sizeof(l->u.utility.name));
caif_assert(sizeof(l->u.utility.name) > 10);
l->u.utility.paramlen = s->param.size;
Expand Down
2 changes: 1 addition & 1 deletion net/caif/cfctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ int cfctrl_linkup_request(struct cflayer *layer,
tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs);
cfpkt_add_body(pkt, &tmp16, 2);
memset(utility_name, 0, sizeof(utility_name));
strlcpy(utility_name, param->u.utility.name,
strscpy(utility_name, param->u.utility.name,
UTILITY_NAME_LENGTH);
cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH);
tmp8 = param->u.utility.paramlen;
Expand Down

0 comments on commit df207b0

Please sign in to comment.