net: Remove casts to same type

Adding casts of objects to the same type is unnecessary
and confusing for a human reader.

For example, this cast:

	int y;
	int *p = (int *)&y;

I used the coccinelle script below to find and remove these
unnecessary casts.  I manually removed the conversions this
script produces of casts with __force and __user.

@@
type T;
T *p;
@@

-	(T *)p
+	p

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Joe Perches 2012-06-03 17:41:40 +00:00 committed by David S. Miller
parent 29a6b6c060
commit e3192690a3
14 changed files with 32 additions and 36 deletions

View File

@ -1548,7 +1548,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
kernel_buf = 1; kernel_buf = 1;
indata = data; indata = data;
} else } else
indata = (char *)udata; indata = udata;
/* /*
* response header len is 11 * response header len is 11
* PDU Header(7) + IO Size (4) * PDU Header(7) + IO Size (4)

View File

@ -1604,7 +1604,7 @@ static void lec_arp_expire_vcc(unsigned long data)
{ {
unsigned long flags; unsigned long flags;
struct lec_arp_table *to_remove = (struct lec_arp_table *)data; struct lec_arp_table *to_remove = (struct lec_arp_table *)data;
struct lec_priv *priv = (struct lec_priv *)to_remove->priv; struct lec_priv *priv = to_remove->priv;
del_timer(&to_remove->timer); del_timer(&to_remove->timer);

View File

@ -322,7 +322,7 @@ static __le16 *dn_mk_ack_header(struct sock *sk, struct sk_buff *skb, unsigned c
/* Set "cross subchannel" bit in ackcrs */ /* Set "cross subchannel" bit in ackcrs */
ackcrs |= 0x2000; ackcrs |= 0x2000;
ptr = (__le16 *)dn_mk_common_header(scp, skb, msgflag, hlen); ptr = dn_mk_common_header(scp, skb, msgflag, hlen);
*ptr++ = cpu_to_le16(acknum); *ptr++ = cpu_to_le16(acknum);
*ptr++ = cpu_to_le16(ackcrs); *ptr++ = cpu_to_le16(ackcrs);

View File

@ -553,7 +553,7 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
if (!inet_sk(sk)->inet_num && inet_autobind(sk)) if (!inet_sk(sk)->inet_num && inet_autobind(sk))
return -EAGAIN; return -EAGAIN;
return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len); return sk->sk_prot->connect(sk, uaddr, addr_len);
} }
EXPORT_SYMBOL(inet_dgram_connect); EXPORT_SYMBOL(inet_dgram_connect);

View File

@ -1007,9 +1007,9 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
while (tn != NULL && (tp = node_parent((struct rt_trie_node *)tn)) != NULL) { while (tn != NULL && (tp = node_parent((struct rt_trie_node *)tn)) != NULL) {
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
wasfull = tnode_full(tp, tnode_get_child(tp, cindex)); wasfull = tnode_full(tp, tnode_get_child(tp, cindex));
tn = (struct tnode *) resize(t, (struct tnode *)tn); tn = (struct tnode *)resize(t, tn);
tnode_put_child_reorg((struct tnode *)tp, cindex, tnode_put_child_reorg(tp, cindex,
(struct rt_trie_node *)tn, wasfull); (struct rt_trie_node *)tn, wasfull);
tp = node_parent((struct rt_trie_node *) tn); tp = node_parent((struct rt_trie_node *) tn);
@ -1024,7 +1024,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
/* Handle last (top) tnode */ /* Handle last (top) tnode */
if (IS_TNODE(tn)) if (IS_TNODE(tn))
tn = (struct tnode *)resize(t, (struct tnode *)tn); tn = (struct tnode *)resize(t, tn);
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
tnode_free_flush(); tnode_free_flush();
@ -1125,7 +1125,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
node_set_parent((struct rt_trie_node *)l, tp); node_set_parent((struct rt_trie_node *)l, tp);
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, (struct rt_trie_node *)l); put_child(t, tp, cindex, (struct rt_trie_node *)l);
} else { } else {
/* Case 3: n is a LEAF or a TNODE and the key doesn't match. */ /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */
/* /*
@ -1160,8 +1160,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
if (tp) { if (tp) {
cindex = tkey_extract_bits(key, tp->pos, tp->bits); cindex = tkey_extract_bits(key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, put_child(t, tp, cindex, (struct rt_trie_node *)tn);
(struct rt_trie_node *)tn);
} else { } else {
rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
tp = tn; tp = tn;
@ -1620,7 +1619,7 @@ static void trie_leaf_remove(struct trie *t, struct leaf *l)
if (tp) { if (tp) {
t_key cindex = tkey_extract_bits(l->key, tp->pos, tp->bits); t_key cindex = tkey_extract_bits(l->key, tp->pos, tp->bits);
put_child(t, (struct tnode *)tp, cindex, NULL); put_child(t, tp, cindex, NULL);
trie_rebalance(t, tp); trie_rebalance(t, tp);
} else } else
RCU_INIT_POINTER(t->trie, NULL); RCU_INIT_POINTER(t->trie, NULL);

View File

@ -405,7 +405,7 @@ static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
ptr = *octets; ptr = *octets;
while (ctx->pointer < eoc) { while (ctx->pointer < eoc) {
if (!asn1_octet_decode(ctx, (unsigned char *)ptr++)) { if (!asn1_octet_decode(ctx, ptr++)) {
kfree(*octets); kfree(*octets);
*octets = NULL; *octets = NULL;
return 0; return 0;
@ -759,7 +759,7 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
} }
break; break;
case SNMP_OBJECTID: case SNMP_OBJECTID:
if (!asn1_oid_decode(ctx, end, (unsigned long **)&lp, &len)) { if (!asn1_oid_decode(ctx, end, &lp, &len)) {
kfree(id); kfree(id);
return 0; return 0;
} }

View File

@ -791,14 +791,14 @@ static int ipv6_renew_option(void *ohdr,
if (ohdr) { if (ohdr) {
memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr)); memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
*hdr = (struct ipv6_opt_hdr *)*p; *hdr = (struct ipv6_opt_hdr *)*p;
*p += CMSG_ALIGN(ipv6_optlen(*(struct ipv6_opt_hdr **)hdr)); *p += CMSG_ALIGN(ipv6_optlen(*hdr));
} }
} else { } else {
if (newopt) { if (newopt) {
if (copy_from_user(*p, newopt, newoptlen)) if (copy_from_user(*p, newopt, newoptlen))
return -EFAULT; return -EFAULT;
*hdr = (struct ipv6_opt_hdr *)*p; *hdr = (struct ipv6_opt_hdr *)*p;
if (ipv6_optlen(*(struct ipv6_opt_hdr **)hdr) > newoptlen) if (ipv6_optlen(*hdr) > newoptlen)
return -EINVAL; return -EINVAL;
*p += CMSG_ALIGN(newoptlen); *p += CMSG_ALIGN(newoptlen);
} }

View File

@ -523,7 +523,7 @@ void *hashbin_remove_first( hashbin_t *hashbin)
* Dequeue the entry... * Dequeue the entry...
*/ */
dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
(irda_queue_t*) entry ); entry);
hashbin->hb_size--; hashbin->hb_size--;
entry->q_next = NULL; entry->q_next = NULL;
entry->q_prev = NULL; entry->q_prev = NULL;
@ -615,7 +615,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
*/ */
if ( found ) { if ( found ) {
dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
(irda_queue_t*) entry ); entry);
hashbin->hb_size--; hashbin->hb_size--;
/* /*
@ -685,7 +685,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
* Dequeue the entry... * Dequeue the entry...
*/ */
dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ], dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
(irda_queue_t*) entry ); entry);
hashbin->hb_size--; hashbin->hb_size--;
entry->q_next = NULL; entry->q_next = NULL;
entry->q_prev = NULL; entry->q_prev = NULL;

View File

@ -1522,8 +1522,8 @@ static int pppol2tp_session_getsockopt(struct sock *sk,
* handler, according to whether the PPPoX socket is a for a regular session * handler, according to whether the PPPoX socket is a for a regular session
* or the special tunnel type. * or the special tunnel type.
*/ */
static int pppol2tp_getsockopt(struct socket *sock, int level, static int pppol2tp_getsockopt(struct socket *sock, int level, int optname,
int optname, char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct l2tp_session *session; struct l2tp_session *session;
@ -1535,7 +1535,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level,
if (level != SOL_PPPOL2TP) if (level != SOL_PPPOL2TP)
return udp_prot.getsockopt(sk, level, optname, optval, optlen); return udp_prot.getsockopt(sk, level, optname, optval, optlen);
if (get_user(len, (int __user *) optlen)) if (get_user(len, optlen))
return -EFAULT; return -EFAULT;
len = min_t(unsigned int, len, sizeof(int)); len = min_t(unsigned int, len, sizeof(int));
@ -1568,7 +1568,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level,
err = pppol2tp_session_getsockopt(sk, session, optname, &val); err = pppol2tp_session_getsockopt(sk, session, optname, &val);
err = -EFAULT; err = -EFAULT;
if (put_user(len, (int __user *) optlen)) if (put_user(len, optlen))
goto end_put_sess; goto end_put_sess;
if (copy_to_user((void __user *) optval, &val, len)) if (copy_to_user((void __user *) optval, &val, len))

View File

@ -114,8 +114,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
if (elems->tim && (!elems->parse_error || if (elems->tim && (!elems->parse_error ||
!(bss->valid_data & IEEE80211_BSS_VALID_DTIM))) { !(bss->valid_data & IEEE80211_BSS_VALID_DTIM))) {
struct ieee80211_tim_ie *tim_ie = struct ieee80211_tim_ie *tim_ie = elems->tim;
(struct ieee80211_tim_ie *)elems->tim;
bss->dtim_period = tim_ie->dtim_period; bss->dtim_period = tim_ie->dtim_period;
if (!elems->parse_error) if (!elems->parse_error)
bss->valid_data |= IEEE80211_BSS_VALID_DTIM; bss->valid_data |= IEEE80211_BSS_VALID_DTIM;

View File

@ -531,7 +531,7 @@ __nf_conntrack_confirm(struct sk_buff *skb)
tstamp = nf_conn_tstamp_find(ct); tstamp = nf_conn_tstamp_find(ct);
if (tstamp) { if (tstamp) {
if (skb->tstamp.tv64 == 0) if (skb->tstamp.tv64 == 0)
__net_timestamp((struct sk_buff *)skb); __net_timestamp(skb);
tstamp->start = ktime_to_ns(skb->tstamp); tstamp->start = ktime_to_ns(skb->tstamp);
} }

View File

@ -592,7 +592,7 @@ static void init_prb_bdqc(struct packet_sock *po,
p1->knxt_seq_num = 1; p1->knxt_seq_num = 1;
p1->pkbdq = pg_vec; p1->pkbdq = pg_vec;
pbd = (struct tpacket_block_desc *)pg_vec[0].buffer; pbd = (struct tpacket_block_desc *)pg_vec[0].buffer;
p1->pkblk_start = (char *)pg_vec[0].buffer; p1->pkblk_start = pg_vec[0].buffer;
p1->kblk_size = req_u->req3.tp_block_size; p1->kblk_size = req_u->req3.tp_block_size;
p1->knum_blocks = req_u->req3.tp_block_nr; p1->knum_blocks = req_u->req3.tp_block_nr;
p1->hdrlen = po->tp_hdrlen; p1->hdrlen = po->tp_hdrlen;
@ -824,8 +824,7 @@ static void prb_open_block(struct tpacket_kbdq_core *pkc1,
h1->ts_first_pkt.ts_sec = ts.tv_sec; h1->ts_first_pkt.ts_sec = ts.tv_sec;
h1->ts_first_pkt.ts_nsec = ts.tv_nsec; h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
pkc1->pkblk_start = (char *)pbd1; pkc1->pkblk_start = (char *)pbd1;
pkc1->nxt_offset = (char *)(pkc1->pkblk_start + pkc1->nxt_offset = pkc1->pkblk_start + BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
BLK_PLUS_PRIV(pkc1->blk_sizeof_priv));
BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN; BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN;
pbd1->version = pkc1->version; pbd1->version = pkc1->version;
@ -1018,7 +1017,7 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po,
struct tpacket_block_desc *pbd; struct tpacket_block_desc *pbd;
char *curr, *end; char *curr, *end;
pkc = GET_PBDQC_FROM_RB(((struct packet_ring_buffer *)&po->rx_ring)); pkc = GET_PBDQC_FROM_RB(&po->rx_ring);
pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc); pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
/* Queue is frozen when user space is lagging behind */ /* Queue is frozen when user space is lagging behind */
@ -1044,7 +1043,7 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po,
smp_mb(); smp_mb();
curr = pkc->nxt_offset; curr = pkc->nxt_offset;
pkc->skb = skb; pkc->skb = skb;
end = (char *) ((char *)pbd + pkc->kblk_size); end = (char *)pbd + pkc->kblk_size;
/* first try the current block */ /* first try the current block */
if (curr+TOTAL_PKT_LEN_INCL_ALIGN(len) < end) { if (curr+TOTAL_PKT_LEN_INCL_ALIGN(len) < end) {

View File

@ -909,8 +909,8 @@ int tipc_createport(void *usr_handle,
warn("Port creation failed, no memory\n"); warn("Port creation failed, no memory\n");
return -ENOMEM; return -ENOMEM;
} }
p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher, p_ptr = tipc_createport_raw(NULL, port_dispatcher, port_wakeup,
port_wakeup, importance); importance);
if (!p_ptr) { if (!p_ptr) {
kfree(up_ptr); kfree(up_ptr);
return -ENOMEM; return -ENOMEM;
@ -1078,8 +1078,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
if (tp_ptr->connected) { if (tp_ptr->connected) {
tp_ptr->connected = 0; tp_ptr->connected = 0;
/* let timer expire on it's own to avoid deadlock! */ /* let timer expire on it's own to avoid deadlock! */
tipc_nodesub_unsubscribe( tipc_nodesub_unsubscribe(&tp_ptr->subscription);
&((struct tipc_port *)tp_ptr)->subscription);
res = 0; res = 0;
} else { } else {
res = -ENOTCONN; res = -ENOTCONN;
@ -1099,7 +1098,7 @@ int tipc_disconnect(u32 ref)
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
res = tipc_disconnect_port((struct tipc_port *)p_ptr); res = tipc_disconnect_port(p_ptr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return res; return res;
} }

View File

@ -54,7 +54,7 @@ struct tipc_sock {
}; };
#define tipc_sk(sk) ((struct tipc_sock *)(sk)) #define tipc_sk(sk) ((struct tipc_sock *)(sk))
#define tipc_sk_port(sk) ((struct tipc_port *)(tipc_sk(sk)->p)) #define tipc_sk_port(sk) (tipc_sk(sk)->p)
#define tipc_rx_ready(sock) (!skb_queue_empty(&sock->sk->sk_receive_queue) || \ #define tipc_rx_ready(sock) (!skb_queue_empty(&sock->sk->sk_receive_queue) || \
(sock->state == SS_DISCONNECTING)) (sock->state == SS_DISCONNECTING))