[PATCH] of: module: remove strlen() call in of_modalias()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 comapt string fit into the remaining buffer
space...

Signed-off-by: Sergey Shtylyov <s.shtylyov@xxxxxx>

---
The patch is against the dt/next branch of Rob Herring's linux.git repo...

 drivers/of/module.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux/drivers/of/module.c
===================================================================
--- linux.orig/drivers/of/module.c
+++ linux/drivers/of/module.c
@@ -35,12 +35,10 @@ ssize_t of_modalias(const struct device_
 	str += csize;
 
 	of_property_for_each_string(np, "compatible", p, compat) {
-		csize = strlen(compat) + 1;
+		csize = snprintf(str, len, "C%s", compat);
 		tsize += csize;
 		if (csize >= len)
 			continue;
-
-		csize = snprintf(str, len, "C%s", compat);
 		for (c = str; c; ) {
 			c = strchr(c, ' ');
 			if (c)




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux