public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga•com>
To: Scott Wood <scottwood@freescale•com>
Cc: ppcdev <linuxppc-dev@ozlabs•org>,
	Paul Mackerras <paulus@samba•org>,
	David Gibson <david@gibson•dropbear.id.au>
Subject: Re: [PATCH 09/61] bootwrapper: Add dt_is_compatible().
Date: Wed, 18 Jul 2007 10:42:56 -0500	[thread overview]
Message-ID: <336b7f0b48526c8feeb9914de32cc9d1@bga.com> (raw)

In-Reply-To: <20070718013137.GA15217@ld0162-tx32•am.freescale.net>

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

             reply	other threads:[~2007-07-18 15:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 15:42 Milton Miller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-07-18  1:31 [PATCH 01/61] Use strcasecmp() rather than strncasecmp() when determining device node compatibility Scott Wood
2007-07-18  1:33 ` [PATCH 09/61] bootwrapper: Add dt_is_compatible() Scott Wood
2007-07-18 16:20   ` Milton Miller
2007-07-18 18:24     ` Scott Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=336b7f0b48526c8feeb9914de32cc9d1@bga.com \
    --to=miltonm@bga$(echo .)com \
    --cc=david@gibson$(echo .)dropbear.id.au \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=paulus@samba$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox