From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: John Bonesio <bones-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: [PATCH 3/4] Allow nodes at the root to be specified by path as well as by label.
Date: Thu, 21 Oct 2010 17:03:48 +1100 [thread overview]
Message-ID: <20101021060348.GI6227@yookeroo> (raw)
In-Reply-To: <20101020214513.2985.76446.stgit@riker>
On Wed, Oct 20, 2010 at 02:45:13PM -0700, John Bonesio wrote:
> Changes to allow us to specify a node by it's path. A path can be used in
> place of a label.
>
> This is particularly useful when overriding existing nodes.
> This way we don't have to label every possible node in a device tree we know
> is a base device tree for a class of systems, and we know the tree will be
> modified for the specific systems.
[snip]
> diff --git a/livetree.c b/livetree.c
> index 21a4c48..bf8796b 100644
> --- a/livetree.c
> +++ b/livetree.c
> @@ -429,10 +429,28 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
>
> struct node *get_node_by_ref(struct node *tree, const char *ref)
> {
> + struct node *node;
> +
> if (ref[0] == '/')
> return get_node_by_path(tree, ref);
> - else
> + else {
> + /*
> + * Support finding a node reference that is rooted by
> + * a label reference.
> + *
> + * References rooted by a label have a '/' in them.
> + */
> + char *p = strchr(ref, '/');
So, this line is effectively un-const-ing part of the string that ref
points to.
> +
> + if (p) {
> + *p = '\0';
And, then you write to it. Not good at all. I'm afraid you're going
to have to use a strndup() here. Or else modify get_node_by_label()
to ignore text after a /.
> + node = get_node_by_label(tree, ref);
> + *p = '/';
> + return get_node_by_path(node, p+1);
> + }
> +
> return get_node_by_label(tree, ref);
> + }
> }
>
> cell_t get_node_phandle(struct node *root, struct node *node)
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
next prev parent reply other threads:[~2010-10-21 6:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 21:44 [PATCH 0/4] Series short description John Bonesio
2010-10-20 21:44 ` [PATCH 1/4] Create new and use new print_error that uses printf style formatting John Bonesio
2010-10-21 4:44 ` Grant Likely
[not found] ` <20101021044410.GD13335-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-11-13 20:40 ` Jon Loeliger
2010-10-20 21:45 ` [PATCH 2/4] Implements new features for updating existing device tree nodes John Bonesio
2010-10-21 4:47 ` Grant Likely
2010-10-21 5:58 ` David Gibson
2010-10-20 21:45 ` [PATCH 3/4] Allow nodes at the root to be specified by path as well as by label John Bonesio
2010-10-21 4:36 ` Grant Likely
2010-10-21 6:03 ` David Gibson [this message]
2010-10-20 21:45 ` [PATCH 4/4] Create a new property value that means 'undefined' John Bonesio
2010-10-21 5:20 ` Grant Likely
[not found] ` <20101021052053.GF13335-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-21 6:19 ` David Gibson
2010-10-21 15:20 ` John Bonesio
2010-10-22 0:38 ` David Gibson
2010-10-22 19:42 ` John Bonesio
2010-10-21 6:14 ` David Gibson
2010-10-22 19:50 ` John Bonesio
2010-10-25 0:44 ` David Gibson
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=20101021060348.GI6227@yookeroo \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=bones-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
/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.