Browse Source

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.
tags/1.0p1
Michael Forney 3 weeks ago
parent
commit
a17b389796
Signed by: C. McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      client.c

+ 1
- 1
client.c View File

@@ -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) {

Loading…
Cancel
Save