lkml.org 
[lkml]   [2003]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: Resend [PATCH] Make KOBJ_NAME_LEN match BUS_ID_SIZE
    Given that the problem with KOBJ_NAME_LEN == 20 affecting one snd driver
    has so far only been explained as a compiler bug, can I suggest this
    patch be applied? Even aside from the KOBJ_NAME_LEN == 20, the snprintf
    changes will keep things from breaking in other ways that are current
    now.


    Index: include/linux/kobject.h
    ===================================================================
    --- include/linux/kobject.h (revision 10014)
    +++ include/linux/kobject.h (working copy)
    @@ -12,7 +12,7 @@
    #include <linux/rwsem.h>
    #include <asm/atomic.h>

    -#define KOBJ_NAME_LEN 16
    +#define KOBJ_NAME_LEN 20

    struct kobject {
    char name[KOBJ_NAME_LEN];
    Index: drivers/base/class.c
    ===================================================================
    --- drivers/base/class.c (revision 10014)
    +++ drivers/base/class.c (working copy)
    @@ -87,8 +87,9 @@

    INIT_LIST_HEAD(&cls->children);
    INIT_LIST_HEAD(&cls->interfaces);
    -
    - strncpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN);
    +
    + snprintf(cls->subsys.kset.kobj.name, KOBJ_NAME_LEN, "%s",
    + cls->name);
    subsys_set_kset(cls,class_subsys);
    subsystem_register(&cls->subsys);

    @@ -258,7 +259,7 @@
    class_dev->class_id);

    /* first, register with generic layer. */
    - strncpy(class_dev->kobj.name, class_dev->class_id, KOBJ_NAME_LEN);
    + snprintf(class_dev->kobj.name, KOBJ_NAME_LEN, "%s", class_dev->class_id);
    kobj_set_kset_s(class_dev, class_obj_subsys);
    if (parent)
    class_dev->kobj.parent = &parent->subsys.kset.kobj;
    Index: drivers/base/core.c
    ===================================================================
    --- drivers/base/core.c (revision 10014)
    +++ drivers/base/core.c (working copy)
    @@ -211,7 +211,7 @@
    dev->bus_id, dev->name);

    /* first, register with generic layer. */
    - strncpy(dev->kobj.name,dev->bus_id,KOBJ_NAME_LEN);
    + snprintf(dev->kobj.name, KOBJ_NAME_LEN, "%s", dev->bus_id);
    if (parent)
    dev->kobj.parent = &parent->kobj;

    Index: drivers/base/bus.c
    ===================================================================
    --- drivers/base/bus.c (revision 10014)
    +++ drivers/base/bus.c (working copy)
    @@ -431,7 +431,7 @@
    if (bus) {
    pr_debug("bus %s: add driver %s\n",bus->name,drv->name);

    - strncpy(drv->kobj.name,drv->name,KOBJ_NAME_LEN);
    + snprintf(drv->kobj.name, KOBJ_NAME_LEN, "%s", drv->name);
    drv->kobj.kset = &bus->drivers;

    if ((error = kobject_register(&drv->kobj))) {
    @@ -540,7 +540,8 @@
    */
    int bus_register(struct bus_type * bus)
    {
    - strncpy(bus->subsys.kset.kobj.name,bus->name,KOBJ_NAME_LEN);
    + snprintf(bus->subsys.kset.kobj.name, KOBJ_NAME_LEN, "%s",
    + bus->name);
    subsys_set_kset(bus,bus_subsys);
    subsystem_register(&bus->subsys);

    -
    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: 2005-03-22 13:35    [W:0.023 / U:122.520 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site