lkml.org 
[lkml]   [2006]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 16/23] Kobject: provide better warning messages when people do stupid things
    Date
    From
    Now that kobject_add() is used more than kobject_register() the kernel
    wasn't always letting people know that they were doing something wrong.
    This change fixes this.

    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---

    lib/kobject.c | 22 ++++++++++++++--------
    1 files changed, 14 insertions(+), 8 deletions(-)

    dcd0da002122a70fe1c625c0ca9f58c95aa33ebe
    diff --git a/lib/kobject.c b/lib/kobject.c
    index efe67fa..36668c8 100644
    --- a/lib/kobject.c
    +++ b/lib/kobject.c
    @@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj)
    unlink(kobj);
    if (parent)
    kobject_put(parent);
    +
    + /* be noisy on error issues */
    + if (error == -EEXIST)
    + printk("kobject_add failed for %s with -EEXIST, "
    + "don't try to register things with the "
    + "same name in the same directory.\n",
    + kobject_name(kobj));
    + else
    + printk("kobject_add failed for %s (%d)\n",
    + kobject_name(kobj), error);
    + dump_stack();
    }

    return error;
    @@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj)

    int kobject_register(struct kobject * kobj)
    {
    - int error = 0;
    + int error = -EINVAL;
    if (kobj) {
    kobject_init(kobj);
    error = kobject_add(kobj);
    - if (error) {
    - printk("kobject_register failed for %s (%d)\n",
    - kobject_name(kobj),error);
    - dump_stack();
    - } else
    + if (!error)
    kobject_uevent(kobj, KOBJ_ADD);
    - } else
    - error = -EINVAL;
    + }
    return error;
    }

    --
    1.2.4

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

    \
     
     \ /
      Last update: 2006-03-20 23:05    [W:4.756 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site