mbox series

[GSOC,v2,0/6] apply: address -Wsign-comparison warnings

Message ID 20250209081216.241350-1-jelly.zhao.42@gmail.com (mailing list archive)
Headers show
Series apply: address -Wsign-comparison warnings | expand

Message

Zejun Zhao Feb. 9, 2025, 8:12 a.m. UTC
There are several -Wsign-comparison warnings in "apply.c", which can be
classified into the following three types:

  1. comparing a length of `size_t` type with a `ptrdiff_t` value

  2. comparing a length of `size_t` type with a length of `int` type

  3. comparing a loop counter `i` of `int` type with an unsigned loop
  bound

Fix these warnings following one basic principle: do not touch the
relevant logics and keep the behaviors of the code. Adopt three
different strategies for each of the above three types:

  1. cast the `ptrdiff_t` values to `size_t` type

  2. try to change the type of the `int` length to `size_t` (may fall 
  back to Strategy 1 if the variable is not guaranteed to be unsigned)

  3. use a loop counter `i` of `size_t` type

Zejun Zhao (6):
  apply: change fields in `apply_state` to unsigned
  apply: change some variables from `int` to `size_t`
  apply: do a typecast to eliminate warnings
  apply: cast some ptrdiff_t's to size_t's
  apply: use `size_t` loop counters
  apply: enable -Wsign-comparison checks

 apply.c | 69 +++++++++++++++++++++++++++------------------------------
 apply.h |  4 ++--
 2 files changed, 35 insertions(+), 38 deletions(-)


base-commit: bc204b742735ae06f65bb20291c95985c9633b7f