Skip to content

Commit

Permalink
Fix for "garbage" bits (#355)
Browse files Browse the repository at this point in the history
Small fix for clang-tidy false positive about using garbage data during
serialization, like following:
```
/home/runner/work/demos/demos/libudpard_demo/build/transpiled/nunavut/support/serialization.h:154:36: error: The left operand of '&' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult,-warnings-as-errors]
            *last_dst = (*last_dst & (uint8_t)~mask) | (*last_src & mask);
                                   ^
```
  • Loading branch information
serges147 authored Nov 12, 2024
1 parent 836a651 commit 2bdc442
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/nunavut/lang/c/support/serialization.j2
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ static inline void nunavutCopyBits(void* const dst,
uint8_t* const last_dst = pdst + length_bytes; // NOLINT NOSONAR
{{ assert('length_mod < 8U') }}
const uint8_t mask = (uint8_t)((1U << length_mod) - 1U);
// No lint for "The left operand of '&' is a garbage value" because
// these so called "garbage" bits of `*last_dst` won't be used during deserialization.
// NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult)
*last_dst = (*last_dst & (uint8_t)~mask) | (*last_src & mask);
}
}
Expand Down

0 comments on commit 2bdc442

Please sign in to comment.