Re: [PATCH v2 08/12] util: hash: Don't use 'const' with virHashTablePtr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 11/5/20 12:26 PM, Peter Krempa wrote:
On Thu, Nov 05, 2020 at 10:50:23 -0300, Daniel Henrique Barboza wrote:


On 11/4/20 2:05 PM, Peter Krempa wrote:
We didn't use it rigorously and some helpers even cast it away. Remove
const from all hash utility functions.

Unrelated question: how much do we care about standardizing a bit the
'const' usage in the code? I for one had to rely on casting to satisfy
the conditions of "const" variables, that most of time are created because
some functions requires  a "const" argument.


[...]


But in this case you again get the payload pointer which you can modify.

In general C's const keyword is a hint for the programmer at best, in
many cases it doesn't do what you want and specifically in case of
structs it doesn't guarantee that the internals can't be changed, so I'd
not really bother that much with being rigorous in this regards.


It's also easier to deal without 'const' here and there in the code. I mean,
as you said, it's more of a hint to the developer. One that comes with the
cost of adding casts here and there when needed.

Thanks for the reply. Guess I'll keep an eye for the 'const' cases I come
across from now on and see if it can be removed/simplified.



DHB




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux