From a17b38979617e8799da58be83699ea64dbed4503 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 20 Nov 2019 01:45:52 -0800 Subject: Fix wordcmp return value when the words have differing lengths Otherwise, the result of strncmp gets converted size_t, since size_t has greater rank than int. Since wordcmp is only ever used as a boolean condition, this poses no real issue, but presumably, it is meant to behave like the other *cmp function and return a value less than, equal to, or greater than 0 depending on the result of the comparison. --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index 9ff192e..9be5a62 100644 --- a/client.c +++ b/client.c @@ -294,7 +294,7 @@ static int wordcmp(const char *line, size_t i, const char *word) { size_t len = strcspn(line, " "); return len == strlen(word) ? strncmp(line, word, len) - : len - strlen(word); + : (int)len - (int)strlen(word); } static size_t strlcpyn(char *dst, const char *src, size_t cap, size_t len) { -- cgit 1.4.1