Skip to content

Commit fb05052

Browse files
committed
posix: c_lib_ext: fnmatch: resolved SonarQube issues
Resolved all sonar qube issues Signed-off-by: Harun Spago <harun.spago.code@gmail.com>
1 parent 1ffe196 commit fb05052

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lib/posix/c_lib_ext/fnmatch.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ enum fnm_char_class {
7171

7272
static bool fnm_cc_is_valid(const char *pattern, size_t psize, enum fnm_char_class *cc)
7373
{
74-
if (psize < 4 || *pattern != ':')
74+
if (psize < 4 || *pattern != ':') {
7575
return false;
76+
}
7677

7778
pattern++; /* skip ':' */
7879
psize--;
@@ -178,7 +179,6 @@ static inline int fnm_cc_match(int c, enum fnm_char_class cc)
178179
return 0;
179180
}
180181

181-
182182
static inline int foldcase(int ch, int flags)
183183
{
184184

@@ -198,13 +198,15 @@ static bool match_posix_class(const char **pattern, int test)
198198
const char *p = *pattern;
199199
size_t remaining = strlen(p);
200200

201-
if (!fnm_cc_is_valid(p, remaining, &cc))
201+
if (!fnm_cc_is_valid(p, remaining, &cc)) {
202202
return false;
203+
}
203204

204205
/* move pattern pointer past ":]" */
205206
const char *end = strstr(p, ":]");
206-
if (end)
207+
if (end) {
207208
*pattern = end + 2;
209+
}
208210

209211
return fnm_cc_match(test, cc);
210212
}
@@ -253,9 +255,14 @@ static const char *rangematch(const char *pattern, int test, int flags)
253255
ok = true;
254256
continue;
255257
} else {
256-
// skip over class if unrecognized
257-
while (*pattern && !(*pattern == ':' && *(pattern+1) == ']')) pattern++;
258-
if (*pattern) pattern += 2;
258+
/* skip over class if unrecognized */
259+
while (*pattern && !(*pattern == ':' && *(pattern + 1) == ']')) {
260+
pattern++;
261+
}
262+
263+
if (*pattern) {
264+
pattern += 2;
265+
}
259266
continue;
260267
}
261268
}

0 commit comments

Comments
 (0)