[NET]: Conversions from kmalloc+memset to k(z|c)alloc.
Signed-off-by: Panagiotis Issaris <takis@issaris.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
a0ee7c70b2
commit
0da974f4f3
@ -665,11 +665,9 @@ int tipc_bearer_init(void)
|
||||
int res;
|
||||
|
||||
write_lock_bh(&tipc_net_lock);
|
||||
tipc_bearers = kmalloc(MAX_BEARERS * sizeof(struct bearer), GFP_ATOMIC);
|
||||
media_list = kmalloc(MAX_MEDIA * sizeof(struct media), GFP_ATOMIC);
|
||||
tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC);
|
||||
media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC);
|
||||
if (tipc_bearers && media_list) {
|
||||
memset(tipc_bearers, 0, MAX_BEARERS * sizeof(struct bearer));
|
||||
memset(media_list, 0, MAX_MEDIA * sizeof(struct media));
|
||||
res = TIPC_OK;
|
||||
} else {
|
||||
kfree(tipc_bearers);
|
||||
|
@ -57,29 +57,25 @@ struct cluster *tipc_cltr_create(u32 addr)
|
||||
struct _zone *z_ptr;
|
||||
struct cluster *c_ptr;
|
||||
int max_nodes;
|
||||
int alloc;
|
||||
|
||||
c_ptr = (struct cluster *)kmalloc(sizeof(*c_ptr), GFP_ATOMIC);
|
||||
c_ptr = kzalloc(sizeof(*c_ptr), GFP_ATOMIC);
|
||||
if (c_ptr == NULL) {
|
||||
warn("Cluster creation failure, no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(c_ptr, 0, sizeof(*c_ptr));
|
||||
|
||||
c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
|
||||
if (in_own_cluster(addr))
|
||||
max_nodes = LOWEST_SLAVE + tipc_max_slaves;
|
||||
else
|
||||
max_nodes = tipc_max_nodes + 1;
|
||||
alloc = sizeof(void *) * (max_nodes + 1);
|
||||
|
||||
c_ptr->nodes = (struct node **)kmalloc(alloc, GFP_ATOMIC);
|
||||
c_ptr->nodes = kcalloc(max_nodes + 1, sizeof(void*), GFP_ATOMIC);
|
||||
if (c_ptr->nodes == NULL) {
|
||||
warn("Cluster creation failure, no memory for node area\n");
|
||||
kfree(c_ptr);
|
||||
return NULL;
|
||||
}
|
||||
memset(c_ptr->nodes, 0, alloc);
|
||||
|
||||
if (in_own_cluster(addr))
|
||||
tipc_local_nodes = c_ptr->nodes;
|
||||
|
@ -417,12 +417,11 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
|
||||
struct tipc_msg *msg;
|
||||
char *if_name;
|
||||
|
||||
l_ptr = (struct link *)kmalloc(sizeof(*l_ptr), GFP_ATOMIC);
|
||||
l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC);
|
||||
if (!l_ptr) {
|
||||
warn("Link creation failed, no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(l_ptr, 0, sizeof(*l_ptr));
|
||||
|
||||
l_ptr->addr = peer;
|
||||
if_name = strchr(b_ptr->publ.name, ':') + 1;
|
||||
|
@ -117,14 +117,12 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
|
||||
u32 scope, u32 node, u32 port_ref,
|
||||
u32 key)
|
||||
{
|
||||
struct publication *publ =
|
||||
(struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC);
|
||||
struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC);
|
||||
if (publ == NULL) {
|
||||
warn("Publication creation failure, no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(publ, 0, sizeof(*publ));
|
||||
publ->type = type;
|
||||
publ->lower = lower;
|
||||
publ->upper = upper;
|
||||
@ -144,11 +142,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
|
||||
|
||||
static struct sub_seq *tipc_subseq_alloc(u32 cnt)
|
||||
{
|
||||
u32 sz = cnt * sizeof(struct sub_seq);
|
||||
struct sub_seq *sseq = (struct sub_seq *)kmalloc(sz, GFP_ATOMIC);
|
||||
|
||||
if (sseq)
|
||||
memset(sseq, 0, sz);
|
||||
struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC);
|
||||
return sseq;
|
||||
}
|
||||
|
||||
@ -160,8 +154,7 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt)
|
||||
|
||||
static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head)
|
||||
{
|
||||
struct name_seq *nseq =
|
||||
(struct name_seq *)kmalloc(sizeof(*nseq), GFP_ATOMIC);
|
||||
struct name_seq *nseq = kzalloc(sizeof(*nseq), GFP_ATOMIC);
|
||||
struct sub_seq *sseq = tipc_subseq_alloc(1);
|
||||
|
||||
if (!nseq || !sseq) {
|
||||
@ -171,7 +164,6 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(nseq, 0, sizeof(*nseq));
|
||||
spin_lock_init(&nseq->lock);
|
||||
nseq->type = type;
|
||||
nseq->sseqs = sseq;
|
||||
@ -1060,7 +1052,7 @@ int tipc_nametbl_init(void)
|
||||
{
|
||||
int array_size = sizeof(struct hlist_head) * tipc_nametbl_size;
|
||||
|
||||
table.types = (struct hlist_head *)kmalloc(array_size, GFP_ATOMIC);
|
||||
table.types = kmalloc(array_size, GFP_ATOMIC);
|
||||
if (!table.types)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -160,14 +160,11 @@ void tipc_net_send_external_routes(u32 dest)
|
||||
|
||||
static int net_init(void)
|
||||
{
|
||||
u32 sz = sizeof(struct _zone *) * (tipc_max_zones + 1);
|
||||
|
||||
memset(&tipc_net, 0, sizeof(tipc_net));
|
||||
tipc_net.zones = (struct _zone **)kmalloc(sz, GFP_ATOMIC);
|
||||
tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC);
|
||||
if (!tipc_net.zones) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(tipc_net.zones, 0, sz);
|
||||
return TIPC_OK;
|
||||
}
|
||||
|
||||
|
@ -226,12 +226,11 @@ u32 tipc_createport_raw(void *usr_handle,
|
||||
struct tipc_msg *msg;
|
||||
u32 ref;
|
||||
|
||||
p_ptr = kmalloc(sizeof(*p_ptr), GFP_ATOMIC);
|
||||
p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC);
|
||||
if (!p_ptr) {
|
||||
warn("Port creation failed, no memory\n");
|
||||
return 0;
|
||||
}
|
||||
memset(p_ptr, 0, sizeof(*p_ptr));
|
||||
ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock);
|
||||
if (!ref) {
|
||||
warn("Port creation failed, reference table exhausted\n");
|
||||
@ -1058,7 +1057,7 @@ int tipc_createport(u32 user_ref,
|
||||
struct port *p_ptr;
|
||||
u32 ref;
|
||||
|
||||
up_ptr = (struct user_port *)kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
|
||||
up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
|
||||
if (!up_ptr) {
|
||||
warn("Port creation failed, no memory\n");
|
||||
return -ENOMEM;
|
||||
|
@ -393,12 +393,11 @@ static void subscr_named_msg_event(void *usr_handle,
|
||||
|
||||
/* Create subscriber object */
|
||||
|
||||
subscriber = kmalloc(sizeof(struct subscriber), GFP_ATOMIC);
|
||||
subscriber = kzalloc(sizeof(struct subscriber), GFP_ATOMIC);
|
||||
if (subscriber == NULL) {
|
||||
warn("Subscriber rejected, no memory\n");
|
||||
return;
|
||||
}
|
||||
memset(subscriber, 0, sizeof(struct subscriber));
|
||||
INIT_LIST_HEAD(&subscriber->subscription_list);
|
||||
INIT_LIST_HEAD(&subscriber->subscriber_list);
|
||||
subscriber->ref = tipc_ref_acquire(subscriber, &subscriber->lock);
|
||||
|
@ -82,9 +82,8 @@ static int reg_init(void)
|
||||
|
||||
spin_lock_bh(®_lock);
|
||||
if (!users) {
|
||||
users = (struct tipc_user *)kmalloc(USER_LIST_SIZE, GFP_ATOMIC);
|
||||
users = kzalloc(USER_LIST_SIZE, GFP_ATOMIC);
|
||||
if (users) {
|
||||
memset(users, 0, USER_LIST_SIZE);
|
||||
for (i = 1; i <= MAX_USERID; i++) {
|
||||
users[i].next = i - 1;
|
||||
}
|
||||
|
@ -52,13 +52,12 @@ struct _zone *tipc_zone_create(u32 addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
z_ptr = (struct _zone *)kmalloc(sizeof(*z_ptr), GFP_ATOMIC);
|
||||
z_ptr = kzalloc(sizeof(*z_ptr), GFP_ATOMIC);
|
||||
if (!z_ptr) {
|
||||
warn("Zone creation failed, insufficient memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(z_ptr, 0, sizeof(*z_ptr));
|
||||
z_num = tipc_zone(addr);
|
||||
z_ptr->addr = tipc_addr(z_num, 0, 0);
|
||||
tipc_net.zones[z_num] = z_ptr;
|
||||
|
Reference in New Issue
Block a user