how can I declare a char[][] module parameter?
Hello,
I have asked this question on IRC, but got no response. So I ask my question here.
I am currently converting the wireless drivers in drivers/net/wireless/ to the new module parameter declaring scheme.
So far there were no problems.
The following parameter declaration is giving me headaches, though:
(from drivers/net/wireless/wavelan.p.h):
static char name[4][IFNAMSIZ];
MODULE_PARM(name, "1-4c" __MODULE_STRING(IFNAMSIZ));Note: __MODULE_STRING(IFNAMSIZ) expands to '"16"'
This is the best conversion I came up with, but it discards information:
module_param_array(name, charp, WAVELAN_P_NAME_LEN, 0444);
How can I declare an array of char*, without loosing the information that each char* points to a buffer of IFNAMESIZ bytes? Do I need to declare a custom parameter type?
Thanks
stefan
Signature · 2 lines
Give me a fish and I will eat today. Teach me to fish and I will eat forever.
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 6 lines · Stefan Sperling
This is the best conversion I came up with, but it discards information:
module_param_array(name, charp, WAVELAN_P_NAME_LEN, 0444);How can I declare an array of char*, without loosing the information that each char* points to a buffer of IFNAMESIZ bytes?
You don't need that information. The parameter is used in only one place, and there, you can use strncpy instead of memcpy to access it.
It probably wasn't a particularly good idea to make the interface name a module parameter anyway, but it's too late for that decision now.
Arnd <><
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Stefan Sperling
This is the best conversion I came up with, but it discards information:
module_param_array(name, charp, WAVELAN_P_NAME_LEN, 0444);How can I declare an array of char*, without loosing the information that each char* points to a buffer of IFNAMESIZ bytes?
You don't need that information. The parameter is used in only one place, and there, you can use strncpy instead of memcpy to access it.
I'll use strlcpy.
While this is not a very generic solution (i.e. does not apply to all possible cases where a module parameter is a char[][]), it is adequate enough in my case :-)
Thanks a lot for your help!
stefan
Signature · 6 lines
Give me a fish and I will eat today. Teach me to fish and I will eat forever. _______________________________________________ Kernel-janitors mailing list [email protected] http://lists.osdl.org/mailman/listinfo/kernel-janitors