Closed Linjieqiang closed 2 years ago
I don't see where the conversion is taking place. Which version of Clang-Tidy is this? Libcanard is currently analyzed with Clang Tools version 11.
I use the segger embedded studio ide to analyze the code. The wiki: https://wiki.segger.com/Static_code_analysis_in_Embedded_Studio
Idk this doesn't make sense to me. Can you see what it takes to fix this warning? Maybe I am missing something.
I understand what a narrowing conversion is. What I don't understand is where within the expression it occurs, please look into that.
(int8_t)((-(int8_t)(uint8_t) ~val) - 1)
and ((int8_t) val)
Maybe you could have a try?
When I remove the libcanard\.clang-tidy
, the code static check is fine.
---
Checks: >-
boost-*,
bugprone-*,
cert-*,
clang-analyzer-*,
cppcoreguidelines-*,
google-*,
hicpp-*,
llvm-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-google-readability-todo,
-readability-avoid-const-params-in-decls,
-llvm-header-guard,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '99'
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
...
Maybe you could use the clang 12 to try CI?
Hmm. I'm not able to reproduce. Can you take a look here:
Maybe it was a warning, but the inspection conditions are too strict. @thirtytwobits
@Linjieqiang it would help if you could isolate the issue to a minimal working example. Also, consider checking the Clang bug tracker to see if this is a known issue. Maybe ask the maintainers about this for good measure unless someone did that already. In the worst case, we may need to add a NOLINT comment on the offending lines to suppress this diagnostic.
Still haven't found the reason, why don't we use NOLINT to circumvent this problem?
We need an MWE first. Please extract the offending fragment into a separate unit and see if you can reproduce the problem there.
Thanks. @pavel-kirienko
I didn't really fix it, the code in question was removed from the library (use Nunavut instead).