public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Stoilov <mstoilov@odesys.com>
To: Olaf Dietsche <olaf+list.linux-kernel@olafdietsche.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kobject_add unreachable code
Date: Fri, 29 Dec 2006 09:15:05 -0800	[thread overview]
Message-ID: <45954D19.5020905@odesys.com> (raw)
In-Reply-To: <87k60azu8b.fsf@goat.bogus.local>

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

  reply	other threads:[~2006-12-29 17:15 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 [this message]
2006-12-29 17:36     ` Martin Stoilov
2006-12-29 17:45       ` Jan Engelhardt
2006-12-29 20:49       ` Olaf Dietsche

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=45954D19.5020905@odesys.com \
    --to=mstoilov@odesys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf+list.linux-kernel@olafdietsche.de \
    /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