Repository navigation
Waf chibios sign compare - #34647
Waf chibios sign compare#34647khancyr wants to merge 7 commits into
Conversation
Global Size Summary (Total Flash delta in bytes)Built from 1c9df2b rebased onto 1f1251a
|
Previous review (2026-10-06)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks for tightening this. With -Wno-sign-compare now C-only, a few C++ comparisons the PR does not fix still break builds at c13598c. I reproduced each with arm-none-eabi-gcc 10.2.1:
Since -Wfatal-errors stops each file at its first error, a wider sweep (CAN, network and ext-flash bootloaders, AP_Periph variants, iomcu variants) would be worth doing before turning this on. I only built the targets above. On the persistent-params commit: MatekH7A3 and MatekH7A3-Wing do have bootloaders larger than their 8 KiB page 0, with persistence enabled. So the 'no board hits this' line in the commit message isn't right, and the fix does help them. The params write at Util.cpp:325-329 still has no space check when the bootloader itself is being updated. Using the same fit test there would close that path. |
c13598c to
27afd29
Compare
Previous review (2026-10-07)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks for the update. At 27afd29 the four build breaks from my last note are fixed, and the persistent-params write is now gated. The commit message also names the MatekH7A3 boards now. Two more C++ comparisons still break builds now that -Wno-sign-compare is C-only (https://github.com/ArduPilot/ardupilot/pull/34647/files#diff-7d695263dc1bd6a88d12cd548aa30f977f387796b6b97d3c739cde0487071002R1241). Both are in driver code that only some boards compile. I reproduced them with arm-none-eabi-gcc 10.2.1:
|
27afd29 to
1c9df2b
Compare
Previous review (2026-10-08)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks for the update. At 1c9df2b the AP_Radio and TIBQ76952 casts are in their own commits, and the waf commit message names the SkyViper boards and VM-L431-BMS. skyviper-journey copter and VM-L431-BMS AP_Periph now build here with the C++-only -Werror=sign-compare (https://github.com/ArduPilot/ardupilot/pull/34647/files#diff-7d695263dc1bd6a88d12cd548aa30f977f387796b6b97d3c739cde0487071002R1240). Reverting the casts makes them fail again. The other reviewers also saw skyviper-v2450 and skyviper-f412-rev1 build. Commits 1-5 are unchanged from the last review. Nothing outstanding from my side. The one red check is 'test sub' (MotorThrustHoverParameterIgnore and TestLogDownloadLogRestart). It passed on this PR's two previous heads and on master at the base, and none of the code changed here is compiled into SITL Sub. It looks unrelated, but I haven't re-run it, so a re-run would be needed before merge. The full board matrix wasn't built. The sample was 23 targets across F1/F4/F7/G4/L4/H7, vehicle, AP_Periph, bootloader and iofirmware builds, plus the 106 passing CI checks. |
|
|
||
| for (int32_t i = 0; i <= count+1; ) { | ||
| if (i < count) { | ||
| for (int32_t i = 0; i <= int32_t(count)+1; ) { |
There was a problem hiding this comment.
Can i go negative here? That would be a bit of a concern considering we're indexing with it down further.
| Debug("Flash OK\n"); | ||
| #if HAL_ENABLE_SAVE_PERSISTENT_PARAMS | ||
| if (persistent_params.get_length()) { | ||
| if (store_persistent_params && persistent_params.get_length()) { |
There was a problem hiding this comment.
This looks like a drive-by bugfix unrelated to "Waf chibios sign compare". That would make this patch the headline!
| int32_t d = synctm.sync_time_us; // Time between packets, e.g. 5100 us | ||
| uint32_t dt = when - synctm.rx_time_us; | ||
| if (dt > 50*d) { // We have lost sync (missed 50 packets) so slow down the channel hopping until we resync | ||
| if (dt > uint32_t(50*d)) { // We have lost sync (missed 50 packets) so slow down the channel hopping until we resync |
There was a problem hiding this comment.
Shouldn't d's type be corrected?
| uint8_t *tdest = (uint8_t *)dest; | ||
| uint8_t *tsrc = (uint8_t *)src; | ||
| for (int i=0; i<n; i++) { | ||
| for (size_t i=0; i<n; i++) { |
There was a problem hiding this comment.
| for (size_t i=0; i<n; i++) { | |
| for (auto i=0; i<n; i++) { |
Compare values of the same signedness, ready for -Werror=sign-compare on ChibiOS. No change in behaviour: the lseek result is still compared with the offset, the priority and sleep ticks get the same values, and the bdshot decode index, which never goes negative, is now unsigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare values of the same signedness, ready for -Werror=sign-compare on ChibiOS. No change in behaviour: arg and n are checked to be positive before they are compared, the name and value ends are after their starts, and the CAN timeouts only gain unsigned constants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare the SBUS interval with an unsigned minimum, ready for -Werror=sign-compare on ChibiOS. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare the update interval with an unsigned limit, ready for -Werror=sign-compare on ChibiOS. proximity_max_rate is checked to be positive first, so there is no change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare values of the same signedness, ready for -Werror=sign-compare on ChibiOS. The packet interval d is set from the unsigned sync_time_us, so make it uint32_t, which is how it was already compared, and the tune length limit only changes type: no change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compare the cell count limits with the same signedness, ready for -Werror=sign-compare on ChibiOS. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ChibiOS flags have -Wno-sign-compare and -Wno-attributes, and are copied into CXXFLAGS after the -Werror= flags every board gets, so neither check has ever applied to ChibiOS C++ code. Keep them for C only, which leaves C as it was, so C++ gets the same checks as on the other boards. The previous commits fix the comparisons this finds. Checked with the warnings made non-fatal on vehicle, AP_Periph, bootloader and IO firmware builds: CAN, network and external flash bootloaders, F1, F3, F4, L4, G4, H7 and H7A3 boards, every iomcu variant, the SkyViper boards and VM-L431-BMS, and CubeOrange copter, plane and rover with every build option enabled. No attributes warning was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1c9df2b to
3b877cc
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This looks good to me at 3b877cc (rebased from 1c9df2b, which I last reviewed). Peter's points are addressed in the code: bk2425's Notes
|
Summary
Enable back the sign/unsign comparison on C++ code when compiling chibios board. This was inhibited by wrong flag handling
fixs the part of code that are reported with the current toolchain
Tested: with the real -Werror, these all build:
CubeOrange copter and rover;
MatekF405 plane;
MatekH743 copter;
MatekL431-Periph and f103-GPS (AP_Periph);
the CubeOrange bootloader;
the IO firmware.
not fly tested
Update :
Fixed the four sites, plus the calls they were hiding (fatal errors, and MIN/MAX instantiations reported once per file). Swept 28 targets with the warning non-fatal (CAN, network and ext-flash bootloaders, F1/F3/F4/L4/G4/H7/H7A3, 7 AP_Periph, all iomcu variants, 4 vehicles), which found three more sites (network.cpp:445, can.cpp:287, AP_Periph/proximity.cpp); all fixed.
Classification & Testing (check all that apply and add your own)
Description