Sam Price created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1386

Project:Branches: TheSamPrice/rtems:fix/tftpfs-read-loop to 
rtems/rtos/rtems:main
Author:   Sam Price



## Summary

testsuites/tftpfs: Fix cast direction in the read loop condition

Commit bd2055cf5a5 ("fstests: Address -Wsign-compare warnings") silenced
the signed/unsigned comparison in the read loop of read_file() by
casting the unsigned limit down to the signed type:

  while ( bytes > 0 && (ssize_t) max_bytes >= bytes ) {

The callers that want an unbounded read pass max_bytes = SIZE_MAX, and
(ssize_t) SIZE_MAX is -1.  The condition is therefore false on the very
first iteration, the loop body never executes, and every read_* case of
the test reports a failure.

Cast in the other direction instead.  The preceding bytes > 0 term
short-circuits the comparison, so bytes is known to be positive and the
conversion to size_t is value preserving; the warning stays fixed.

With this the check count rises from 5405 to 7282 as the 1877 checks in
the read paths finally run, and the test passes.

The bug is architecture independent and affects all BSPs.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 6fff2086d8a2ee0f0d8119e9be3f2fd34a655635)


## Generative AI

<!-- If you have used AI please use the "AI Contribution" template otherwise 
leave this blank see our fulls statement at 
https://www.rtems.org/generative-ai/-->


<!-- Default settings, if it is a dropdown it will set after submission -->

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1386
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/sent_notifications/4-722r9rol9m475brzhokj1970n-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to