public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Olaf Dietsche <olaf.dietsche@olafdietsche.de>
To: Martin Stoilov <mstoilov@odesys.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kobject_add unreachable code
Date: Fri, 29 Dec 2006 21:49:18 +0100	[thread overview]
Message-ID: <87bqlmzaup.fsf@goat.bogus.local> (raw)
In-Reply-To: <45955217.5050405@odesys.com> (Martin Stoilov's message of "Fri, 29 Dec 2006 09:36:23 -0800")

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.

      parent reply	other threads:[~2006-12-29 20:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqlmzaup.fsf@goat.bogus.local \
    --to=olaf.dietsche@olafdietsche.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mstoilov@odesys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox