Commit d8f969e603b85931f25a1d50f3a7a01e2712c17a
1 parent
b3b8dc51c1
Exists in
master
and in
4 other branches
ax25: Fix set-but-unused variable.
The variable 's' is set but unused in ax25_protocol_release(). Just kill it off. Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 1 additions and 2 deletions Inline Diff
net/ax25/ax25_iface.c
| 1 | /* | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify | 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License as published by | 3 | * it under the terms of the GNU General Public License as published by |
| 4 | * the Free Software Foundation; either version 2 of the License, or | 4 | * the Free Software Foundation; either version 2 of the License, or |
| 5 | * (at your option) any later version. | 5 | * (at your option) any later version. |
| 6 | * | 6 | * |
| 7 | * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk) | 7 | * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk) |
| 8 | */ | 8 | */ |
| 9 | #include <linux/errno.h> | 9 | #include <linux/errno.h> |
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | #include <linux/socket.h> | 11 | #include <linux/socket.h> |
| 12 | #include <linux/in.h> | 12 | #include <linux/in.h> |
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 16 | #include <linux/timer.h> | 16 | #include <linux/timer.h> |
| 17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
| 18 | #include <linux/sockios.h> | 18 | #include <linux/sockios.h> |
| 19 | #include <linux/net.h> | 19 | #include <linux/net.h> |
| 20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| 21 | #include <net/ax25.h> | 21 | #include <net/ax25.h> |
| 22 | #include <linux/inet.h> | 22 | #include <linux/inet.h> |
| 23 | #include <linux/netdevice.h> | 23 | #include <linux/netdevice.h> |
| 24 | #include <linux/skbuff.h> | 24 | #include <linux/skbuff.h> |
| 25 | #include <net/sock.h> | 25 | #include <net/sock.h> |
| 26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
| 27 | #include <asm/system.h> | 27 | #include <asm/system.h> |
| 28 | #include <linux/fcntl.h> | 28 | #include <linux/fcntl.h> |
| 29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
| 30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
| 31 | 31 | ||
| 32 | static struct ax25_protocol *protocol_list; | 32 | static struct ax25_protocol *protocol_list; |
| 33 | static DEFINE_RWLOCK(protocol_list_lock); | 33 | static DEFINE_RWLOCK(protocol_list_lock); |
| 34 | 34 | ||
| 35 | static HLIST_HEAD(ax25_linkfail_list); | 35 | static HLIST_HEAD(ax25_linkfail_list); |
| 36 | static DEFINE_SPINLOCK(linkfail_lock); | 36 | static DEFINE_SPINLOCK(linkfail_lock); |
| 37 | 37 | ||
| 38 | static struct listen_struct { | 38 | static struct listen_struct { |
| 39 | struct listen_struct *next; | 39 | struct listen_struct *next; |
| 40 | ax25_address callsign; | 40 | ax25_address callsign; |
| 41 | struct net_device *dev; | 41 | struct net_device *dev; |
| 42 | } *listen_list = NULL; | 42 | } *listen_list = NULL; |
| 43 | static DEFINE_SPINLOCK(listen_lock); | 43 | static DEFINE_SPINLOCK(listen_lock); |
| 44 | 44 | ||
| 45 | /* | 45 | /* |
| 46 | * Do not register the internal protocols AX25_P_TEXT, AX25_P_SEGMENT, | 46 | * Do not register the internal protocols AX25_P_TEXT, AX25_P_SEGMENT, |
| 47 | * AX25_P_IP or AX25_P_ARP ... | 47 | * AX25_P_IP or AX25_P_ARP ... |
| 48 | */ | 48 | */ |
| 49 | void ax25_register_pid(struct ax25_protocol *ap) | 49 | void ax25_register_pid(struct ax25_protocol *ap) |
| 50 | { | 50 | { |
| 51 | write_lock_bh(&protocol_list_lock); | 51 | write_lock_bh(&protocol_list_lock); |
| 52 | ap->next = protocol_list; | 52 | ap->next = protocol_list; |
| 53 | protocol_list = ap; | 53 | protocol_list = ap; |
| 54 | write_unlock_bh(&protocol_list_lock); | 54 | write_unlock_bh(&protocol_list_lock); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | EXPORT_SYMBOL_GPL(ax25_register_pid); | 57 | EXPORT_SYMBOL_GPL(ax25_register_pid); |
| 58 | 58 | ||
| 59 | void ax25_protocol_release(unsigned int pid) | 59 | void ax25_protocol_release(unsigned int pid) |
| 60 | { | 60 | { |
| 61 | struct ax25_protocol *s, *protocol; | 61 | struct ax25_protocol *protocol; |
| 62 | 62 | ||
| 63 | write_lock_bh(&protocol_list_lock); | 63 | write_lock_bh(&protocol_list_lock); |
| 64 | protocol = protocol_list; | 64 | protocol = protocol_list; |
| 65 | if (protocol == NULL) | 65 | if (protocol == NULL) |
| 66 | goto out; | 66 | goto out; |
| 67 | 67 | ||
| 68 | if (protocol->pid == pid) { | 68 | if (protocol->pid == pid) { |
| 69 | protocol_list = protocol->next; | 69 | protocol_list = protocol->next; |
| 70 | goto out; | 70 | goto out; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | while (protocol != NULL && protocol->next != NULL) { | 73 | while (protocol != NULL && protocol->next != NULL) { |
| 74 | if (protocol->next->pid == pid) { | 74 | if (protocol->next->pid == pid) { |
| 75 | s = protocol->next; | ||
| 76 | protocol->next = protocol->next->next; | 75 | protocol->next = protocol->next->next; |
| 77 | goto out; | 76 | goto out; |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | protocol = protocol->next; | 79 | protocol = protocol->next; |
| 81 | } | 80 | } |
| 82 | out: | 81 | out: |
| 83 | write_unlock_bh(&protocol_list_lock); | 82 | write_unlock_bh(&protocol_list_lock); |
| 84 | } | 83 | } |
| 85 | 84 | ||
| 86 | EXPORT_SYMBOL(ax25_protocol_release); | 85 | EXPORT_SYMBOL(ax25_protocol_release); |
| 87 | 86 | ||
| 88 | void ax25_linkfail_register(struct ax25_linkfail *lf) | 87 | void ax25_linkfail_register(struct ax25_linkfail *lf) |
| 89 | { | 88 | { |
| 90 | spin_lock_bh(&linkfail_lock); | 89 | spin_lock_bh(&linkfail_lock); |
| 91 | hlist_add_head(&lf->lf_node, &ax25_linkfail_list); | 90 | hlist_add_head(&lf->lf_node, &ax25_linkfail_list); |
| 92 | spin_unlock_bh(&linkfail_lock); | 91 | spin_unlock_bh(&linkfail_lock); |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | EXPORT_SYMBOL(ax25_linkfail_register); | 94 | EXPORT_SYMBOL(ax25_linkfail_register); |
| 96 | 95 | ||
| 97 | void ax25_linkfail_release(struct ax25_linkfail *lf) | 96 | void ax25_linkfail_release(struct ax25_linkfail *lf) |
| 98 | { | 97 | { |
| 99 | spin_lock_bh(&linkfail_lock); | 98 | spin_lock_bh(&linkfail_lock); |
| 100 | hlist_del_init(&lf->lf_node); | 99 | hlist_del_init(&lf->lf_node); |
| 101 | spin_unlock_bh(&linkfail_lock); | 100 | spin_unlock_bh(&linkfail_lock); |
| 102 | } | 101 | } |
| 103 | 102 | ||
| 104 | EXPORT_SYMBOL(ax25_linkfail_release); | 103 | EXPORT_SYMBOL(ax25_linkfail_release); |
| 105 | 104 | ||
| 106 | int ax25_listen_register(ax25_address *callsign, struct net_device *dev) | 105 | int ax25_listen_register(ax25_address *callsign, struct net_device *dev) |
| 107 | { | 106 | { |
| 108 | struct listen_struct *listen; | 107 | struct listen_struct *listen; |
| 109 | 108 | ||
| 110 | if (ax25_listen_mine(callsign, dev)) | 109 | if (ax25_listen_mine(callsign, dev)) |
| 111 | return 0; | 110 | return 0; |
| 112 | 111 | ||
| 113 | if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL) | 112 | if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL) |
| 114 | return -ENOMEM; | 113 | return -ENOMEM; |
| 115 | 114 | ||
| 116 | listen->callsign = *callsign; | 115 | listen->callsign = *callsign; |
| 117 | listen->dev = dev; | 116 | listen->dev = dev; |
| 118 | 117 | ||
| 119 | spin_lock_bh(&listen_lock); | 118 | spin_lock_bh(&listen_lock); |
| 120 | listen->next = listen_list; | 119 | listen->next = listen_list; |
| 121 | listen_list = listen; | 120 | listen_list = listen; |
| 122 | spin_unlock_bh(&listen_lock); | 121 | spin_unlock_bh(&listen_lock); |
| 123 | 122 | ||
| 124 | return 0; | 123 | return 0; |
| 125 | } | 124 | } |
| 126 | 125 | ||
| 127 | EXPORT_SYMBOL(ax25_listen_register); | 126 | EXPORT_SYMBOL(ax25_listen_register); |
| 128 | 127 | ||
| 129 | void ax25_listen_release(ax25_address *callsign, struct net_device *dev) | 128 | void ax25_listen_release(ax25_address *callsign, struct net_device *dev) |
| 130 | { | 129 | { |
| 131 | struct listen_struct *s, *listen; | 130 | struct listen_struct *s, *listen; |
| 132 | 131 | ||
| 133 | spin_lock_bh(&listen_lock); | 132 | spin_lock_bh(&listen_lock); |
| 134 | listen = listen_list; | 133 | listen = listen_list; |
| 135 | if (listen == NULL) { | 134 | if (listen == NULL) { |
| 136 | spin_unlock_bh(&listen_lock); | 135 | spin_unlock_bh(&listen_lock); |
| 137 | return; | 136 | return; |
| 138 | } | 137 | } |
| 139 | 138 | ||
| 140 | if (ax25cmp(&listen->callsign, callsign) == 0 && listen->dev == dev) { | 139 | if (ax25cmp(&listen->callsign, callsign) == 0 && listen->dev == dev) { |
| 141 | listen_list = listen->next; | 140 | listen_list = listen->next; |
| 142 | spin_unlock_bh(&listen_lock); | 141 | spin_unlock_bh(&listen_lock); |
| 143 | kfree(listen); | 142 | kfree(listen); |
| 144 | return; | 143 | return; |
| 145 | } | 144 | } |
| 146 | 145 | ||
| 147 | while (listen != NULL && listen->next != NULL) { | 146 | while (listen != NULL && listen->next != NULL) { |
| 148 | if (ax25cmp(&listen->next->callsign, callsign) == 0 && listen->next->dev == dev) { | 147 | if (ax25cmp(&listen->next->callsign, callsign) == 0 && listen->next->dev == dev) { |
| 149 | s = listen->next; | 148 | s = listen->next; |
| 150 | listen->next = listen->next->next; | 149 | listen->next = listen->next->next; |
| 151 | spin_unlock_bh(&listen_lock); | 150 | spin_unlock_bh(&listen_lock); |
| 152 | kfree(s); | 151 | kfree(s); |
| 153 | return; | 152 | return; |
| 154 | } | 153 | } |
| 155 | 154 | ||
| 156 | listen = listen->next; | 155 | listen = listen->next; |
| 157 | } | 156 | } |
| 158 | spin_unlock_bh(&listen_lock); | 157 | spin_unlock_bh(&listen_lock); |
| 159 | } | 158 | } |
| 160 | 159 | ||
| 161 | EXPORT_SYMBOL(ax25_listen_release); | 160 | EXPORT_SYMBOL(ax25_listen_release); |
| 162 | 161 | ||
| 163 | int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *) | 162 | int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *) |
| 164 | { | 163 | { |
| 165 | int (*res)(struct sk_buff *, ax25_cb *) = NULL; | 164 | int (*res)(struct sk_buff *, ax25_cb *) = NULL; |
| 166 | struct ax25_protocol *protocol; | 165 | struct ax25_protocol *protocol; |
| 167 | 166 | ||
| 168 | read_lock(&protocol_list_lock); | 167 | read_lock(&protocol_list_lock); |
| 169 | for (protocol = protocol_list; protocol != NULL; protocol = protocol->next) | 168 | for (protocol = protocol_list; protocol != NULL; protocol = protocol->next) |
| 170 | if (protocol->pid == pid) { | 169 | if (protocol->pid == pid) { |
| 171 | res = protocol->func; | 170 | res = protocol->func; |
| 172 | break; | 171 | break; |
| 173 | } | 172 | } |
| 174 | read_unlock(&protocol_list_lock); | 173 | read_unlock(&protocol_list_lock); |
| 175 | 174 | ||
| 176 | return res; | 175 | return res; |
| 177 | } | 176 | } |
| 178 | 177 | ||
| 179 | int ax25_listen_mine(ax25_address *callsign, struct net_device *dev) | 178 | int ax25_listen_mine(ax25_address *callsign, struct net_device *dev) |
| 180 | { | 179 | { |
| 181 | struct listen_struct *listen; | 180 | struct listen_struct *listen; |
| 182 | 181 | ||
| 183 | spin_lock_bh(&listen_lock); | 182 | spin_lock_bh(&listen_lock); |
| 184 | for (listen = listen_list; listen != NULL; listen = listen->next) | 183 | for (listen = listen_list; listen != NULL; listen = listen->next) |
| 185 | if (ax25cmp(&listen->callsign, callsign) == 0 && | 184 | if (ax25cmp(&listen->callsign, callsign) == 0 && |
| 186 | (listen->dev == dev || listen->dev == NULL)) { | 185 | (listen->dev == dev || listen->dev == NULL)) { |
| 187 | spin_unlock_bh(&listen_lock); | 186 | spin_unlock_bh(&listen_lock); |
| 188 | return 1; | 187 | return 1; |
| 189 | } | 188 | } |
| 190 | spin_unlock_bh(&listen_lock); | 189 | spin_unlock_bh(&listen_lock); |
| 191 | 190 | ||
| 192 | return 0; | 191 | return 0; |
| 193 | } | 192 | } |
| 194 | 193 | ||
| 195 | void ax25_link_failed(ax25_cb *ax25, int reason) | 194 | void ax25_link_failed(ax25_cb *ax25, int reason) |
| 196 | { | 195 | { |
| 197 | struct ax25_linkfail *lf; | 196 | struct ax25_linkfail *lf; |
| 198 | struct hlist_node *node; | 197 | struct hlist_node *node; |
| 199 | 198 | ||
| 200 | spin_lock_bh(&linkfail_lock); | 199 | spin_lock_bh(&linkfail_lock); |
| 201 | hlist_for_each_entry(lf, node, &ax25_linkfail_list, lf_node) | 200 | hlist_for_each_entry(lf, node, &ax25_linkfail_list, lf_node) |
| 202 | lf->func(ax25, reason); | 201 | lf->func(ax25, reason); |
| 203 | spin_unlock_bh(&linkfail_lock); | 202 | spin_unlock_bh(&linkfail_lock); |
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | int ax25_protocol_is_registered(unsigned int pid) | 205 | int ax25_protocol_is_registered(unsigned int pid) |
| 207 | { | 206 | { |
| 208 | struct ax25_protocol *protocol; | 207 | struct ax25_protocol *protocol; |
| 209 | int res = 0; | 208 | int res = 0; |
| 210 | 209 | ||
| 211 | read_lock_bh(&protocol_list_lock); | 210 | read_lock_bh(&protocol_list_lock); |
| 212 | for (protocol = protocol_list; protocol != NULL; protocol = protocol->next) | 211 | for (protocol = protocol_list; protocol != NULL; protocol = protocol->next) |
| 213 | if (protocol->pid == pid) { | 212 | if (protocol->pid == pid) { |
| 214 | res = 1; | 213 | res = 1; |
| 215 | break; | 214 | break; |
| 216 | } | 215 | } |
| 217 | read_unlock_bh(&protocol_list_lock); | 216 | read_unlock_bh(&protocol_list_lock); |
| 218 | 217 | ||
| 219 | return res; | 218 | return res; |
| 220 | } | 219 | } |
| 221 | 220 |