Skip to content

fix(misc-redundant-expression): fix clang-tidy violations#2019

Open
github-actions[bot] wants to merge 3 commits intomainfrom
fix/clang-tidy-misc-redundant-expression
Open

fix(misc-redundant-expression): fix clang-tidy violations#2019
github-actions[bot] wants to merge 3 commits intomainfrom
fix/clang-tidy-misc-redundant-expression

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Feb 1, 2026

Summary

Fixing clang-tidy checker: misc-redundant-expression

  • Total violations: 1

Analysis run: #21555444024

Status

🔄 Copilot is reviewing remaining violations...


Generated by clang-tidy autofix workflow

@github-actions github-actions bot added the copilot-autofix PRs created by Copilot auto-fix workflow label Feb 1, 2026
@blozano-tt
Copy link
Collaborator

@broskoTT looks like clang-tidy + copilot caught a bug here. Could you please confirm? Are we missing a test?

@pjanevskiTT
Copy link
Contributor

Ok won't merge until @broskoTT takes a look at the potential bug

Copy link
Contributor

@broskoTT broskoTT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor

Copilot AI commented Feb 3, 2026

@blozano-tt I've opened a new pull request, #2049, to work on those changes. Once the pull request is ready, I'll request review from you.

blozano-tt added a commit that referenced this pull request Feb 3, 2026
### Issue
Addresses feedback on #2019:
#2019 (comment)

### Description
The original `spi_ctrl0_spi_scph()` function contained `(scph << 6) &
0x1`, which always returned 0 due to shift-then-mask order. Since this
function was only used in bitwise OR expressions where OR-ing with 0 has
no effect, and the SPI implementation works correctly without it, the
function is dead code.

Removed the function and all call sites.

### List of the changes
- Removed `spi_ctrl0_spi_scph(uint32_t scph)` function definition
- Removed function calls from three SPI control register writes in
`init()`, `read_status()`, and `lock()` methods

### Testing
Build verification confirms clean compilation.

### API Changes
There are no API changes in this PR.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: blozano-tt <181790211+blozano-tt@users.noreply.github.com>
blozano-tt and others added 3 commits February 10, 2026 00:24
…on (#2020)

### Issue
Fix clang-tidy violations for checker: misc-redundant-expression

### Description
Fixed ineffective bitwise operation in SPI control register helper.
Original expression `(scph << 6) & 0x1` always evaluated to 0 due to
shift-then-mask order. Corrected to `(scph & 0x1) << 6` to properly
place bit 0 at position 6.

```cpp
// Before: Always returns 0
static inline uint32_t spi_ctrl0_spi_scph(uint32_t scph) { return (scph << 6) & 0x1; }

// After: Returns 0x00 or 0x40 based on input LSB
static inline uint32_t spi_ctrl0_spi_scph(uint32_t scph) { return (scph & 0x1) << 6; }
```

### List of the changes
- Fixed redundant bitwise AND in `spi_ctrl0_spi_scph()` helper function
- Removed `-misc-redundant-expression` from `.clang-tidy` to enable
regression detection
- Deleted `violations_to_fix.txt`

### Testing
Build verification confirms clean compilation with fix applied.

### API Changes
There are no API changes in this PR.

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> Fix all clang-tidy violations for checker: misc-redundant-expression
> 
> The full list of violations is in: violations_to_fix.txt
> 
> Some violations may have been auto-fixed by CodeChecker.
> Review those fixes and fix any remaining violations.
> 
> Total violations: 1
> 
> For each violation in violations_to_fix.txt:
> 1. If already fixed by auto-fix, verify it's correct
> 2. If not fixed, apply the appropriate fix
> 3. Follow the existing code style
> 
> After fixing all violations:
> 1. Delete violations_to_fix.txt
> 2. If .clang-tidy disables this checker (e.g.,
-misc-redundant-expression),
>    remove that disablement to enable the check for regressions


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/tenstorrent/tt-umd/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: blozano-tt <181790211+blozano-tt@users.noreply.github.com>
### Issue
Addresses feedback on #2019:
#2019 (comment)

### Description
The original `spi_ctrl0_spi_scph()` function contained `(scph << 6) &
0x1`, which always returned 0 due to shift-then-mask order. Since this
function was only used in bitwise OR expressions where OR-ing with 0 has
no effect, and the SPI implementation works correctly without it, the
function is dead code.

Removed the function and all call sites.

### List of the changes
- Removed `spi_ctrl0_spi_scph(uint32_t scph)` function definition
- Removed function calls from three SPI control register writes in
`init()`, `read_status()`, and `lock()` methods

### Testing
Build verification confirms clean compilation.

### API Changes
There are no API changes in this PR.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: blozano-tt <181790211+blozano-tt@users.noreply.github.com>
@blozano-tt blozano-tt force-pushed the fix/clang-tidy-misc-redundant-expression branch from 4e03e79 to 66728f0 Compare February 10, 2026 08:24

static constexpr uint32_t SPI_DUMP_ADDR_CORRECTION = 0x10000000;

static inline uint32_t spi_ctrl0_spi_scph(uint32_t scph) { return (scph << 6) & 0x1; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant expression always returns 0.


val = SPI_CTRL0_TMOD_EEPROM_READ | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS |
spi_ctrl0_spi_scph(0x1);
val = SPI_CTRL0_TMOD_EEPROM_READ | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x | 0 = x


val = SPI_CTRL0_TMOD_EEPROM_READ | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS |
spi_ctrl0_spi_scph(0x1);
val = SPI_CTRL0_TMOD_EEPROM_READ | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x | 0 = x


val = SPI_CTRL0_TMOD_TRANSMIT_ONLY | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS |
spi_ctrl0_spi_scph(0x1);
val = SPI_CTRL0_TMOD_TRANSMIT_ONLY | SPI_CTRL0_SPI_FRF_STANDARD | SPI_CTRL0_DFS32_FRAME_08BITS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x | 0 = x

@broskoTT
Copy link
Contributor

I'm fine to merge as long as spi tests pass. These need to be ran on a dedicated machine. @pjanevskiTT if you have the time, please run the tests on one of the wh machines (this is wh specific code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot-autofix PRs created by Copilot auto-fix workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants