Name: notifier_unregister should return void Author: Rusty Russell Status: Tested on 2.5.66-bk2 Noone uses the return value of notifier_chain_unregister and its children: make it BUG() when unregistering a non-existent notifier, and return void. Index: linux-2.6.10-rc2-bk9-Misc/kernel/sys.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/kernel/sys.c 2004-11-16 15:30:10.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/kernel/sys.c 2004-11-27 14:54:38.197307856 +1100 @@ -123,11 +123,9 @@ * @n: New entry in notifier chain * * Removes a notifier from a notifier chain. - * - * Returns zero on success, or %-ENOENT on failure. */ -int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n) +void notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n) { write_lock(¬ifier_lock); while((*nl)!=NULL) @@ -136,12 +134,12 @@ { *nl=n->next; write_unlock(¬ifier_lock); - return 0; + return; } nl=&((*nl)->next); } write_unlock(¬ifier_lock); - return -ENOENT; + BUG(); } EXPORT_SYMBOL(notifier_chain_unregister); @@ -205,13 +203,11 @@ * * Unregisters a previously registered reboot * notifier function. - * - * Returns zero on success, or %-ENOENT on failure. */ -int unregister_reboot_notifier(struct notifier_block * nb) +void unregister_reboot_notifier(struct notifier_block * nb) { - return notifier_chain_unregister(&reboot_notifier_list, nb); + notifier_chain_unregister(&reboot_notifier_list, nb); } EXPORT_SYMBOL(unregister_reboot_notifier); Index: linux-2.6.10-rc2-bk9-Misc/net/netlink/af_netlink.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/net/netlink/af_netlink.c 2004-11-26 11:37:08.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/net/netlink/af_netlink.c 2004-11-27 14:54:38.203306944 +1100 @@ -1407,9 +1407,9 @@ return notifier_chain_register(&netlink_chain, nb); } -int netlink_unregister_notifier(struct notifier_block *nb) +void netlink_unregister_notifier(struct notifier_block *nb) { - return notifier_chain_unregister(&netlink_chain, nb); + notifier_chain_unregister(&netlink_chain, nb); } static struct proto_ops netlink_ops = { Index: linux-2.6.10-rc2-bk9-Misc/include/linux/profile.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/profile.h 2004-11-16 15:30:07.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/profile.h 2004-11-27 14:56:32.173980768 +1100 @@ -48,10 +48,10 @@ void profile_munmap(unsigned long addr); int task_handoff_register(struct notifier_block * n); -int task_handoff_unregister(struct notifier_block * n); +void task_handoff_unregister(struct notifier_block * n); int profile_event_register(enum profile_type, struct notifier_block * n); -int profile_event_unregister(enum profile_type, struct notifier_block * n); +void profile_event_unregister(enum profile_type, struct notifier_block * n); int register_timer_hook(int (*hook)(struct pt_regs *)); void unregister_timer_hook(int (*hook)(struct pt_regs *)); @@ -68,9 +68,9 @@ return -ENOSYS; } -static inline int task_handoff_unregister(struct notifier_block * n) +static inline void task_handoff_unregister(struct notifier_block * n) { - return -ENOSYS; + return; } static inline int profile_event_register(enum profile_type t, struct notifier_block * n) @@ -78,9 +78,8 @@ return -ENOSYS; } -static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n) +static inline void profile_event_unregister(enum profile_type t, struct notifier_block * n) { - return -ENOSYS; } #define profile_task_exit(a) do { } while (0) Index: linux-2.6.10-rc2-bk9-Misc/include/linux/netlink.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/netlink.h 2004-11-16 15:30:07.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/netlink.h 2004-11-27 14:54:38.193308464 +1100 @@ -126,7 +126,7 @@ __u32 group, int allocation); extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code); extern int netlink_register_notifier(struct notifier_block *nb); -extern int netlink_unregister_notifier(struct notifier_block *nb); +extern void netlink_unregister_notifier(struct notifier_block *nb); /* finegrained unicast helpers: */ struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid); Index: linux-2.6.10-rc2-bk9-Misc/kernel/profile.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/kernel/profile.c 2004-11-16 15:30:10.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/kernel/profile.c 2004-11-27 14:56:32.200976664 +1100 @@ -121,14 +121,11 @@ return err; } -int task_handoff_unregister(struct notifier_block * n) +void task_handoff_unregister(struct notifier_block * n) { - int err = -EINVAL; - write_lock(&handoff_lock); - err = notifier_chain_unregister(&task_free_notifier, n); + notifier_chain_unregister(&task_free_notifier, n); write_unlock(&handoff_lock); - return err; } int profile_event_register(enum profile_type type, struct notifier_block * n) @@ -152,23 +149,20 @@ } -int profile_event_unregister(enum profile_type type, struct notifier_block * n) +void profile_event_unregister(enum profile_type type, struct notifier_block * n) { - int err = -EINVAL; - down_write(&profile_rwsem); switch (type) { case PROFILE_TASK_EXIT: - err = notifier_chain_unregister(&task_exit_notifier, n); + notifier_chain_unregister(&task_exit_notifier, n); break; case PROFILE_MUNMAP: - err = notifier_chain_unregister(&munmap_notifier, n); + notifier_chain_unregister(&munmap_notifier, n); break; } up_write(&profile_rwsem); - return err; } int register_timer_hook(int (*hook)(struct pt_regs *)) Index: linux-2.6.10-rc2-bk9-Misc/include/linux/reboot.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/reboot.h 2004-06-17 08:49:37.000000000 +1000 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/reboot.h 2004-11-27 14:54:38.194308312 +1100 @@ -40,7 +40,7 @@ #include extern int register_reboot_notifier(struct notifier_block *); -extern int unregister_reboot_notifier(struct notifier_block *); +extern void unregister_reboot_notifier(struct notifier_block *); /* Index: linux-2.6.10-rc2-bk9-Misc/include/net/addrconf.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/net/addrconf.h 2004-11-16 15:30:08.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/net/addrconf.h 2004-11-27 14:54:38.195308160 +1100 @@ -118,7 +118,7 @@ /* Device notifier */ extern int register_inet6addr_notifier(struct notifier_block *nb); -extern int unregister_inet6addr_notifier(struct notifier_block *nb); +extern void unregister_inet6addr_notifier(struct notifier_block *nb); static inline struct inet6_dev * __in6_dev_get(struct net_device *dev) Index: linux-2.6.10-rc2-bk9-Misc/include/linux/notifier.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/notifier.h 2004-11-16 15:30:07.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/notifier.h 2004-11-27 14:54:38.194308312 +1100 @@ -22,7 +22,7 @@ #ifdef __KERNEL__ extern int notifier_chain_register(struct notifier_block **list, struct notifier_block *n); -extern int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n); +extern void notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n); extern int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v); #define NOTIFY_DONE 0x0000 /* Don't care */ Index: linux-2.6.10-rc2-bk9-Misc/include/linux/inetdevice.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/inetdevice.h 2004-11-16 15:30:07.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/inetdevice.h 2004-11-27 14:54:38.192308616 +1100 @@ -99,7 +99,7 @@ }; extern int register_inetaddr_notifier(struct notifier_block *nb); -extern int unregister_inetaddr_notifier(struct notifier_block *nb); +extern void unregister_inetaddr_notifier(struct notifier_block *nb); extern struct net_device *ip_dev_find(u32 addr); extern int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b); Index: linux-2.6.10-rc2-bk9-Misc/net/ipv4/devinet.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/net/ipv4/devinet.c 2004-11-16 15:30:12.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/net/ipv4/devinet.c 2004-11-27 14:54:38.201307248 +1100 @@ -900,9 +900,9 @@ return notifier_chain_register(&inetaddr_chain, nb); } -int unregister_inetaddr_notifier(struct notifier_block *nb) +void unregister_inetaddr_notifier(struct notifier_block *nb) { - return notifier_chain_unregister(&inetaddr_chain, nb); + notifier_chain_unregister(&inetaddr_chain, nb); } /* Rename ifa_labels for a device name change. Make some effort to preserve existing Index: linux-2.6.10-rc2-bk9-Misc/include/net/bluetooth/hci_core.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/net/bluetooth/hci_core.h 2004-11-16 15:30:08.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/net/bluetooth/hci_core.h 2004-11-27 14:54:38.195308160 +1100 @@ -539,7 +539,7 @@ int hci_unregister_cb(struct hci_cb *hcb); int hci_register_notifier(struct notifier_block *nb); -int hci_unregister_notifier(struct notifier_block *nb); +void hci_unregister_notifier(struct notifier_block *nb); int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *param); int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); Index: linux-2.6.10-rc2-bk9-Misc/net/ipv6/addrconf.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/net/ipv6/addrconf.c 2004-11-26 11:37:08.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/net/ipv6/addrconf.c 2004-11-27 14:54:38.202307096 +1100 @@ -3376,9 +3376,9 @@ return notifier_chain_register(&inet6addr_chain, nb); } -int unregister_inet6addr_notifier(struct notifier_block *nb) +void unregister_inet6addr_notifier(struct notifier_block *nb) { - return notifier_chain_unregister(&inet6addr_chain,nb); + notifier_chain_unregister(&inet6addr_chain,nb); } /* Index: linux-2.6.10-rc2-bk9-Misc/net/core/dev.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/net/core/dev.c 2004-11-26 11:37:07.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/net/core/dev.c 2004-11-27 14:54:38.200307400 +1100 @@ -978,13 +978,12 @@ * * Unregister a notifier previously registered by * register_netdevice_notifier(). The notifier is unlinked into the - * kernel structures and may then be reused. A negative errno code - * is returned on a failure. + * kernel structures and may then be reused. */ -int unregister_netdevice_notifier(struct notifier_block *nb) +void unregister_netdevice_notifier(struct notifier_block *nb) { - return notifier_chain_unregister(&netdev_chain, nb); + notifier_chain_unregister(&netdev_chain, nb); } /** Index: linux-2.6.10-rc2-bk9-Misc/net/bluetooth/hci_core.c =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/net/bluetooth/hci_core.c 2004-11-16 15:30:11.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/net/bluetooth/hci_core.c 2004-11-27 14:54:38.198307704 +1100 @@ -83,9 +83,9 @@ return notifier_chain_register(&hci_notifier, nb); } -int hci_unregister_notifier(struct notifier_block *nb) +void hci_unregister_notifier(struct notifier_block *nb) { - return notifier_chain_unregister(&hci_notifier, nb); + notifier_chain_unregister(&hci_notifier, nb); } void hci_notify(struct hci_dev *hdev, int event) Index: linux-2.6.10-rc2-bk9-Misc/include/linux/cpufreq.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/cpufreq.h 2004-11-16 15:30:06.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/cpufreq.h 2004-11-27 14:54:38.192308616 +1100 @@ -32,7 +32,7 @@ *********************************************************************/ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list); -int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); +void cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); #define CPUFREQ_TRANSITION_NOTIFIER (0) #define CPUFREQ_POLICY_NOTIFIER (1) Index: linux-2.6.10-rc2-bk9-Misc/include/linux/netdevice.h =================================================================== --- linux-2.6.10-rc2-bk9-Misc.orig/include/linux/netdevice.h 2004-11-26 11:37:06.000000000 +1100 +++ linux-2.6.10-rc2-bk9-Misc/include/linux/netdevice.h 2004-11-27 14:54:38.193308464 +1100 @@ -544,7 +544,7 @@ extern void free_netdev(struct net_device *dev); extern void synchronize_net(void); extern int register_netdevice_notifier(struct notifier_block *nb); -extern int unregister_netdevice_notifier(struct notifier_block *nb); +extern void unregister_netdevice_notifier(struct notifier_block *nb); extern int call_netdevice_notifiers(unsigned long val, void *v); extern struct net_device *dev_get_by_index(int ifindex); extern struct net_device *__dev_get_by_index(int ifindex);