Skip to content

Commit

Permalink
Fix -Werror=conversion failure in trimcr().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jonathan Perkin committed Sep 20, 2018
1 parent 9aaa995 commit e6ffb00
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions fsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e6ffb00

Please sign in to comment.