From patchwork Wed Sep 12 12:56:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Senna Tschudin X-Patchwork-Id: 1443561 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0DF05DF28C for ; Wed, 12 Sep 2012 12:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758452Ab2ILM5X (ORCPT ); Wed, 12 Sep 2012 08:57:23 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:37861 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758355Ab2ILM42 (ORCPT ); Wed, 12 Sep 2012 08:56:28 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so964139wey.19 for ; Wed, 12 Sep 2012 05:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=g7+/AuJbVsY/Ab1v3n6cCWdZ0eSpih2TpUNvFcCmc+Y=; b=dVYS+2djrKgmwH3MoED4I/5uGNJUB6RcpuaaXYUOzKPJVeUZDuBgDkVwILfKzZylt/ 8Y8FT/J49ZBDfiP6mfJpOIfyKedFUM/Y3qN3mD8JWmVjWwFMdyr4JOQ5nLub43+BQuGo +rSBruplIcBuFIdkVnr/hSYtMRrRNrcbph1jDLrlqU6St46MTqTV0/NBb0dTofn/AbmX WECmNnW8MM1mDVToXU/4wu+fkSS6c3A7uhnF2LNiYYZomX1nMOQMz+llVzjU3IMS/lZp Z04aRASUpU1r4AgNhHgEP12Us+EeNwZb1SFGVKiSl+fLhL7ooxgyhaA3EuQh0otdMbQ2 eJPw== Received: by 10.216.242.196 with SMTP id i46mr11318089wer.123.1347454587404; Wed, 12 Sep 2012 05:56:27 -0700 (PDT) Received: from localhost.localdomain (ppeter.rsr.lip6.fr. [132.227.76.16]) by mx.google.com with ESMTPS id cl8sm7933596wib.10.2012.09.12.05.56.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 05:56:26 -0700 (PDT) From: Peter Senna Tschudin To: Mauro Carvalho Chehab Cc: kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/8] drivers/media/dvb-frontends/dvb_dummy_fe.c: Removes useless kfree() Date: Wed, 12 Sep 2012 14:56:04 +0200 Message-Id: <1347454564-5178-8-git-send-email-peter.senna@gmail.com> X-Mailer: git-send-email 1.7.11.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Peter Senna Tschudin Remove useless kfree() and clean up code related to the removal. The semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r exists@ position p1,p2; expression x; @@ if (x@p1 == NULL) { ... kfree@p2(x); ... return ...; } @unchanged exists@ position r.p1,r.p2; expression e <= r.x,x,e1; iterator I; statement S; @@ if (x@p1 == NULL) { ... when != I(x,...) S when != e = e1 when != e += e1 when != e -= e1 when != ++e when != --e when != e++ when != e-- when != &e kfree@p2(x); ... return ...; } @ok depends on unchanged exists@ position any r.p1; position r.p2; expression x; @@ ... when != true x@p1 == NULL kfree@p2(x); @depends on !ok && unchanged@ position r.p2; expression x; @@ *kfree@p2(x); // Signed-off-by: Peter Senna Tschudin --- drivers/media/dvb-frontends/dvb_dummy_fe.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c index dcfc902..d5acc30 100644 --- a/drivers/media/dvb-frontends/dvb_dummy_fe.c +++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c @@ -121,16 +121,13 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) /* allocate memory for the internal state */ state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); - if (state == NULL) goto error; + if (!state) + return NULL; /* create dvb_frontend */ memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; return &state->frontend; - -error: - kfree(state); - return NULL; } static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; @@ -141,16 +138,13 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void) /* allocate memory for the internal state */ state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); - if (state == NULL) goto error; + if (!state) + return NULL; /* create dvb_frontend */ memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; return &state->frontend; - -error: - kfree(state); - return NULL; } static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; @@ -161,16 +155,13 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void) /* allocate memory for the internal state */ state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); - if (state == NULL) goto error; + if (!state) + return NULL; /* create dvb_frontend */ memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops)); state->frontend.demodulator_priv = state; return &state->frontend; - -error: - kfree(state); - return NULL; } static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {