Re: [PATCH RFC 1/3] can: calc_bittiming: get rid of the incorrect "nominal" word

From: Marc Kleine-Budde
Date: Mon Nov 17 2025 - 11:35:24 EST


On 17.11.2025 16:32:31, Stéphane Grosjean wrote:
> > >> static int
> > >> can_update_sample_point(const struct can_bittiming_const *btc,
> > >> - const unsigned int sample_point_nominal, const unsigned int
> > >> tseg,
> > >> + unsigned int sp_origin, unsigned int tseg,
> > >
> > > Please don't remove the "const".
> > I always considered it silly to tag a scalar parameter as const.
> > Because C
> > passes the function argument by value, it is pretty meaningless.
>
> The "const" attribute means that the parameter cannot be used on the
> left side of an assignment in its block. Even if this parameter is not
> an input/output parameter, without “const” it can be modified within
> the function, just like a local variable (which it is, since it is
> theoretically also declared on the stack). Explicitly stating “const”
> is a strong indicator that the value cannot be modified in the block
> imho.

...and this is exactly what I want to express, because it's the
reference value.

regards,
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