Skip to content

Commit 2109580

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 8c75b51 commit 2109580

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
@@ -72,8 +72,9 @@ enum fnm_char_class {
7272

7373
static bool fnm_cc_is_valid(const char *pattern, size_t psize, enum fnm_char_class *cc)
7474
{
75-
if (psize < 4 || *pattern != ':')
75+
if (psize < 4 || *pattern != ':') {
7676
return false;
77+
}
7778

7879
pattern++; /* skip ':' */
7980
psize--;
@@ -187,7 +188,6 @@ static inline int fnm_cc_match(int c, enum fnm_char_class cc)
187188
return 0;
188189
}
189190

190-
191191
static inline int foldcase(int ch, int flags)
192192
{
193193

@@ -207,13 +207,15 @@ static bool match_posix_class(const char **pattern, int test)
207207
const char *p = *pattern;
208208
size_t remaining = strlen(p);
209209

210-
if (!fnm_cc_is_valid(p, remaining, &cc))
210+
if (!fnm_cc_is_valid(p, remaining, &cc)) {
211211
return false;
212+
}
212213

213214
/* move pattern pointer past ":]" */
214215
const char *end = strstr(p, ":]");
215-
if (end)
216+
if (end) {
216217
*pattern = end + 2;
218+
}
217219

218220
return fnm_cc_match(test, cc);
219221
}
@@ -262,9 +264,14 @@ static const char *rangematch(const char *pattern, int test, int flags)
262264
ok = true;
263265
continue;
264266
} else {
265-
// skip over class if unrecognized
266-
while (*pattern && !(*pattern == ':' && *(pattern+1) == ']')) pattern++;
267-
if (*pattern) pattern += 2;
267+
/* skip over class if unrecognized */
268+
while (*pattern && !(*pattern == ':' && *(pattern + 1) == ']')) {
269+
pattern++;
270+
}
271+
272+
if (*pattern) {
273+
pattern += 2;
274+
}
268275
continue;
269276
}
270277
}

0 commit comments

Comments
 (0)