提交 6257ff21 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

[NET]: Forget the zero_it argument of sk_alloc()

Finally, the zero_it argument can be completely removed from
the callers and from the function prototype.

Besides, fix the checkpatch.pl warnings about using the
assignments inside if-s.

This patch is rather big, and it is a part of the previous one.
I splitted it wishing to make the patches more readable. Hope 
this particular split helped.
Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 154adbc8
...@@ -491,7 +491,7 @@ static int pppoe_create(struct net *net, struct socket *sock) ...@@ -491,7 +491,7 @@ static int pppoe_create(struct net *net, struct socket *sock)
int error = -ENOMEM; int error = -ENOMEM;
struct sock *sk; struct sock *sk;
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto, 1); sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto);
if (!sk) if (!sk)
goto out; goto out;
......
...@@ -1416,7 +1416,7 @@ static int pppol2tp_create(struct net *net, struct socket *sock) ...@@ -1416,7 +1416,7 @@ static int pppol2tp_create(struct net *net, struct socket *sock)
int error = -ENOMEM; int error = -ENOMEM;
struct sock *sk; struct sock *sk;
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto, 1); sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto);
if (!sk) if (!sk)
goto out; goto out;
......
...@@ -779,7 +779,7 @@ extern void FASTCALL(release_sock(struct sock *sk)); ...@@ -779,7 +779,7 @@ extern void FASTCALL(release_sock(struct sock *sk));
extern struct sock *sk_alloc(struct net *net, int family, extern struct sock *sk_alloc(struct net *net, int family,
gfp_t priority, gfp_t priority,
struct proto *prot, int zero_it); struct proto *prot);
extern void sk_free(struct sock *sk); extern void sk_free(struct sock *sk);
extern struct sock *sk_clone(const struct sock *sk, extern struct sock *sk_clone(const struct sock *sk,
const gfp_t priority); const gfp_t priority);
......
...@@ -1044,7 +1044,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol) ...@@ -1044,7 +1044,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM) if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
goto out; goto out;
rc = -ENOMEM; rc = -ENOMEM;
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto, 1); sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto);
if (!sk) if (!sk)
goto out; goto out;
rc = 0; rc = 0;
......
...@@ -133,7 +133,7 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family) ...@@ -133,7 +133,7 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
sock->sk = NULL; sock->sk = NULL;
if (sock->type == SOCK_STREAM) if (sock->type == SOCK_STREAM)
return -EINVAL; return -EINVAL;
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto, 1); sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
sock_init_data(sock, sk); sock_init_data(sock, sk);
......
...@@ -836,7 +836,8 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol) ...@@ -836,7 +836,8 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
} }
if ((sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto, 1)) == NULL) sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto);
if (sk == NULL)
return -ENOMEM; return -ENOMEM;
ax25 = sk->sk_protinfo = ax25_create_cb(); ax25 = sk->sk_protinfo = ax25_create_cb();
...@@ -861,7 +862,8 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev) ...@@ -861,7 +862,8 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
struct sock *sk; struct sock *sk;
ax25_cb *ax25, *oax25; ax25_cb *ax25, *oax25;
if ((sk = sk_alloc(osk->sk_net, PF_AX25, GFP_ATOMIC, osk->sk_prot, 1)) == NULL) sk = sk_alloc(osk->sk_net, PF_AX25, GFP_ATOMIC, osk->sk_prot);
if (sk == NULL)
return NULL; return NULL;
if ((ax25 = ax25_create_cb()) == NULL) { if ((ax25 = ax25_create_cb()) == NULL) {
......
...@@ -213,7 +213,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol) ...@@ -213,7 +213,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_RAW) if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -204,7 +204,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol) ...@@ -204,7 +204,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_RAW) if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -645,7 +645,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol) ...@@ -645,7 +645,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol)
sock->ops = &hci_sock_ops; sock->ops = &hci_sock_ops;
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -255,7 +255,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol) ...@@ -255,7 +255,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_RAW) if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -607,7 +607,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p ...@@ -607,7 +607,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p
{ {
struct sock *sk; struct sock *sk;
sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto);
if (!sk) if (!sk)
return NULL; return NULL;
......
...@@ -287,7 +287,7 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int ...@@ -287,7 +287,7 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int
struct rfcomm_dlc *d; struct rfcomm_dlc *d;
struct sock *sk; struct sock *sk;
sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto);
if (!sk) if (!sk)
return NULL; return NULL;
......
...@@ -421,7 +421,7 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro ...@@ -421,7 +421,7 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro
{ {
struct sock *sk; struct sock *sk;
sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto, 1); sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto);
if (!sk) if (!sk)
return NULL; return NULL;
......
...@@ -927,7 +927,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk) ...@@ -927,7 +927,7 @@ static void sk_prot_free(struct proto *prot, struct sock *sk)
* @zero_it: if we should zero the newly allocated sock * @zero_it: if we should zero the newly allocated sock
*/ */
struct sock *sk_alloc(struct net *net, int family, gfp_t priority, struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
struct proto *prot, int zero_it) struct proto *prot)
{ {
struct sock *sk; struct sock *sk;
......
...@@ -474,7 +474,7 @@ static struct proto dn_proto = { ...@@ -474,7 +474,7 @@ static struct proto dn_proto = {
static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp) static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
{ {
struct dn_scp *scp; struct dn_scp *scp;
struct sock *sk = sk_alloc(net, PF_DECnet, gfp, &dn_proto, 1); struct sock *sk = sk_alloc(net, PF_DECnet, gfp, &dn_proto);
if (!sk) if (!sk)
goto out; goto out;
......
...@@ -624,7 +624,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol) ...@@ -624,7 +624,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol)
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
err = -ENOBUFS; err = -ENOBUFS;
sk = sk_alloc(net, PF_ECONET, GFP_KERNEL, &econet_proto, 1); sk = sk_alloc(net, PF_ECONET, GFP_KERNEL, &econet_proto);
if (sk == NULL) if (sk == NULL)
goto out; goto out;
......
...@@ -323,7 +323,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol) ...@@ -323,7 +323,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol)
BUG_TRAP(answer_prot->slab != NULL); BUG_TRAP(answer_prot->slab != NULL);
err = -ENOBUFS; err = -ENOBUFS;
sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot, 1); sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot);
if (sk == NULL) if (sk == NULL)
goto out; goto out;
......
...@@ -162,7 +162,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol) ...@@ -162,7 +162,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
BUG_TRAP(answer_prot->slab != NULL); BUG_TRAP(answer_prot->slab != NULL);
err = -ENOBUFS; err = -ENOBUFS;
sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, 1); sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot);
if (sk == NULL) if (sk == NULL)
goto out; goto out;
......
...@@ -1381,7 +1381,7 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol) ...@@ -1381,7 +1381,7 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol)
goto out; goto out;
rc = -ENOMEM; rc = -ENOMEM;
sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto, 1); sk = sk_alloc(net, PF_IPX, GFP_KERNEL, &ipx_proto);
if (!sk) if (!sk)
goto out; goto out;
#ifdef IPX_REFCNT_DEBUG #ifdef IPX_REFCNT_DEBUG
......
...@@ -1078,7 +1078,7 @@ static int irda_create(struct net *net, struct socket *sock, int protocol) ...@@ -1078,7 +1078,7 @@ static int irda_create(struct net *net, struct socket *sock, int protocol)
} }
/* Allocate networking socket */ /* Allocate networking socket */
sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto, 1); sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto);
if (sk == NULL) if (sk == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -216,7 +216,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio) ...@@ -216,7 +216,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio)
{ {
struct sock *sk; struct sock *sk;
sk = sk_alloc(&init_net, PF_IUCV, prio, &iucv_proto, 1); sk = sk_alloc(&init_net, PF_IUCV, prio, &iucv_proto);
if (!sk) if (!sk)
return NULL; return NULL;
......
...@@ -152,7 +152,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol) ...@@ -152,7 +152,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
err = -ENOMEM; err = -ENOMEM;
sk = sk_alloc(net, PF_KEY, GFP_KERNEL, &key_proto, 1); sk = sk_alloc(net, PF_KEY, GFP_KERNEL, &key_proto);
if (sk == NULL) if (sk == NULL)
goto out; goto out;
......
...@@ -869,7 +869,7 @@ static void llc_sk_init(struct sock* sk) ...@@ -869,7 +869,7 @@ static void llc_sk_init(struct sock* sk)
*/ */
struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot) struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot)
{ {
struct sock *sk = sk_alloc(net, family, priority, prot, 1); struct sock *sk = sk_alloc(net, family, priority, prot);
if (!sk) if (!sk)
goto out; goto out;
......
...@@ -396,7 +396,7 @@ static int __netlink_create(struct net *net, struct socket *sock, ...@@ -396,7 +396,7 @@ static int __netlink_create(struct net *net, struct socket *sock,
sock->ops = &netlink_ops; sock->ops = &netlink_ops;
sk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, &netlink_proto, 1); sk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, &netlink_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -423,7 +423,8 @@ static int nr_create(struct net *net, struct socket *sock, int protocol) ...@@ -423,7 +423,8 @@ static int nr_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_SEQPACKET || protocol != 0) if (sock->type != SOCK_SEQPACKET || protocol != 0)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
if ((sk = sk_alloc(net, PF_NETROM, GFP_ATOMIC, &nr_proto, 1)) == NULL) sk = sk_alloc(net, PF_NETROM, GFP_ATOMIC, &nr_proto);
if (sk == NULL)
return -ENOMEM; return -ENOMEM;
nr = nr_sk(sk); nr = nr_sk(sk);
...@@ -465,7 +466,8 @@ static struct sock *nr_make_new(struct sock *osk) ...@@ -465,7 +466,8 @@ static struct sock *nr_make_new(struct sock *osk)
if (osk->sk_type != SOCK_SEQPACKET) if (osk->sk_type != SOCK_SEQPACKET)
return NULL; return NULL;
if ((sk = sk_alloc(osk->sk_net, PF_NETROM, GFP_ATOMIC, osk->sk_prot, 1)) == NULL) sk = sk_alloc(osk->sk_net, PF_NETROM, GFP_ATOMIC, osk->sk_prot);
if (sk == NULL)
return NULL; return NULL;
nr = nr_sk(sk); nr = nr_sk(sk);
......
...@@ -995,7 +995,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol) ...@@ -995,7 +995,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol)
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
err = -ENOBUFS; err = -ENOBUFS;
sk = sk_alloc(net, PF_PACKET, GFP_KERNEL, &packet_proto, 1); sk = sk_alloc(net, PF_PACKET, GFP_KERNEL, &packet_proto);
if (sk == NULL) if (sk == NULL)
goto out; goto out;
......
...@@ -513,7 +513,8 @@ static int rose_create(struct net *net, struct socket *sock, int protocol) ...@@ -513,7 +513,8 @@ static int rose_create(struct net *net, struct socket *sock, int protocol)
if (sock->type != SOCK_SEQPACKET || protocol != 0) if (sock->type != SOCK_SEQPACKET || protocol != 0)
return -ESOCKTNOSUPPORT; return -ESOCKTNOSUPPORT;
if ((sk = sk_alloc(net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL) sk = sk_alloc(net, PF_ROSE, GFP_ATOMIC, &rose_proto);
if (sk == NULL)
return -ENOMEM; return -ENOMEM;
rose = rose_sk(sk); rose = rose_sk(sk);
...@@ -551,7 +552,8 @@ static struct sock *rose_make_new(struct sock *osk) ...@@ -551,7 +552,8 @@ static struct sock *rose_make_new(struct sock *osk)
if (osk->sk_type != SOCK_SEQPACKET) if (osk->sk_type != SOCK_SEQPACKET)
return NULL; return NULL;
if ((sk = sk_alloc(osk->sk_net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL) sk = sk_alloc(osk->sk_net, PF_ROSE, GFP_ATOMIC, &rose_proto);
if (sk == NULL)
return NULL; return NULL;
rose = rose_sk(sk); rose = rose_sk(sk);
......
...@@ -627,7 +627,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol) ...@@ -627,7 +627,7 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol)
sock->ops = &rxrpc_rpc_ops; sock->ops = &rxrpc_rpc_ops;
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
sk = sk_alloc(net, PF_RXRPC, GFP_KERNEL, &rxrpc_proto, 1); sk = sk_alloc(net, PF_RXRPC, GFP_KERNEL, &rxrpc_proto);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
......
...@@ -631,7 +631,7 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk, ...@@ -631,7 +631,7 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
struct ipv6_pinfo *newnp, *np = inet6_sk(sk); struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
struct sctp6_sock *newsctp6sk; struct sctp6_sock *newsctp6sk;
newsk = sk_alloc(sk->sk_net, PF_INET6, GFP_KERNEL, sk->sk_prot, 1); newsk = sk_alloc(sk->sk_net, PF_INET6, GFP_KERNEL, sk->sk_prot);
if (!newsk) if (!newsk)
goto out; goto out;
......
...@@ -552,7 +552,8 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk, ...@@ -552,7 +552,8 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct inet_sock *newinet; struct inet_sock *newinet;
struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL, sk->sk_prot, 1); struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL,
sk->sk_prot);
if (!newsk) if (!newsk)
goto out; goto out;
......
...@@ -201,7 +201,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) ...@@ -201,7 +201,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol)
return -EPROTOTYPE; return -EPROTOTYPE;
} }
sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto, 1); sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto);
if (!sk) { if (!sk) {
tipc_deleteport(ref); tipc_deleteport(ref);
return -ENOMEM; return -ENOMEM;
......
...@@ -602,7 +602,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) ...@@ -602,7 +602,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) if (atomic_read(&unix_nr_socks) >= 2*get_max_files())
goto out; goto out;
sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto, 1); sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto);
if (!sk) if (!sk)
goto out; goto out;
......
...@@ -472,7 +472,7 @@ static struct proto x25_proto = { ...@@ -472,7 +472,7 @@ static struct proto x25_proto = {
static struct sock *x25_alloc_socket(struct net *net) static struct sock *x25_alloc_socket(struct net *net)
{ {
struct x25_sock *x25; struct x25_sock *x25;
struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto, 1); struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto);
if (!sk) if (!sk)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册