mbox series

[0/2] utf8: change return type of some helpers from int to size_t

Message ID pull.1690.git.1710664071.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series utf8: change return type of some helpers from int to size_t | expand

Message

Philippe Blain via GitGitGadget March 17, 2024, 8:27 a.m. UTC
Hello,

There are lot of places in the codebase where int is used to store size of
an object instead of size_t (which is better alternative due to reasons like
portability, readability, etc). This patch series accomplishes one such
#TODO comment, which addresses this issue.

I appreciate your review and feedback on this patch series.

Best regards, Mohit Marathe

Mohit Marathe (2):
  utf8: change type from int to size_t
  utf8: make utf8_strnwidth & utf8_strwidth return size_t instead of int

 builtin/blame.c    |  6 +++---
 builtin/branch.c   |  2 +-
 builtin/fetch.c    |  2 +-
 builtin/worktree.c |  4 ++--
 column.c           |  2 +-
 diff.c             |  8 +++++---
 gettext.c          |  2 +-
 gettext.h          |  2 +-
 pretty.c           |  4 ++--
 utf8.c             | 14 +++++---------
 utf8.h             |  4 ++--
 wt-status.c        |  4 ++--
 12 files changed, 26 insertions(+), 28 deletions(-)


base-commit: 2953d95d402b6bff1a59c4712f4d46f1b9ea137f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1690%2Fmohit-marathe%2Fint-to-size_t-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1690/mohit-marathe/int-to-size_t-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1690

Comments

Junio C Hamano March 17, 2024, 4:51 p.m. UTC | #1
"Mohit Marathe via GitGitGadget" <gitgitgadget@gmail.com> writes:

> There are lot of places in the codebase where int is used to store size of
> an object instead of size_t (which is better alternative due to reasons like
> portability, readability, etc). This patch series accomplishes one such
> #TODO comment, which addresses this issue.

Nice. In principle this is the right thing to do.

To reviewers, if I were reviewing this series (which I will not in
the next 24 hours), I'd pay particular attention to the callers that
currently accept "int" and use negative return value as an sign of a
failure.  Moving to "size_t" from "int" will break such callers.

Thanks.
Patrick Steinhardt March 21, 2024, 10:30 a.m. UTC | #2
On Sun, Mar 17, 2024 at 08:27:49AM +0000, Mohit Marathe via GitGitGadget wrote:
> Hello,
> 
> There are lot of places in the codebase where int is used to store size of
> an object instead of size_t (which is better alternative due to reasons like
> portability, readability, etc). This patch series accomplishes one such
> #TODO comment, which addresses this issue.
> 
> I appreciate your review and feedback on this patch series.

I really appreciate you working on this -- our mismatch of types really
irks me a ton, so I'm very happy to see some fixes. I've provided a
bunch of feedback for your patch 1/2, where we need to be quite a bit
more careful about the blast radius of each of the changes.

I'd recommend to split that patch up into multiple parts. While each of
the changes is basically only changing some types around, it's rather
involved to review as you have to also investigate the vicinity of each
change quite vigorously. So at the very least I would recommend to split
out patches for every change that requires further changes, e.g. to the
return types of additional functions.

Thanks!

Patrick