Re: [PATCH] can: ucan: Correct the size parameter
From: Marc Kleine-Budde
Date: Tue Feb 18 2025 - 09:30:45 EST
On 18.02.2025 23:26:01, Vincent Mailhol wrote:
> >> @@ -1555,7 +1544,10 @@ static int ucan_probe(struct usb_interface *intf,
> >>
> >> /* initialisation complete, log device info */
> >> netdev_info(up->netdev, "registered device\n");
> >> - netdev_info(up->netdev, "firmware string: %s\n", firmware_str);
> >> + ucan_get_fw_info(up, up->ctl_msg_buffer->fw_info,
> >> + sizeof(up->ctl_msg_buffer->fw_info));
> >> + netdev_info(up->netdev, "firmware string: %s\n",
> >> + up->ctl_msg_buffer->fw_info);
> >
> > We could also use the:
> >
> > printf("%.*s", sizeof(up->ctl_msg_buffer->fw_info), up->ctl_msg_buffer->fw_info);
> >
> > format string trick to only print a limited number of chars of the given
> > string.
>
> Indeed. But after the renaming of ucan_device_request_in() into
> ucan_get_fw_info(), it makes slightly more sense to me to have this new
> function to handle the string NUL termination logic rather than to
> deffer it to the format string.
ACK, makes sense!
> But thanks for the suggestion.
>
> > But I'm also fine with your solution. Either way, please send a
> > proper patch :)
>
> Will do so right now!
Thanks,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature