Add noop do-while to non-DEBUG DXG_TRACE to avoid future compiler warnings
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
**Is your feature request related to a problem? Please describe.**
As future Linux enables more warning flags[^1], some code needs to be changed accordingly to suppress warnings and support `WERROR=y` builds. One problem is the `DXG_TRACE` in drivers/hv/dxgkrnl:
https://github.com/microsoft/WSL2-Linux-Kernel/blob/427645e3db3a8896714f22a3d3fe0c3f7b317ad4/drivers/hv/dxgkrnl/dxgkrnl.h#L1031
Uses like the following generates a `if` statement without a body, which could trigger `-Wempty-body` warnings:
https://github.com/microsoft/WSL2-Linux-Kernel/blob/427645e3db3a8896714f22a3d3fe0c3f7b317ad4/drivers/hv/dxgkrnl/dxgmodule.c#L597-L599
I encountered this problem in a 3rdparty port (Nevuly/WSL2-Linux-Kernel-Rolling) targeting stable kernel branch. I think upstreaming the patch here would be more beneficial to every user.
**Describe the solution you'd like**
Adopt the patch as in [^2], thus eliminating this compiler warning from happening in the future.
**Describe alternatives you've considered**
* **Disable warnings.** Not ideal as this may hinder real positives, and implementing the patch has virtually no runtime impact.
**Additional context**
See also Nevuly/WSL2-Rolling-Kernel-Issue#37.
[^1]:
[^2]: Attachment: [0001-drivers-hv-dxgkrnl-Add-noop-do-while-to-non-DEBUG-DX.patch](https://github.com/user-attachments/files/22871168/0001-drivers-hv-dxgkrnl-Add-noop-do-while-to-non-DEBUG-DX.patch)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in drivers/hv/dxgkrnl/dxgkrnl.h at the non-DEBUG DXG_TRACE definition, then inspect the referenced use in drivers/hv/dxgkrnl/dxgmodule.c. Compare the attached patch and verify that the non-DEBUG macro no longer produces an empty if body. Build the affected kernel configuration with WERROR=y to confirm the warning is avoided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- build-system, operating-systems
- Issue type
- Feature
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100