net: use kasprintf() for socket cache names
kasprintf() makes code smaller. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
8a5ce54562
commit
faf234220f
@@ -2228,13 +2228,10 @@ int proto_register(struct proto *prot, int alloc_slab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prot->rsk_prot != NULL) {
|
if (prot->rsk_prot != NULL) {
|
||||||
static const char mask[] = "request_sock_%s";
|
prot->rsk_prot->slab_name = kasprintf(GFP_KERNEL, "request_sock_%s", prot->name);
|
||||||
|
|
||||||
prot->rsk_prot->slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
|
|
||||||
if (prot->rsk_prot->slab_name == NULL)
|
if (prot->rsk_prot->slab_name == NULL)
|
||||||
goto out_free_sock_slab;
|
goto out_free_sock_slab;
|
||||||
|
|
||||||
sprintf(prot->rsk_prot->slab_name, mask, prot->name);
|
|
||||||
prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name,
|
prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name,
|
||||||
prot->rsk_prot->obj_size, 0,
|
prot->rsk_prot->obj_size, 0,
|
||||||
SLAB_HWCACHE_ALIGN, NULL);
|
SLAB_HWCACHE_ALIGN, NULL);
|
||||||
@@ -2247,14 +2244,11 @@ int proto_register(struct proto *prot, int alloc_slab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prot->twsk_prot != NULL) {
|
if (prot->twsk_prot != NULL) {
|
||||||
static const char mask[] = "tw_sock_%s";
|
prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name);
|
||||||
|
|
||||||
prot->twsk_prot->twsk_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
|
|
||||||
|
|
||||||
if (prot->twsk_prot->twsk_slab_name == NULL)
|
if (prot->twsk_prot->twsk_slab_name == NULL)
|
||||||
goto out_free_request_sock_slab;
|
goto out_free_request_sock_slab;
|
||||||
|
|
||||||
sprintf(prot->twsk_prot->twsk_slab_name, mask, prot->name);
|
|
||||||
prot->twsk_prot->twsk_slab =
|
prot->twsk_prot->twsk_slab =
|
||||||
kmem_cache_create(prot->twsk_prot->twsk_slab_name,
|
kmem_cache_create(prot->twsk_prot->twsk_slab_name,
|
||||||
prot->twsk_prot->twsk_obj_size,
|
prot->twsk_prot->twsk_obj_size,
|
||||||
|
Reference in New Issue
Block a user