Re: [PATCH 3/5] of: Correct property name comparison in __of_add_property()

From: Zijun Hu
Date: Tue Feb 25 2025 - 10:06:17 EST


On 2025/2/25 22:38, Rob Herring wrote:
> On Mon, Feb 24, 2025 at 10:27:59PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>>
>> __of_add_property() compares property name by strcmp(), and that is
>> improper for SPARC which wants strcasecmp().
> Except that 'name' is the nodename (usually, with a few rare
> exceptions). Sparc node names are case sensitive, so strcmp was correct.

Here, it is property's name and NOT node's name.

arch/sparc/include/asm/prom.h:

#define of_compat_cmp(s1, s2, l) strncmp((s1), (s2), (l))
#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) //SPARC HERE
#define of_node_cmp(s1, s2) strcmp((s1), (s2))


include/linux/of.h:
/* Default string compare functions, Allow arch asm/prom.h to override */
#if !defined(of_compat_cmp)
#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
#define of_prop_cmp(s1, s2) strcmp((s1), (s2)) // others HERE
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
#endif

actually, later __of_update_property() and __of_find_property() use
of_prop_cmp() instead of strcmp() to compare property name.

perhaps, compatible and node name also have similar issues in current
OF codes.