The use of KOBJ_NAME_LEN
Subsystems (2)
Hi,
Does the KOBJ_NAME_LEN really means the limit of kobject name length? seems not . And if it's true, is the KOBJ_NAME_LEN of 20 enough to use?
In the kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated.
/**
* kobject_set_name - Set the name of an object * @kobj: object. * @fmt: format string used to build the name * * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated * string that @kobj->k_name points to. Otherwise, use the static * @kobj->name array.
*/
Regards
dave
Quoted 6 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated./**
Quoted 8 lines
* kobject_set_name - Set the name of an object * @kobj: object. * @fmt: format string used to build the name * * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated * string that @kobj->k_name points to. Otherwise, use the static * @kobj->name array.*/
the comment seems fairly clear -- if the name is sufficiently short, it's stored in the static array. if not, then it's stored in dynamically allocated space.
rday
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
Quoted 18 lines · Robert P. J. Day
Quoted 6 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated./**
Quoted 8 lines
* kobject_set_name - Set the name of an object * @kobj: object. * @fmt: format string used to build the name * * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated * string that @kobj->k_name points to. Otherwise, use the static * @kobj->name array.*/
Quoted 3 lines
the comment seems fairly clear -- if the name is sufficiently short, it's stored in the static array. if not, then it's stored in dynamically allocated space.
Yes, It's clear, but it is not the topic I talk about. Please look at the KOBJ_NAME_LEN macro usage.
Quoted 10 lines
rday
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADAhttp://crashcourse.ca
========================================================================
Quoted 17 lines · Robert P. J. Day
Quoted 6 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated./**
Quoted 8 lines
* kobject_set_name - Set the name of an object * @kobj: object. * @fmt: format string used to build the name * * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated * string that @kobj->k_name points to. Otherwise, use the static * @kobj->name array.*/
Quoted 3 lines
the comment seems fairly clear -- if the name is sufficiently short, it's stored in the static array. if not, then it's stored in dynamically allocated space.
Unfortunately, it's totally wrong, the code was updated by the comment wasn't, sorry. See my patch to fix this.
thanks,
greg k-h
Quoted 18 lines · Greg KH
Quoted 17 lines · Robert P. J. Day
Quoted 14 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated./**
* kobject_set_name - Set the name of an object * @kobj: object. * @fmt: format string used to build the name * * If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated * string that @kobj->k_name points to. Otherwise, use the static * @kobj->name array.*/
Quoted 6 lines
Quoted 3 lines
the comment seems fairly clear -- if the name is sufficiently short, it's stored in the static array. if not, then it's stored in dynamically allocated space.
Unfortunately, it's totally wrong, the code was updated by the comment wasn't, sorry. See my patch to fix this.
ah, quite right, now i see what dave was talking about.
rday
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
Quoted 3 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?
No, not anymore, the kobject name is totally dynamic.
Quoted 2 lines
In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated.
Here's a patch below for the comment updating it.
I also have a patch in my -mm series that takes away the 1024 character limit, but for 2.6.24 we'll have to live with it :)
thanks,
greg k-h
--- lib/kobject.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/kobject.c +6 -6
@@ -234,13 +234,13 @@ int kobject_register(struct kobject * ko/** -* kobject_set_name - Set the name of an object -* @kobj: object. -* @fmt: format string used to build the name +* kobject_set_name - Set the name of a kobject +* @kobj: kobject to name +* @fmt: format string used to build the name * -* If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated -* string that @kobj->k_name points to. Otherwise, use the static -* @kobj->name array. +* This sets the name of the kobject. If you have already added the +* kobject to the system, you must call kobject_rename() in order to +* change the name of the kobject. */ int kobject_set_name (struct kobject * kobj,const char * fmt, ...) {
Quoted 6 lines · Greg KH
Quoted 3 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?No, not anymore, the kobject name is totally dynamic.
Eh, Why does this macro still exist? If KOBJ_NAME_LEN is really needed, maybe it should be renamed to something else to avoid misleading.
Quoted 5 lines
Quoted 3 lines
In the
kobject_set_name, the limit is 1024. Looks like either the comment or the code should be updated.Here's a patch below for the comment updating it.
Thanks
Quoted 36 lines
I also have a patch in my -mm series that takes away the 1024 character limit, but for 2.6.24 we'll have to live with it :)
thanks,
greg k-h
--- lib/kobject.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)lib/kobject.c +6
-6@@ -234,13 +234,13 @@ int kobject_register(struct kobject * ko/** -* kobject_set_name - Set the name of an object -* @kobj: object. -* @fmt: format string used to build the name +* kobject_set_name - Set the name of a kobject +* @kobj: kobject to name +* @fmt: format string used to build the name * -* If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated -* string that @kobj->k_name points to. Otherwise, use the static -* @kobj->name array. +* This sets the name of the kobject. If you have already added the +* kobject to the system, you must call kobject_rename() in order to +* change the name of the kobject. */ int kobject_set_name (struct kobject * kobj,const char * fmt, ...) {
Quoted 11 lines · Dave Young
Quoted 6 lines · Greg KH
Quoted 3 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?No, not anymore, the kobject name is totally dynamic.
Eh, Why does this macro still exist? If
KOBJ_NAME_LENis really needed, maybe it should be renamed to something else to avoid misleading.
Right now other .h files use it also. It isn't hurting anything for now, and Kay has some patches he is working on to get rid of the static bus_id array, which will then let us get rid of that define entirely.
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 8 lines · Dave Young
Quoted 6 lines · Greg KH
Quoted 3 lines · Dave Young
Hi,
Does theKOBJ_NAME_LENreally means the limit of kobject name length? seems not . And if it's true, is theKOBJ_NAME_LENof 20 enough to use?No, not anymore, the kobject name is totally dynamic.
Quoted 8 lines
Quoted 3 lines
Eh, Why does this macro still exist? If
KOBJ_NAME_LENis really needed, maybe it should be renamed to something else to avoid misleading.Right now other .h files use it also. It isn't hurting anything for now, and Kay has some patches he is working on to get rid of the static
bus_idarray, which will then let us get rid of that define entirely.
Good to know, thanks!
Quoted 4 lines
thanks,
greg k-h