mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-16 01:54:00 +00:00
of: module: remove strlen() call in of_modalias()
In of_modalias(), there's no dire need to call strlen() (and then add 1 to its result to account for the 'C' char preceding the compat string). Replace that strlen() with snprintf() (currently below it) -- this way, we always try to print the compat string but then only advance the str and len parameters iff the compat string fit into the remaining buffer space... Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Link: https://lore.kernel.org/r/471418be-5d2f-4d14-bd9e-9e8f0526241f@omp.ru Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
parent
00c9a452a2
commit
2e030910fa
@ -35,12 +35,10 @@ ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
|
|||||||
str += csize;
|
str += csize;
|
||||||
|
|
||||||
of_property_for_each_string(np, "compatible", p, compat) {
|
of_property_for_each_string(np, "compatible", p, compat) {
|
||||||
csize = strlen(compat) + 1;
|
csize = snprintf(str, len, "C%s", compat);
|
||||||
tsize += csize;
|
tsize += csize;
|
||||||
if (csize >= len)
|
if (csize >= len)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
csize = snprintf(str, len, "C%s", compat);
|
|
||||||
for (c = str; c; ) {
|
for (c = str; c; ) {
|
||||||
c = strchr(c, ' ');
|
c = strchr(c, ' ');
|
||||||
if (c)
|
if (c)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user