checks: replace strstr and strrchr with strends
Makes the logic more clear Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> Message-Id: <20210504035944.8453-4-ilya.lipnitskiy@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
09c6a6e887
commit
ad4abfadb6
1 changed files with 7 additions and 18 deletions
25
checks.c
25
checks.c
|
@ -687,8 +687,7 @@ static void check_names_is_string_list(struct check *c, struct dt_info *dti,
|
|||
struct property *prop;
|
||||
|
||||
for_each_property(node, prop) {
|
||||
const char *s = strrchr(prop->name, '-');
|
||||
if (!s || !streq(s, "-names"))
|
||||
if (!strends(prop->name, "-names"))
|
||||
continue;
|
||||
|
||||
c->data = prop->name;
|
||||
|
@ -1488,24 +1487,17 @@ WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sen
|
|||
|
||||
static bool prop_is_gpio(struct property *prop)
|
||||
{
|
||||
char *str;
|
||||
|
||||
/*
|
||||
* *-gpios and *-gpio can appear in property names,
|
||||
* so skip over any false matches (only one known ATM)
|
||||
*/
|
||||
if (strstr(prop->name, ",nr-gpios"))
|
||||
if (strends(prop->name, ",nr-gpios"))
|
||||
return false;
|
||||
|
||||
str = strrchr(prop->name, '-');
|
||||
if (str)
|
||||
str++;
|
||||
else
|
||||
str = prop->name;
|
||||
if (!(streq(str, "gpios") || streq(str, "gpio")))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return strends(prop->name, "-gpios") ||
|
||||
streq(prop->name, "gpios") ||
|
||||
strends(prop->name, "-gpio") ||
|
||||
streq(prop->name, "gpio");
|
||||
}
|
||||
|
||||
static void check_gpios_property(struct check *c,
|
||||
|
@ -1540,13 +1532,10 @@ static void check_deprecated_gpio_property(struct check *c,
|
|||
struct property *prop;
|
||||
|
||||
for_each_property(node, prop) {
|
||||
char *str;
|
||||
|
||||
if (!prop_is_gpio(prop))
|
||||
continue;
|
||||
|
||||
str = strstr(prop->name, "gpio");
|
||||
if (!streq(str, "gpio"))
|
||||
if (!strends(prop->name, "gpio"))
|
||||
continue;
|
||||
|
||||
FAIL_PROP(c, dti, node, prop,
|
||||
|
|
Loading…
Reference in a new issue