Thread (7 messages) flat view 7 messages, 2 authors, 2023-04-03

Re: [Skiboot] [PATCH V4 1/3] core/device: Add function to return child node using name at substring "@"

From: Reza Arbab <hidden>
Date: 2023-03-22 20:14:11

Hi Athira,

On Mon, Mar 06, 2023 at 09:09:11AM +0530, Athira Rajeev wrote:
Add a function dt_find_by_name_substr() that returns the child node if
it matches till first occurence at "@" of a given name, otherwise NULL.
Given this summary, I don't understand the following:
+	assert(dt_find_by_name_substr(root, "node@1") == addr1);
+	assert(dt_find_by_name_substr(root, "node0_1@2") == addr2);
Is this behavior required? I don't think it makes sense to call this 
function with a second argument containing '@', so I wouldn't expect it 
to match anything in these cases. The function seems to specifically 
enable it:
+struct dt_node *dt_find_by_name_substr(struct dt_node *root, const char *name)
+{
[snip]
+      node = strdup(name);
+      if (!node)
+              return NULL;
+      node = strtok(node, "@");
Seems like you could get rid of this and just use name as-is.

I was curious about something else; say we have 'node@1' and 'node@2'.  
Is there an expectation of which it should match?

     addr1 = dt_new_addr(root, "node", 0x1);
     addr2 = dt_new_addr(root, "node", 0x2);
     assert(dt_find_by_name_substr(root, "node") == ???????);
                                                    ^^^^^^^
+/* Find a child node by name and substring */
+struct dt_node *dt_find_by_name_substr(struct dt_node *root, const char *name);
I think this name fit better in previous versions of the patch, but 
since you're specifically looking for '@' now, maybe call it something 
like dt_find_by_name_before_addr?

-- 
Reza Arbab
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help