From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759908Ab0ENULE (ORCPT ); Fri, 14 May 2010 16:11:04 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:39917 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759298Ab0ENULB (ORCPT ); Fri, 14 May 2010 16:11:01 -0400 Date: Fri, 14 May 2010 22:10:54 +0200 (CEST) From: Julia Lawall To: Martin Schwidefsky , Heiko Carstens , linux390@de.ibm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/10] drivers/s390/char: Use kstrdup In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This introduced an unused variable. I will send a revised version shortly. julia On Fri, 14 May 2010, Julia Lawall wrote: > From: Julia Lawall > > Use kstrdup when the goal of an allocation is copy a string into the > allocated region. > > The semantic patch that makes this change is as follows: > (http://coccinelle.lip6.fr/) > > // > @@ > expression x,from,to; > expression flag,E1,E2,E3; > statement S; > @@ > > - x = strlen(from) + 1; > ... when != \( x = E1 \| from = E1 \) > - to = \(kmalloc\|kzalloc\)(x,flag); > + to = kstrdup(from, flag); > ... when != \(x = E2 \| from = E2 \| to = E2 \) > if (to==NULL || ...) S > ... when != \(x = E3 \| from = E3 \| to = E3 \) > - memcpy(to, from, x); > // > > Signed-off-by: Julia Lawall > > --- > drivers/s390/char/keyboard.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff -u -p a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c > --- a/drivers/s390/char/keyboard.c > +++ b/drivers/s390/char/keyboard.c > @@ -72,11 +72,10 @@ kbd_alloc(void) { > goto out_maps; > for (i = 0; i < ARRAY_SIZE(func_table); i++) { > if (func_table[i]) { > - len = strlen(func_table[i]) + 1; > - kbd->func_table[i] = kmalloc(len, GFP_KERNEL); > + kbd->func_table[i] = kstrdup(func_table[i], > + GFP_KERNEL); > if (!kbd->func_table[i]) > goto out_func; > - memcpy(kbd->func_table[i], func_table[i], len); > } > } > kbd->fn_handler = >