Thread (7 messages) 7 messages, 3 authors, 2023-12-28
STALE919d

[PATCH v2] sideband.c: replace int with size_t for clarity

From: Chandra Pratap via GitGitGadget <hidden>
Date: 2023-12-23 17:03:40
Subsystem: the rest · Maintainer: Linus Torvalds

From: Chandra Pratap <redacted>

Replace int with size_t for non-negative values to improve
clarity and remove the 'NEEDSWORK' tag associated with it.wq

Signed-off-by: Chandra Pratap <redacted>
---
    sideband.c: replace int with size_t for clarity

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1625%2FChand-ra%2Fdusra-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1625/Chand-ra/dusra-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1625

Range-diff vs v1:

 1:  be67e1bca38 ! 1:  fdacc69ae3b sideband.c: replace int with size_t for clarity
     @@ Metadata
       ## Commit message ##
          sideband.c: replace int with size_t for clarity
      
     -    Replace int with size_t for clarity and remove the
     -    'NEEDSWORK' tag associated with it.
     +    Replace int with size_t for non-negative values to improve
     +    clarity and remove the 'NEEDSWORK' tag associated with it.wq
      
          Signed-off-by: Chandra Pratap [off-list ref]
      
     @@ sideband.c: void list_config_color_sideband_slots(struct string_list *list, cons
       {
       	int i;
       
     +@@ sideband.c: static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
     + 
     + 	for (i = 0; i < ARRAY_SIZE(keywords); i++) {
     + 		struct keyword_entry *p = keywords + i;
     +-		int len = strlen(p->keyword);
     ++		size_t len = strlen(p->keyword);
     + 
     + 		if (n < len)
     + 			continue;


 sideband.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sideband.c b/sideband.c
index 6cbfd391c47..7c3ec0ece29 100644
--- a/sideband.c
+++ b/sideband.c
@@ -69,9 +69,8 @@ void list_config_color_sideband_slots(struct string_list *list, const char *pref
  * of the line. This should be called for a single line only, which is
  * passed as the first N characters of the SRC array.
  *
- * NEEDSWORK: use "size_t n" instead for clarity.
  */
-static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
+static void maybe_colorize_sideband(struct strbuf *dest, const char *src, size_t n)
 {
 	int i;
 
@@ -88,7 +87,7 @@ static void maybe_colorize_sideband(struct strbuf *dest, const char *src, int n)
 
 	for (i = 0; i < ARRAY_SIZE(keywords); i++) {
 		struct keyword_entry *p = keywords + i;
-		int len = strlen(p->keyword);
+		size_t len = strlen(p->keyword);
 
 		if (n < len)
 			continue;
base-commit: 1a87c842ece327d03d08096395969aca5e0a6996
-- 
gitgitgadget
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help