Skip to content

Fix most remaining Clang -Wsign-conversion warnings - #1730

Merged
seanm merged 1 commit into
libusb:masterfrom
seanm:conversion-warnings
Jul 20, 2026
Merged

seanm merged 1 commit into
libusb:masterfrom
seanm:conversion-warnings

Conversation

@seanm

@seanm seanm commented Dec 31, 2025

Copy link
Copy Markdown
Contributor
  • added cast
  • changed some types
  • added asserts

@mcuee mcuee added core Related to common codes Examples Examples labels Jan 2, 2026
@mcuee mcuee added this to the 1.0.31 milestone Apr 13, 2026
@mcuee mcuee mentioned this pull request May 6, 2026
@seanm
seanm requested review from Youw and mcuee May 31, 2026 20:58
Comment thread examples/fxload.c Resolved

@Youw Youw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall this is good from "fix the warning" point of view.
But there is also anothre thing - this actually affects overall consistency and code style across implementation. We might want to consider what to do with it in the future.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce remaining Clang -Wsign-conversion warnings across the core POSIX event loop and several example programs by adding explicit casts, tightening types, and adding assertions for internal invariants.

Changes:

  • Adjust POSIX event waiting logic to use unsigned types/casts and add assertions around internal pollfd layout.
  • Refine example code integer types/casts to avoid signed/unsigned conversion warnings.
  • Clarify API documentation for libusb_transfer.actual_length to indicate it is never negative.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
libusb/os/events_posix.c Adds assertions and adjusts signed/unsigned handling around poll() results and internal fd bookkeeping.
libusb/libusb.h Updates documentation for actual_length to state it is never negative.
examples/xusb.c Adds casts / type changes around mass storage helpers and buffer display to address sign-conversion warnings.
examples/sam3u_benchmark.c Adds casts/type adjustments in benchmark accounting and timing computations.
examples/fxload.c Adjusts loop variable types/scope to reduce sign-conversion warnings.
examples/ezusb.c Narrows variable scope and adds casts in IIC parsing to avoid sign-conversion warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libusb/os/events_posix.c Resolved
Comment thread examples/xusb.c Resolved
Comment thread examples/xusb.c Resolved
Comment thread examples/sam3u_benchmark.c Resolved
Comment thread libusb/os/events_posix.c Resolved
Comment thread examples/sam3u_benchmark.c Resolved
Comment thread libusb/os/events_posix.c Resolved
Comment thread examples/xusb.c Resolved
Comment thread examples/xusb.c Resolved
Comment thread examples/sam3u_benchmark.c Resolved
@seanm
seanm force-pushed the conversion-warnings branch 3 times, most recently from 1aaa937 to ff63857 Compare July 14, 2026 20:07
@seanm

seanm commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@sonatique @Youw ok I made some small changes today, this is ready for hopefully one last review.

Comment thread libusb/os/events_posix.c Resolved
Comment thread examples/sam3u_benchmark.c Resolved
@seanm
seanm force-pushed the conversion-warnings branch from ff63857 to e11ead4 Compare July 15, 2026 02:31
- added cast
- changed some types
- added asserts
@seanm
seanm force-pushed the conversion-warnings branch from e11ead4 to 6170ee7 Compare July 20, 2026 19:06
@seanm
seanm merged commit bc1ddf4 into libusb:master Jul 20, 2026
37 checks passed
Youw added a commit that referenced this pull request Jul 26, 2026
Declare internal_fds before the existing goto paths while preserving its
unsigned type and assignment point. This fixes C++ builds after #1730.

Assisted-by: codex:GPT-5.6-Sol
Youw added a commit that referenced this pull request Jul 27, 2026
Declare internal_fds before the existing goto paths while preserving its
unsigned type and assignment point. The C++ CI added by #1845 exposed this
regression from #1730.

Assisted-by: codex:GPT-5.6-Sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to common codes Examples Examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants