minisketch icon indicating copy to clipboard operation
minisketch copied to clipboard

refactor: remove all c style casts in minisketch subtree

Open PastaPastaPasta opened this issue 3 years ago • 8 comments

A part of https://github.com/bitcoin/bitcoin/pull/23810

PastaPastaPasta avatar Dec 18 '21 05:12 PastaPastaPasta

I don't really see the point of using C++ style casts for integer types, as C-style casts are equivalent for those anyway.

sipa avatar Dec 18 '21 05:12 sipa

I don't really see the point of using C++ style casts for integer types, as C-style casts are equivalent for those anyway.

Yeah, if we could use C style casts for only integer types I'd be totally happy. The problem comes when using C style casts with more complex (and potentially dangerous) types.

The main reason for this PR, is that it allows us to use tooling (see -Wold-style-cast) to prevent, in Bitcoin Core or other libraries that use minisketch, the dangerous usage of C style casts. If you look at the bitcoin PR, I replaced a LOT of C style casts that were acting as a reinterpret_cast as opposed to a normal static_cast.

I speak more about the benefits of this change / enforcement of no C style casts in the bitcoin PR

PastaPastaPasta avatar Dec 18 '21 05:12 PastaPastaPasta

I know nothing about the build system, but I think it is possible to disable warnings for subtrees?

maflcko avatar Dec 18 '21 08:12 maflcko

Please see latest @sipa

I have replaced non-narrowing static_casts (I introduced) with c++11 braced init instead

PastaPastaPasta avatar Dec 18 '21 17:12 PastaPastaPasta

@sipa can you please review the current state of this PR?

Thanks

PastaPastaPasta avatar Dec 21 '21 16:12 PastaPastaPasta

All done, will squash if requested

PastaPastaPasta avatar Dec 21 '21 22:12 PastaPastaPasta

@sipa how does that look?

PastaPastaPasta avatar Jan 03 '22 20:01 PastaPastaPasta

Hi going through my old open PRs. Any chance we can get this merged?

PastaPastaPasta avatar Feb 19 '23 17:02 PastaPastaPasta