Re: [PATCH 09/61] bootwrapper: Add dt_is_compatible().

From: Milton Miller <hidden>
Date: 2007-07-18 15:43:28

In-Reply-To: [ref]

On Wed Jul 18 11:33:06 EST 2007, Scott Wood wrote:
+int dt_is_compatible(void *node, const char *compat)
+{
+       char *buf = (char *)prop_buf;
+       int compat_len = strlen(compat);
+       int len, pos;
+
+       len = getprop(node, "compatible", buf, MAX_PROP_LEN);
+       if (len < 0)
+               return 0;
+
+       for (pos = 0; pos + compat_len < len; pos++) {
+               if (!strcmp(buf + pos, compat))
+                       return 1;
+
+               while (buf[pos] && pos + compat_len < len)
+                       pos++;
This is buggy: if you are searching for "ns16550" and the compatable is 
"fsl,1234\0commons16550" this code will incorrectly says its 
compatable.

Comparing pos < len instead will do the right thing, at the cost of a 
few iterations of the loop.
+       }
+
+       return 0;
milton
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help