All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2/8] device tree: correctly ignore unit-address when matching nodes by name
Date: Wed, 14 Mar 2012 10:48:58 +0000	[thread overview]
Message-ID: <4F60779A.2090905@citrix.com> (raw)
In-Reply-To: <1331719214.23971.359.camel@zakaz.uk.xensource.com>

On 14/03/12 10:00, Ian Campbell wrote:
> On Tue, 2012-02-28 at 16:54 +0000, David Vrabel wrote:
>> From: David Vrabel <david.vrabel@citrix.com>
>>
>> When matching node by their name, correctly ignore the unit address
>> (@...) part of the name.  Previously, a "memory-controller" node would
>> be incorrectly matched as a "memory" node.
> 
> Are we reinventing this ourselves or is this derived from the Linux (or
> other) version of similar code?

Linux doesn't have an equivalent node_matches() function.  Linux could
do with one as it open-codes a bunch of these comparisons.

>> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
>> index d50cb9c..e5df748 100644
>> --- a/xen/common/device_tree.c
>> +++ b/xen/common/device_tree.c
>> @@ -24,6 +24,20 @@
>>  struct dt_early_info __initdata early_info;
>>  void *device_tree_flattened;
>>  
>> +static bool_t __init node_matches(const void *fdt, int node, const char *match)
>> +{
>> +    const char *name;
>> +    size_t len;
>> +
>> +    name = fdt_get_name(fdt, node, NULL);
>> +    len = strlen(match);
>> +
>> +    /* Match both "match" and "match@..." patterns but not
>> +       "match-foo". */
>> +    return strncmp(name, match, len) == 0
>> +        && (name[len] == '@' || name[len] == '\0');
> 
> How can name[len] == '@' when len came from strlen? Wouldn't you need
> some sort of strchr construct?

I can rename len to match_len if you think it makes it clearer.

David

  reply	other threads:[~2012-03-14 10:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 16:54 [PATCH 0/8] arm: pass a device tree to dom0 David Vrabel
2012-02-28 16:54 ` [PATCH 1/8] arm: add generated files to .gitignore and .hgignore David Vrabel
2012-03-14  9:53   ` Ian Campbell
2012-02-28 16:54 ` [PATCH 2/8] device tree: correctly ignore unit-address when matching nodes by name David Vrabel
2012-03-14 10:00   ` Ian Campbell
2012-03-14 10:48     ` David Vrabel [this message]
2012-02-28 16:54 ` [PATCH 3/8] device tree: add device_tree_for_each_node() David Vrabel
2012-03-14 10:08   ` Ian Campbell
2012-03-14 11:01     ` David Vrabel
2012-03-14 11:09       ` Ian Campbell
2012-02-28 16:54 ` [PATCH 4/8] device tree: add device_tree_dump() to print a flat device tree David Vrabel
2012-03-14 10:11   ` Ian Campbell
2012-02-28 16:54 ` [PATCH 5/8] arm: remove the hack for loading vmlinux images David Vrabel
2012-03-14 10:17   ` Ian Campbell
2012-03-14 10:51     ` David Vrabel
2012-02-28 16:54 ` [PATCH 6/8] device tree, arm: supply a flat device tree to dom0 David Vrabel
2012-03-14 10:44   ` Ian Campbell
2012-03-14 11:17     ` David Vrabel
2012-03-14 13:00       ` Ian Campbell
2012-02-28 16:54 ` [PATCH 7/8] arm: use bootargs for the command line David Vrabel
2012-03-14 10:46   ` Ian Campbell
2012-03-14 11:26     ` David Vrabel
2012-02-28 16:54 ` [PATCH 8/8] arm: add dom0_mem command line argument David Vrabel
2012-03-14 10:48   ` Ian Campbell
2012-03-14 11:27     ` David Vrabel

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=4F60779A.2090905@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.