Hi Bart, > Date: 2026-11-10 10:00:42+0100 > From: Bartosz Golaszewski > [...] > > > > > + names[i] = kstrdup(prop->name, GFP_KERNEL); > > > > > > > > Can property be statically defined somewhere? We might want to also optimize > > > > these duplications with const variant (here or elsewhere, for fwnode generic > > > > path, I believe). > > > > > > Please rephrase because I'm not quite following what you're saying. > > > > Can prop->name come from something that is declared as > > > > static const ... foo = { > > ... .name = "bar"; > > }; > > > > You can't know it for every instance of struct fwnode_handle, so the > answer is: no. > > PS: is there a way of using match_string() with non-const data? Given the definition here: $ grepc match_string . ./include/linux/string.h:int match_string(const char * const *array, size_t n, const char *string); ./lib/string_helpers.c:int match_string(const char * const *array, size_t n, const char *string) { int index; const char *item; for (index = 0; index < n; index++) { item = array[index]; if (!item) break; if (!strcmp(item, string)) return index; } return -EINVAL; } You should be able to call it with a cast. It's dangerous, but technically it works. I'm not encouraging it, though. :) char **strings; ... i = match_string((const char *const *) strings, n, "foo"); This is a historic problem in C, which was solved in C++. I have a proposal paper for the C Committee for solving it as in C++: This paper will be discussed (and probably voted in) in the next meeting of the committee (which happens next week), so there's a chance that this will be solved for C2y, and thus the cast will no longer be necessary. The history of why this is not allowed in C but is in C++ is, as far as I've been told, the following: Back before C and C++ were standardized, C++ invented const, with rules slightly more allowing than what they are now. This was going to be standardized first in C89. But very close to the release of C89, they realized about the danger of converting a const char** to a char** implicitly. They were so close to the release, that they opted for the safest approach: disallow any non-trivial conversions. Later, while standardizing C++98, they realized we could allow a few more conversions safely, and so they did. C could have taken advantage of that, and pick C++ rules in C99 or C11, but for some reason, nobody proposed that. I'm proposing it now. :) We've already discussed this proposal informally within the committee for some a year and a half, and there seems to be consensus that we want it. We're only being careful about the specific language. But I think I finally got it, and it will go in next week. Have a lovely day! Alex > > Bart > --