The variable name 'match' naturally implies a binary
state e.g. true or false and is not appropriate for
the indexing of a string literal, it is better to
avoid this ambiguity and use a name that properly
conveys its purpose, in this case 'idx' is a better
choice.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
static int is_local_in_file(const char *user, const char *filename)
{
int local = 0;
- size_t match;
+ size_t idx;
int chin, skip;
FILE *f;
if (!f)
return -1;
- match = 0;
+ idx = 0;
skip = 0;
while ((chin = fgetc(f)) != EOF) {
if (skip) {
if (chin == '\n') {
/* Start matching username at the next char. */
skip = 0;
- match = 0;
+ idx = 0;
}
} else {
if (chin == ':') {
- if (user[match] == '\0') {
+ if (user[idx] == '\0') {
/* Success. */
local = 1;
/* next line has no test coverage,
/* This line contains no colon; it's
* malformed. No skip since we are already
* at the start of the next line. */
- match = 0U;
- } else if (chin != user[match]) {
+ idx = 0;
+ } else if (chin != user[idx]) {
/* username does not match. */
skip = 1;
} else {
- ++match;
+ ++idx;
}
}
}