All of lore.kernel.org
 help / color / mirror / Atom feed
* kobject_add unreachable code
@ 2006-12-29  6:47 Martin Stoilov
  2006-12-29 13:50 ` Olaf Dietsche
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Stoilov @ 2006-12-29  6:47 UTC (permalink / raw)
  To: linux-kernel

The following code in kobject_add
    if (!kobj->k_name)
        kobj->k_name = kobj->name;
    if (!kobj->k_name) {
        pr_debug("kobject attempted to be registered with no name!\n");
        WARN_ON(1);
        return -EINVAL;
    }

doesn't look right to me. The second 'if' statement looks useless after
the assignment in the first one. May be it was meant to be like:
if (!*kobj->k_name)

See the full patch:

--- linux-2.6.20-rc2/lib/kobject.c      2006-12-28 19:59:56.000000000 -0800
+++ linux-2.6.20-rc2.mod/lib/kobject.c  2006-12-28 20:00:25.000000000 -0800
@@ -161,19 +161,19 @@
 int kobject_add(struct kobject * kobj)
 {
        int error = 0;
        struct kobject * parent;

        if (!(kobj = kobject_get(kobj)))
                return -ENOENT;
        if (!kobj->k_name)
                kobj->k_name = kobj->name;
-       if (!kobj->k_name) {
+       if (!*kobj->k_name) {
                pr_debug("kobject attempted to be registered with no
name!\n");
                WARN_ON(1);
                return -EINVAL;
        }
        parent = kobject_get(kobj->parent);


-Martin


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

* Re: kobject_add unreachable code
  2006-12-29  6:47 kobject_add unreachable code Martin Stoilov
@ 2006-12-29 13:50 ` Olaf Dietsche
  2006-12-29 17:15   ` Martin Stoilov
  0 siblings, 1 reply; 6+ messages in thread
From: Olaf Dietsche @ 2006-12-29 13:50 UTC (permalink / raw)
  To: Martin Stoilov; +Cc: linux-kernel

Martin Stoilov <mstoilov@odesys.com> writes:

> The following code in kobject_add
>     if (!kobj->k_name)
>         kobj->k_name = kobj->name;
>     if (!kobj->k_name) {
>         pr_debug("kobject attempted to be registered with no name!\n");
>         WARN_ON(1);
>         return -EINVAL;
>     }
>
> doesn't look right to me. The second 'if' statement looks useless after
> the assignment in the first one. May be it was meant to be like:
> if (!*kobj->k_name)

The second test is true, if kobj->name is NULL as well.

Regards, Olaf.

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

* Re: kobject_add unreachable code
  2006-12-29 13:50 ` Olaf Dietsche
@ 2006-12-29 17:15   ` Martin Stoilov
  2006-12-29 17:36     ` Martin Stoilov
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Stoilov @ 2006-12-29 17:15 UTC (permalink / raw)
  To: Olaf Dietsche; +Cc: linux-kernel

Olaf Dietsche wrote:
> Martin Stoilov <mstoilov@odesys.com> writes:
>
>   
>> The following code in kobject_add
>>     if (!kobj->k_name)
>>         kobj->k_name = kobj->name;
>>     if (!kobj->k_name) {
>>         pr_debug("kobject attempted to be registered with no name!\n");
>>         WARN_ON(1);
>>         return -EINVAL;
>>     }
>>
>> doesn't look right to me. The second 'if' statement looks useless after
>> the assignment in the first one. May be it was meant to be like:
>> if (!*kobj->k_name)
>>     
>
> The second test is true, if kobj->name is NULL as well.
>   
And how would that ever be true? kobj->name is a buffer inside kobj:

struct kobject <http://localhost/lxr/http/ident?i=kobject> {
	const char              * k_name;
	char                    name <http://localhost/lxr/http/ident?i=name>[KOBJ_NAME_LEN <http://localhost/lxr/http/ident?i=KOBJ_NAME_LEN>];

kobj->name will not be NULL, even if kobj itself is NULL.

> Regards, Olaf.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>   

-Martin

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

* Re: kobject_add unreachable code
  2006-12-29 17:15   ` Martin Stoilov
@ 2006-12-29 17:36     ` Martin Stoilov
  2006-12-29 17:45       ` Jan Engelhardt
  2006-12-29 20:49       ` Olaf Dietsche
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Stoilov @ 2006-12-29 17:36 UTC (permalink / raw)
  To: Olaf Dietsche; +Cc: linux-kernel

Martin Stoilov wrote:
> Olaf Dietsche wrote:
>   
>> Martin Stoilov <mstoilov@odesys.com> writes:
>>
>>   
>>     
>>> The following code in kobject_add
>>>     if (!kobj->k_name)
>>>         kobj->k_name = kobj->name;
>>>     if (!kobj->k_name) {
>>>         pr_debug("kobject attempted to be registered with no name!\n");
>>>         WARN_ON(1);
>>>         return -EINVAL;
>>>     }
>>>
>>> doesn't look right to me. The second 'if' statement looks useless after
>>> the assignment in the first one. May be it was meant to be like:
>>> if (!*kobj->k_name)
>>>     
>>>       
>> The second test is true, if kobj->name is NULL as well.
>>   
>>     
> And how would that ever be true? kobj->name is a buffer inside kobj:
>
> struct kobject <http://localhost/lxr/http/ident?i=kobject> {
> 	const char              * k_name;
> 	char                    name <http://localhost/lxr/http/ident?i=name>[KOBJ_NAME_LEN <http://localhost/lxr/http/ident?i=KOBJ_NAME_LEN>];
>
> kobj->name will not be NULL, even if kobj itself is NULL.
>   

Oops, I am sorry for sending badly formated text! Here it is:

I don't understand how would that ever be true? kobj->name is a buffer inside kobj:

struct kobject {
    const char      * k_name;
    char            name[KOBJ_NAME_LEN];

kobj->name will not be NULL, even if kobj itself is NULL.


>> Regards, Olaf.
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>>   
>>     
>
> -Martin
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>   


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

* Re: kobject_add unreachable code
  2006-12-29 17:36     ` Martin Stoilov
@ 2006-12-29 17:45       ` Jan Engelhardt
  2006-12-29 20:49       ` Olaf Dietsche
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Engelhardt @ 2006-12-29 17:45 UTC (permalink / raw)
  To: Martin Stoilov; +Cc: Olaf Dietsche, linux-kernel


On Dec 29 2006 09:36, Martin Stoilov wrote:
> Olaf Dietsche wrote:
>> Martin Stoilov <mstoilov@odesys.com> writes:
>>     
>>> The following code in kobject_add
>>>     if (!kobj->k_name)
>>>         kobj->k_name = kobj->name;
>>>     if (!kobj->k_name) {
>>>         pr_debug("kobject attempted to be registered with no name!\n");
>>>         WARN_ON(1);
>>>         return -EINVAL;
>>>     }
>>>
>>> doesn't look right to me. The second 'if' statement looks useless after
>>> the assignment in the first one. May be it was meant to be like:
>>> if (!*kobj->k_name)
>>>       
>> The second test is true, if kobj->name is NULL as well.
>
>I don't understand how would that ever be true? kobj->name is a buffer inside kobj:
>
>struct kobject {
>    const char      * k_name;
>    char            name[KOBJ_NAME_LEN];
>
>kobj->name will not be NULL, even if kobj itself is NULL.

So you probably found a bug. Maybe this was intended then?

     if (!kobj->k_name)
         kobj->k_name = kobj->name;
     if (*kobj->k_name == '\0') {
         pr_debug("kobject attempted to be registered with no name!\n");
         WARN_ON(1);
         return -EINVAL;
     }


	-`J'
-- 

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

* Re: kobject_add unreachable code
  2006-12-29 17:36     ` Martin Stoilov
  2006-12-29 17:45       ` Jan Engelhardt
@ 2006-12-29 20:49       ` Olaf Dietsche
  1 sibling, 0 replies; 6+ messages in thread
From: Olaf Dietsche @ 2006-12-29 20:49 UTC (permalink / raw)
  To: Martin Stoilov; +Cc: linux-kernel

Martin Stoilov <mstoilov@odesys.com> writes:

> Martin Stoilov wrote:
>> Olaf Dietsche wrote:
>>   
>>> Martin Stoilov <mstoilov@odesys.com> writes:
>>>
>>>   
>>>     
>>>> The following code in kobject_add
>>>>     if (!kobj->k_name)
>>>>         kobj->k_name = kobj->name;
>>>>     if (!kobj->k_name) {
>>>>         pr_debug("kobject attempted to be registered with no name!\n");
>>>>         WARN_ON(1);
>>>>         return -EINVAL;
>>>>     }
>>>>
>>>> doesn't look right to me. The second 'if' statement looks useless after
>>>> the assignment in the first one. May be it was meant to be like:
>>>> if (!*kobj->k_name)
>>>>     
>>>>       
>>> The second test is true, if kobj->name is NULL as well.
>>>   
>>>     
>> And how would that ever be true? kobj->name is a buffer inside kobj:
>>
>> struct kobject <http://localhost/lxr/http/ident?i=kobject> {
>> 	const char              * k_name;
>> 	char                    name <http://localhost/lxr/http/ident?i=name>[KOBJ_NAME_LEN <http://localhost/lxr/http/ident?i=KOBJ_NAME_LEN>];
>>
>> kobj->name will not be NULL, even if kobj itself is NULL.
>>   
>
> Oops, I am sorry for sending badly formated text! Here it is:
>
> I don't understand how would that ever be true? kobj->name is a buffer inside kobj:
>
> struct kobject {
>     const char      * k_name;
>     char            name[KOBJ_NAME_LEN];
>
> kobj->name will not be NULL, even if kobj itself is NULL.

Shame on me! I just looked at kobject_add() without a clue about struct
kobject. You're right, of course.

Regards, Olaf.

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

end of thread, other threads:[~2006-12-29 20:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-29  6:47 kobject_add unreachable code Martin Stoilov
2006-12-29 13:50 ` Olaf Dietsche
2006-12-29 17:15   ` Martin Stoilov
2006-12-29 17:36     ` Martin Stoilov
2006-12-29 17:45       ` Jan Engelhardt
2006-12-29 20:49       ` Olaf Dietsche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.