[PATCH 09/61] bootwrapper: Add dt_is_compatible().
Milton Miller
miltonm at bga.com
Thu Jul 19 02:20:41 EST 2007
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
More information about the Linuxppc-dev
mailing list