linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* The use of KOBJ_NAME_LEN
@ 2007-12-04  6:45 Dave Young
  2007-12-04  6:50 ` Robert P. J. Day
  2007-12-04  7:46 ` Greg KH
  0 siblings, 2 replies; 9+ messages in thread
From: Dave Young @ 2007-12-04  6:45 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  6:45 The use of KOBJ_NAME_LEN Dave Young
@ 2007-12-04  6:50 ` Robert P. J. Day
  2007-12-04  7:17   ` Dave Young
  2007-12-04  7:46   ` Greg KH
  2007-12-04  7:46 ` Greg KH
  1 sibling, 2 replies; 9+ messages in thread
From: Robert P. J. Day @ 2007-12-04  6:50 UTC (permalink / raw)
  To: Dave Young; +Cc: gregkh, linux-kernel

On Tue, 4 Dec 2007, Dave Young wrote:

> 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.
>  */

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
========================================================================

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  6:50 ` Robert P. J. Day
@ 2007-12-04  7:17   ` Dave Young
  2007-12-04  7:46   ` Greg KH
  1 sibling, 0 replies; 9+ messages in thread
From: Dave Young @ 2007-12-04  7:17 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: gregkh, linux-kernel

On Dec 4, 2007 2:50 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
>
> On Tue, 4 Dec 2007, Dave Young wrote:
>
> > 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.
> >  */
>
> 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.

>
> rday
> ========================================================================
> Robert P. J. Day
> Linux Consulting, Training and Annoying Kernel Pedantry
> Waterloo, Ontario, CANADA
>
> http://crashcourse.ca
> ========================================================================
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  6:45 The use of KOBJ_NAME_LEN Dave Young
  2007-12-04  6:50 ` Robert P. J. Day
@ 2007-12-04  7:46 ` Greg KH
  2007-12-04  7:53   ` Dave Young
  1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2007-12-04  7:46 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-kernel

On Tue, Dec 04, 2007 at 02:45:47PM +0800, Dave Young wrote:
> 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?

No, not anymore, the kobject name is totally dynamic.

> 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(-)

--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -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, ...)
 {

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  6:50 ` Robert P. J. Day
  2007-12-04  7:17   ` Dave Young
@ 2007-12-04  7:46   ` Greg KH
  2007-12-04  8:02     ` Robert P. J. Day
  1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2007-12-04  7:46 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Dave Young, linux-kernel

On Tue, Dec 04, 2007 at 01:50:53AM -0500, Robert P. J. Day wrote:
> On Tue, 4 Dec 2007, Dave Young wrote:
> 
> > 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.
> >  */
> 
> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  7:46 ` Greg KH
@ 2007-12-04  7:53   ` Dave Young
  2007-12-04  8:20     ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Young @ 2007-12-04  7:53 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

On Dec 4, 2007 3:46 PM, Greg KH <gregkh@suse.de> wrote:
> On Tue, Dec 04, 2007 at 02:45:47PM +0800, Dave Young wrote:
> > 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?
>
> 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.

>
> > 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
>
> 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(-)
>
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -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, ...)
>  {
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  7:46   ` Greg KH
@ 2007-12-04  8:02     ` Robert P. J. Day
  0 siblings, 0 replies; 9+ messages in thread
From: Robert P. J. Day @ 2007-12-04  8:02 UTC (permalink / raw)
  To: Greg KH; +Cc: Dave Young, linux-kernel

On Mon, 3 Dec 2007, Greg KH wrote:

> On Tue, Dec 04, 2007 at 01:50:53AM -0500, Robert P. J. Day wrote:
> > On Tue, 4 Dec 2007, Dave Young wrote:
> >
> > > 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.
> > >  */
> >
> > 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
========================================================================

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  7:53   ` Dave Young
@ 2007-12-04  8:20     ` Greg KH
  2007-12-04  8:22       ` Dave Young
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2007-12-04  8:20 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-kernel

On Tue, Dec 04, 2007 at 03:53:15PM +0800, Dave Young wrote:
> On Dec 4, 2007 3:46 PM, Greg KH <gregkh@suse.de> wrote:
> > On Tue, Dec 04, 2007 at 02:45:47PM +0800, Dave Young wrote:
> > > 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?
> >
> > 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.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: The use of KOBJ_NAME_LEN
  2007-12-04  8:20     ` Greg KH
@ 2007-12-04  8:22       ` Dave Young
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Young @ 2007-12-04  8:22 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

On Dec 4, 2007 4:20 PM, Greg KH <gregkh@suse.de> wrote:
> On Tue, Dec 04, 2007 at 03:53:15PM +0800, Dave Young wrote:
> > On Dec 4, 2007 3:46 PM, Greg KH <gregkh@suse.de> wrote:
> > > On Tue, Dec 04, 2007 at 02:45:47PM +0800, Dave Young wrote:
> > > > 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?
> > >
> > > 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.
>
> 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.
>

Good to know, thanks!

> thanks,
>
> greg k-h
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-12-04  8:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-04  6:45 The use of KOBJ_NAME_LEN Dave Young
2007-12-04  6:50 ` Robert P. J. Day
2007-12-04  7:17   ` Dave Young
2007-12-04  7:46   ` Greg KH
2007-12-04  8:02     ` Robert P. J. Day
2007-12-04  7:46 ` Greg KH
2007-12-04  7:53   ` Dave Young
2007-12-04  8:20     ` Greg KH
2007-12-04  8:22       ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).