From 3f64699ffde6cd2152db2106505a2310601a207f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 25 Feb 2017 11:30:03 +0100 Subject: cocci: use ALLOC_ARRAY Add a semantic patch for using ALLOC_ARRAY to allocate arrays and apply the transformation on the current source tree. The macro checks for multiplication overflow and infers the element size automatically; the result is shorter and safer code. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'worktree.c') diff --git a/worktree.c b/worktree.c index eb6121263..b43160c00 100644 --- a/worktree.c +++ b/worktree.c @@ -175,7 +175,7 @@ struct worktree **get_worktrees(unsigned flags) struct dirent *d; int counter = 0, alloc = 2; - list = xmalloc(alloc * sizeof(struct worktree *)); + ALLOC_ARRAY(list, alloc); list[counter++] = get_main_worktree(); -- cgit v1.2.1