diff options
author | Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> | 2021-05-03 20:59:43 -0700 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-05-04 14:45:20 +1000 |
commit | ad4abfadb687060d047a9cff664b471c7effb3b1 (patch) | |
tree | 128d6799350f2bf14b0eb60ca8c1ba96d31f260d | |
parent | 09c6a6e88718de6b2ef646a015187605caa5789f (diff) | |
download | dtc-ad4abfadb687060d047a9cff664b471c7effb3b1.zip dtc-ad4abfadb687060d047a9cff664b471c7effb3b1.tar.gz dtc-ad4abfadb687060d047a9cff664b471c7effb3b1.tar.bz2 |
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>
-rw-r--r-- | checks.c | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -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, |