aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2010-02-17 04:34:12 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-17 16:27:11 -0500
commitfaf234220fb79a05891477a75180e1d9f7ab4105 (patch)
tree8ecd9e757fee2f2e81a44dd55b024528572a03e3 /net/core
parent8a5ce54562f296b1996813a413b0f2307ec9351a (diff)
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index ceef50bd131b..472a59f205b0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2228,13 +2228,10 @@ int proto_register(struct proto *prot, int alloc_slab)
2228 } 2228 }
2229 2229
2230 if (prot->rsk_prot != NULL) { 2230 if (prot->rsk_prot != NULL) {
2231 static const char mask[] = "request_sock_%s"; 2231 prot->rsk_prot->slab_name = kasprintf(GFP_KERNEL, "request_sock_%s", prot->name);
2232
2233 prot->rsk_prot->slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
2234 if (prot->rsk_prot->slab_name == NULL) 2232 if (prot->rsk_prot->slab_name == NULL)
2235 goto out_free_sock_slab; 2233 goto out_free_sock_slab;
2236 2234
2237 sprintf(prot->rsk_prot->slab_name, mask, prot->name);
2238 prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name, 2235 prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name,
2239 prot->rsk_prot->obj_size, 0, 2236 prot->rsk_prot->obj_size, 0,
2240 SLAB_HWCACHE_ALIGN, NULL); 2237 SLAB_HWCACHE_ALIGN, NULL);
@@ -2247,14 +2244,11 @@ int proto_register(struct proto *prot, int alloc_slab)
2247 } 2244 }
2248 2245
2249 if (prot->twsk_prot != NULL) { 2246 if (prot->twsk_prot != NULL) {
2250 static const char mask[] = "tw_sock_%s"; 2247 prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name);
2251
2252 prot->twsk_prot->twsk_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL);
2253 2248
2254 if (prot->twsk_prot->twsk_slab_name == NULL) 2249 if (prot->twsk_prot->twsk_slab_name == NULL)
2255 goto out_free_request_sock_slab; 2250 goto out_free_request_sock_slab;
2256 2251
2257 sprintf(prot->twsk_prot->twsk_slab_name, mask, prot->name);
2258 prot->twsk_prot->twsk_slab = 2252 prot->twsk_prot->twsk_slab =
2259 kmem_cache_create(prot->twsk_prot->twsk_slab_name, 2253 kmem_cache_create(prot->twsk_prot->twsk_slab_name,
2260 prot->twsk_prot->twsk_obj_size, 2254 prot->twsk_prot->twsk_obj_size,