Skip to content

Commit 9cd4353

Browse files
committed
chore(fnmatch.c): resolved SonarQube issues
Signed-off-by: Spago123 <harun.spago.code@gmail.com>
1 parent dd6ce78 commit 9cd4353

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lib/posix/options/fnmatch.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ static bool match_posix_class(const char **pattern, int test) {
115115
};
116116

117117
const char *p = *pattern;
118-
if (*p != ':' ) return false;
118+
if (*p != ':' ) {
119+
return false;
120+
}
119121
p++;
120122
for (size_t i = 0; i < sizeof(classes)/sizeof(classes[0]); i++) {
121123
size_t len = strlen(classes[i].name);
122-
if (strncmp(p, classes[i].name, len) == 0 && p[len] == ':') {
123-
if (p[len+1] == ']') {
124-
*pattern = p + len + 2; // move past ":]"
124+
if (strncmp(p, classes[i].name, len) == 0 && p[len] == ':' && p[len+1] == ']') {
125+
*pattern = p + len + 2; /* move past ":]" */
125126
return classes[i].func(test);
126-
}
127127
}
128128
}
129129
return false;
@@ -173,9 +173,15 @@ static const char *rangematch(const char *pattern, int test, int flags)
173173
ok = true;
174174
continue;
175175
} else {
176-
// skip over class if unrecognized
177-
while (*pattern && !(*pattern == ':' && *(pattern+1) == ']')) pattern++;
178-
if (*pattern) pattern += 2;
176+
/* skip over class if unrecognized */
177+
while (*pattern && !(*pattern == ':' && *(pattern+1) == ']')) {
178+
pattern++;
179+
}
180+
181+
if (*pattern)
182+
{
183+
pattern += 2;
184+
}
179185
continue;
180186
}
181187
}

0 commit comments

Comments
 (0)