Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35827 )
Change subject: drivers/pc80/rtc: Cache cmos_layout.bin region device ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35827/3/src/drivers/pc80/rtc/mc1468... File src/drivers/pc80/rtc/mc146818rtc.c:
https://review.coreboot.org/c/coreboot/+/35827/3/src/drivers/pc80/rtc/mc1468... PS3, Line 278: rdev = car_get_ptr(layout_rdev_p);
(I guess I should start a discussion about declaring `const` what can be declared `const`. This wouldn't have happened if `rdev` were immu- table.)
Nico, what did you mean by this specifically? I'm not following on the specifics.
We could generally make more use of the `const` keyword. Newer languages have actually inverted the concept, e.g. in Rust you have to explicitly declare a variable mutable if you don't want it to be `const`, and I concur. I feel like I've seen many bugs that could have been prevented if the original intention never to change a variable's (or even more often parameter's) value would have been enforced. It also makes code easier to read, IMHO, if one knows that they don't have to track the current state of a `variable`.
I haven't looked into it, maybe there is a compiler warning for that yet (e.g. "... could be declared const but isn't"). If not, I have no clue how we could enforce such a rule...