This change modifies code paths and uses __used to address -Wunused
issues that occur when THUNDERBOLT_DEBUG == 0.
Details
- Reviewers
- None
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 71082 Build 67965: arc lint + arc unit
Event Timeline
thanks for this!
in general, can't we just use __used on maybe-unused declarations? smaller diff & more idiomatic wrt having sc defined everywhere without doing r->sc. but I'm nitpicking here so I'm okay with accepting this as is
| sys/dev/thunderbolt/nhi.c | ||
|---|---|---|
| 908–911 | why don't we just use __used here as suggested in the description of this revision? | |
| sys/dev/thunderbolt/tb_debug.h | ||
| 84 | why this change? Do we want this code to be built if THUNDERBOLT_DEBUG is 0? but also if we wanted to preserve the existing logic we could simplify the previous check with just #if THUNDERBOLT_DEBUG > 0 since undefined identifiers evaluate to 0. | |
| sys/dev/thunderbolt/nhi.c | ||
|---|---|---|
| 908–911 | I tried using it universally, but __used is only applicable to function arguments, not local variables in functions, etc. I did this to avoid #ifdef soup, but I suppose there are alternative ways I could try applying these changes. I'm open to suggestions. | |
| sys/dev/thunderbolt/nhi.c | ||
|---|---|---|
| 908–911 | I have an idea... maybe something like this? #ifdef THUNDERBOLT_DEBUG #define WUNUSED_IF_DEBUG(x) (void)(x) #else #define WUNUSED_IF_DEBUG(x) (x) #endif | |
| sys/dev/thunderbolt/tb_debug.h | ||
| 84 | The latter is actually a source of grief with certain compilers/versions of compilers. I remember a fair bit of effort being spent by @dim dealing with that particular scenario with drivers and higher values of WARNS (was that llvm 5.x~6.x? I forget...). | |
| sys/dev/thunderbolt/nhi.c | ||
|---|---|---|
| 908–911 | I flip-flopped the conditional by accident and also s/WUNUSED/UNUSED/g. | |
| sys/dev/thunderbolt/nhi.c | ||
|---|---|---|
| 908–911 | you could also do __unused, as that applies to everything. In fact I think that may be more correct than __used, as that forces the compiler to emit code even if not used: | |
| sys/dev/thunderbolt/tb_debug.h | ||
| 84 | but then what was wrong with the original code? in the case where THUNDERBOLT_DEBUG is not defined, the behaviour is the same here | |