ChangeSet 1.1996, 2004/10/15 16:07:38-07:00, greg@kroah.com kevent: add __bitwise kobject_action to help the compiler check for misusages Signed-off-by: Greg Kroah-Hartman include/linux/kobject_uevent.h | 13 ++++++------- lib/kobject_uevent.c | 28 +++++++++++++--------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff -Nru a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h --- a/include/linux/kobject_uevent.h 2004-10-19 09:20:20 -07:00 +++ b/include/linux/kobject_uevent.h 2004-10-19 09:20:20 -07:00 @@ -15,14 +15,13 @@ * If you add an action here, you must also add the proper string to the * lib/kobject_uevent.c file. */ - +typedef int __bitwise kobject_action_t; enum kobject_action { - KOBJ_ADD = 0x00, /* add event, for hotplug */ - KOBJ_REMOVE = 0x01, /* remove event, for hotplug */ - KOBJ_CHANGE = 0x02, /* a sysfs attribute file has changed */ - KOBJ_MOUNT = 0x03, /* mount event for block devices */ - KOBJ_UMOUNT = 0x04, /* umount event for block devices */ - KOBJ_MAX_ACTION, /* must be last action listed */ + KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ + KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ + KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ + KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */ + KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */ }; diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c --- a/lib/kobject_uevent.c 2004-10-19 09:20:20 -07:00 +++ b/lib/kobject_uevent.c 2004-10-19 09:20:20 -07:00 @@ -23,24 +23,22 @@ #include #include -/* - * These must match up with the values for enum kobject_action - * as found in include/linux/kobject_uevent.h - */ -static char *actions[] = { - "add", /* 0x00 */ - "remove", /* 0x01 */ - "change", /* 0x02 */ - "mount", /* 0x03 */ - "umount", /* 0x04 */ -}; - static char *action_to_string(enum kobject_action action) { - if (action >= KOBJ_MAX_ACTION) + switch (action) { + case KOBJ_ADD: + return "add"; + case KOBJ_REMOVE: + return "remove"; + case KOBJ_CHANGE: + return "change"; + case KOBJ_MOUNT: + return "mount"; + case KOBJ_UMOUNT: + return "umount"; + default: return NULL; - else - return actions[action]; + } } #ifdef CONFIG_KOBJECT_UEVENT