Commit 2453a306 authored by Matt Helsley's avatar Matt Helsley Committed by Linus Torvalds

[PATCH] ipc: replace kmalloc and memset in get_undo_list with kzalloc

Simplify get_undo_list() by dropping the unnecessary cast, removing the
size variable, and switching to kzalloc() instead of a kmalloc() followed
by a memset().

This cleanup was split then modified from Jes Sorenson's Task Notifiers
patches.
Signed-off-by: default avatarMatt Helsley <matthltc@us.ibm.com>
Cc: Jes Sorensen <jes@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5d124e99
...@@ -1003,15 +1003,12 @@ static inline void unlock_semundo(void) ...@@ -1003,15 +1003,12 @@ static inline void unlock_semundo(void)
static inline int get_undo_list(struct sem_undo_list **undo_listp) static inline int get_undo_list(struct sem_undo_list **undo_listp)
{ {
struct sem_undo_list *undo_list; struct sem_undo_list *undo_list;
int size;
undo_list = current->sysvsem.undo_list; undo_list = current->sysvsem.undo_list;
if (!undo_list) { if (!undo_list) {
size = sizeof(struct sem_undo_list); undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);
undo_list = (struct sem_undo_list *) kmalloc(size, GFP_KERNEL);
if (undo_list == NULL) if (undo_list == NULL)
return -ENOMEM; return -ENOMEM;
memset(undo_list, 0, size);
spin_lock_init(&undo_list->lock); spin_lock_init(&undo_list->lock);
atomic_set(&undo_list->refcnt, 1); atomic_set(&undo_list->refcnt, 1);
current->sysvsem.undo_list = undo_list; current->sysvsem.undo_list = undo_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment