On Mon, Feb 01, 2021 at 03:41:50PM -0300, Vinicius Tinti wrote: > > My goal is to avoid having a dead code. Three options come to mind. > > The first would be to add another #ifdef SOMETHING (suggest a name). > But this doesn't remove the code and someone could enable it by accident. I *really* don't see the point of having the compiler whine about "dead code", so I'm not terribly fond of -Wunreachable-code-aggressive. There may be times where depending on how things are compiled, we *want* the compiler to remove code block, and it makes the code less ugly than having #ifdef ... #endif breaking up the code. If turning that on requires uglifying many places in the kernel code, maybe the right answer is... don't. That being said, I have no problem of replacing if (0) { ... } with #ifdef DX_DEBUG ... #endif In this particular place. But before we go there, I want to register my extreme skepticsm about -Wunreachable-code-aggressive. How much other places where it is ***obvious*** that the maintainer really knew what they are doing, and it's just the compiler whining about a false positive? > > However, if there *is* a bug, having an early detection that the > > representation invariant of the data structure has been violated can > > be useful in root causing a bug. This would probably be clearer if > > the code was pulled out into a separate function with comments > > explaining that this is a rep invariant check. > > Good idea. I will do that too. If you want to do that, and do something like #ifdef DX_DEBUG static inline htree_rep_invariant_Check(...) { ... } #else static inline htree_rep_invariant_check(...) { } #endif I'm not going to complain. That's actually a better way to go, since there may be other places in the code where a developer might want to introduce a rep invariant check. So that's actually improving the code, as opposed to making a pointless change just to suppress a compiler warning. Of course, then someone will try enabling a -W flag which causes the compiler to whine about empty function bodies.... - Ted