From e6ffb00768b06d8787d024e047f48b372b886936 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Thu, 20 Sep 2018 13:27:11 +0100 Subject: [PATCH] Fix -Werror=conversion failure in trimcr(). While here avoid a separate strlen call in read_repos(), using the length returned by trimcr(). The check for a NULL buf is removed as it was already tested earlier in the function. --- fsops.c | 5 +---- tools.c | 4 ++-- tools.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fsops.c b/fsops.c index 9804eeb..f02490d 100644 --- a/fsops.c +++ b/fsops.c @@ -139,10 +139,7 @@ read_repos(void) } } - if (trimcr(buf) < 0) /* strip newline */ - continue; - - curlen = strlen(buf) + 2; /* ' ' + '\0' */ + curlen = trimcr(buf) + 2; /* ' ' + '\0' */ repolen += curlen; repos = xrealloc(repos, repolen * sizeof(char)); diff --git a/tools.c b/tools.c index c6a52d4..73c0f0e 100644 --- a/tools.c +++ b/tools.c @@ -48,13 +48,13 @@ charcount(char *str, char c) /* * Remove trailing \n or \r\n, returning length of resulting string. */ -int +size_t trimcr(char *str) { size_t len; if (str == NULL) - return (-1); + return (0); len = strlen(str); diff --git a/tools.h b/tools.h index e774c2c..f6d6dcd 100644 --- a/tools.h +++ b/tools.h @@ -158,7 +158,7 @@ extern uint8_t yesflag; extern uint8_t noflag; extern int charcount(char *, char); -extern int trimcr(char *); +extern size_t trimcr(char *); extern void free_list(char **); extern void do_log(const char *, const char *, ...); extern void trunc_str(char *, char, int);