[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2/8] device tree: correctly ignore unit-address when matching nodes by name
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@xxxxxxxxxx> >> >> 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 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |