From 4595ada2f69b42670c85a63c7d2344af63f2afe7 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 29 Dec 2019 01:35:09 -0500 Subject: Minor fixes: * size_t in place of int * Moved some variables closer to their execution scope * Add some error checks --- src/strings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/strings.c') diff --git a/src/strings.c b/src/strings.c index d6da7b6..782d66c 100644 --- a/src/strings.c +++ b/src/strings.c @@ -390,7 +390,7 @@ char **strdeldup(char **arr) { return NULL; } - int records; + size_t records; // Determine the length of the array for (records = 0; arr[records] != NULL; records++); @@ -453,7 +453,7 @@ char *strip(char *sptr) { *sptr = '\0'; return sptr; } - for (size_t i = len - 1; i >= 0; i--) { + for (size_t i = len - 1; ; i--) { if (isspace(sptr[i]) || isblank(sptr[i])) { sptr[i] = '\0'; } @@ -523,7 +523,7 @@ int isrelational(char ch) { */ void print_banner(const char *s, int len) { size_t s_len = strlen(s); - if (!s || !s_len) { + if (!s_len) { return; } for (int i = 0; i < (len / s_len); i++) { -- cgit