From patchwork Mon Feb 23 15:26:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schwarzott X-Patchwork-Id: 8422 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1NFQkj6013181 for ; Mon, 23 Feb 2009 15:26:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754425AbZBWP0q (ORCPT ); Mon, 23 Feb 2009 10:26:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754463AbZBWP0q (ORCPT ); Mon, 23 Feb 2009 10:26:46 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:36270 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754425AbZBWP0p (ORCPT ); Mon, 23 Feb 2009 10:26:45 -0500 Received: from mail01.m-online.net (mail.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 536381C1533B; Mon, 23 Feb 2009 16:26:53 +0100 (CET) Received: from localhost (dynscan2.mnet-online.de [192.168.1.215]) by mail.m-online.net (Postfix) with ESMTP id 59BC890111; Mon, 23 Feb 2009 16:26:42 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.3.149]) by localhost (dynscan2.mnet-online.de [192.168.1.215]) (amavisd-new, port 10024) with ESMTP id Wirb+OkiGKdW; Mon, 23 Feb 2009 16:26:39 +0100 (CET) Received: from gauss.x.fun (ppp-88-217-122-135.dynamic.mnet-online.de [88.217.122.135]) by mail.nefkom.net (Postfix) with ESMTP; Mon, 23 Feb 2009 16:26:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by gauss.x.fun (Postfix) with ESMTP id 59C1FDD710; Mon, 23 Feb 2009 16:26:39 +0100 (CET) From: Matthias Schwarzott To: linux-media@vger.kernel.org Subject: [PATCH] remove redundant memset after kzalloc Date: Mon, 23 Feb 2009 16:26:38 +0100 User-Agent: KMail/1.9.10 Cc: Markus Rechberger , Patrick Boettcher , Steven Toth MIME-Version: 1.0 Message-Id: <200902231626.38940.zzam@gentoo.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi there! While having a look at the allocation of struct dvb_frontend in *_attach functions, I found some cases calling memset after kzalloc. This is redundant, and the attached patch removes these calls. I also changed one case calling kmalloc and memset to kzalloc. Signed-off-by: Matthias Schwarzott Regards Matthias Index: v4l-dvb/linux/drivers/media/dvb/frontends/cx24113.c =================================================================== --- v4l-dvb.orig/linux/drivers/media/dvb/frontends/cx24113.c +++ v4l-dvb/linux/drivers/media/dvb/frontends/cx24113.c @@ -559,7 +559,7 @@ struct dvb_frontend *cx24113_attach(stru kzalloc(sizeof(struct cx24113_state), GFP_KERNEL); int rc; if (state == NULL) { - err("Unable to kmalloc\n"); + err("Unable to kzalloc\n"); goto error; } Index: v4l-dvb/linux/drivers/media/dvb/frontends/cx24116.c =================================================================== --- v4l-dvb.orig/linux/drivers/media/dvb/frontends/cx24116.c +++ v4l-dvb/linux/drivers/media/dvb/frontends/cx24116.c @@ -1112,13 +1112,10 @@ struct dvb_frontend *cx24116_attach(cons dprintk("%s\n", __func__); /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); + state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL); if (state == NULL) goto error1; - /* setup the state */ - memset(state, 0, sizeof(struct cx24116_state)); - state->config = config; state->i2c = i2c; Index: v4l-dvb/linux/drivers/media/dvb/frontends/cx24123.c =================================================================== --- v4l-dvb.orig/linux/drivers/media/dvb/frontends/cx24123.c +++ v4l-dvb/linux/drivers/media/dvb/frontends/cx24123.c @@ -1084,13 +1084,13 @@ static struct dvb_frontend_ops cx24123_o struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, struct i2c_adapter *i2c) { + /* allocate memory for the internal state */ struct cx24123_state *state = kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); dprintk("\n"); - /* allocate memory for the internal state */ if (state == NULL) { - err("Unable to kmalloc\n"); + err("Unable to kzalloc\n"); goto error; } Index: v4l-dvb/linux/drivers/media/dvb/frontends/lgdt3304.c =================================================================== --- v4l-dvb.orig/linux/drivers/media/dvb/frontends/lgdt3304.c +++ v4l-dvb/linux/drivers/media/dvb/frontends/lgdt3304.c @@ -383,7 +383,6 @@ struct dvb_frontend* lgdt3304_attach(con struct lgdt3304_state *state; state = kzalloc(sizeof(struct lgdt3304_state), GFP_KERNEL); - memset(state, 0x0, sizeof(struct lgdt3304_state)); state->addr = config->i2c_address; state->i2c = i2c; Index: v4l-dvb/linux/drivers/media/dvb/frontends/s921_module.c =================================================================== --- v4l-dvb.orig/linux/drivers/media/dvb/frontends/s921_module.c +++ v4l-dvb/linux/drivers/media/dvb/frontends/s921_module.c @@ -233,7 +233,6 @@ struct dvb_frontend* s921_attach(const s struct s921_state *state; state = kzalloc(sizeof(struct s921_state), GFP_KERNEL); - memset(state, 0x0, sizeof(struct s921_state)); state->addr = config->i2c_address; state->i2c = i2c;