]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ident: fix type of string length parameter
authorPatrick Steinhardt <ps@pks.im>
Wed, 6 Aug 2025 05:54:16 +0000 (07:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Aug 2025 14:36:30 +0000 (07:36 -0700)
The last parameter in `split_ident_line()` is the length of the line
passed in by the caller. As such, most callers pass in either the result
of `strlen()`, `struct strbuf::len` or a pointer diff, all of which
are expected to be positive numbers. Regardless of that, the function
accepts a signed integer, which is somewhat confusing.

Fix the function signature to instead accept a `size_t`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c
ident.h

diff --git a/ident.c b/ident.c
index 967895d885033da5393a9c0c0c52d51531a64867..a7a2d13257931bab81f51147e9ba198fb414ae32 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -272,7 +272,7 @@ static void strbuf_addstr_without_crud(struct strbuf *sb, const char *src)
  * can still be NULL if the input line only has the name/email part
  * (e.g. reading from a reflog entry).
  */
-int split_ident_line(struct ident_split *split, const char *line, int len)
+int split_ident_line(struct ident_split *split, const char *line, size_t len)
 {
        const char *cp;
        size_t span;
diff --git a/ident.h b/ident.h
index 6a79febba15feabb8418ee6441a47553e616c6ec..3c034038791b7834682e512b276718126b10b3d7 100644 (file)
--- a/ident.h
+++ b/ident.h
@@ -35,7 +35,7 @@ void reset_ident_date(void);
  * Signals an success with 0, but time part of the result may be NULL
  * if the input lacks timestamp and zone
  */
-int split_ident_line(struct ident_split *, const char *, int);
+int split_ident_line(struct ident_split *, const char *, size_t);
 
 /*
  * Given a commit or tag object buffer and the commit or tag headers, replaces