public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Stoilov <mstoilov@odesys.com>
To: linux-kernel@vger.kernel.org
Subject: kobject_add unreachable code
Date: Thu, 28 Dec 2006 22:47:37 -0800	[thread overview]
Message-ID: <4594BA09.1080509@odesys.com> (raw)

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


             reply	other threads:[~2006-12-29  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-29  6:47 Martin Stoilov [this message]
2006-12-29 13:50 ` kobject_add unreachable code 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

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=4594BA09.1080509@odesys.com \
    --to=mstoilov@odesys.com \
    --cc=linux-kernel@vger.kernel.org \
    /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