From patchwork Sat Sep 8 14:01:58 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: 14237 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TALc1-0002Ki-0Y for patchwork@linuxtv.org; Sat, 08 Sep 2012 16:02:17 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1TALc0-0002EY-E3; Sat, 08 Sep 2012 16:02:16 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754539Ab2IHOCJ (ORCPT ); Sat, 8 Sep 2012 10:02:09 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:45141 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809Ab2IHOCG (ORCPT ); Sat, 8 Sep 2012 10:02:06 -0400 Received: by weyx8 with SMTP id x8so328147wey.19 for ; Sat, 08 Sep 2012 07:02:04 -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=T0UF1kTe08X+FqpVgozpVk7Rfz1PTU+vcpbx5Cg6ny8=; b=beIOdOBqk3FIH9zTP9QN42UT2pEv2PuXSf+mcM2wCgcXWXkB5Z9C7fsfgKaFUyP3rC MFA/kXjBmlAhSq5QwibQFK3/8imD0fZ/b7ZuaKy9VnrPWwOZOSUropCFesEhF1rxd1mm j1kd4ZOMt1dsQWFr1Se7yUDs9vGyiycYVW7DNTIAn+nz3QnYW9lYLZKkLgQqa63PBLhP ojCoNk7hTRzjN/4tceb1LUOd8wy8X9Fx6xtpsa2n5IzAXlmV1Ju5RSAvoOsAdso3X6J2 QtoGxaE7KD+KEGWk7lV8uAuokL7xRiRbl3WfECa+4flrUv7G9fyolxxx+rjN6OuAhgJH c2mQ== Received: by 10.180.20.11 with SMTP id j11mr5094271wie.12.1347112924084; Sat, 08 Sep 2012 07:02:04 -0700 (PDT) Received: from localhost.localdomain ([132.227.100.38]) by mx.google.com with ESMTPS id q4sm5150057wix.9.2012.09.08.07.02.03 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 08 Sep 2012 07:02:03 -0700 (PDT) From: Peter Senna Tschudin To: Mauro Carvalho Chehab Cc: kernel-janitors@vger.kernel.org, wharms@bfs.de, Julia.Lawall@lip6.fr, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c: fix error return code Date: Sat, 8 Sep 2012 16:01:58 +0200 Message-Id: <1347112918-7738-1-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 X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.9.8.135128 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, HTML_NO_HTTP 0.1, MULTIPLE_RCPTS 0.1, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, FROM_NAME_PHRASE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS ' From: Peter Senna Tschudin Convert a nonnegative error return code to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Peter Senna Tschudin Reviewed-by: walter harms --- walter harms , thanks for the tip. Please take a look carefully to check if I got your suggestion correctly. It was tested by compilation only. drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c | 30 ++++++----------- 1 file changed, 12 insertions(+), 18 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/pci/cx25821/cx25821-video-upstream-ch2.c b/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c index c8c94fb..b663dac 100644 --- a/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/media/pci/cx25821/cx25821-video-upstream-ch2.c @@ -704,11 +704,9 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, { struct sram_channel *sram_ch; u32 tmp; - int retval = 0; int err = 0; int data_frame_size = 0; int risc_buffer_size = 0; - int str_length = 0; if (dev->_is_running_ch2) { pr_info("Video Channel is still running so return!\n"); @@ -744,20 +742,16 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, risc_buffer_size = dev->_isNTSC_ch2 ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE; - if (dev->input_filename_ch2) { - str_length = strlen(dev->input_filename_ch2); - dev->_filename_ch2 = kmemdup(dev->input_filename_ch2, - str_length + 1, GFP_KERNEL); - - if (!dev->_filename_ch2) - goto error; - } else { - str_length = strlen(dev->_defaultname_ch2); - dev->_filename_ch2 = kmemdup(dev->_defaultname_ch2, - str_length + 1, GFP_KERNEL); + if (dev->input_filename_ch2) + dev->_filename_ch2 = kstrdup(dev->input_filename_ch2, + GFP_KERNEL); + else + dev->_filename_ch2 = kstrdup(dev->_defaultname_ch2, + GFP_KERNEL); - if (!dev->_filename_ch2) - goto error; + if (!dev->_filename_ch2) { + err = -ENOENT; + goto error; } /* Default if filename is empty string */ @@ -773,7 +767,7 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, } } - retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, + err = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size_ch2, 0); /* setup fifo + format */ @@ -783,9 +777,9 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, dev->upstream_databuf_size_ch2 = data_frame_size * 2; /* Allocating buffers and prepare RISC program */ - retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, + err = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2); - if (retval < 0) { + if (err < 0) { pr_err("%s: Failed to set up Video upstream buffers!\n", dev->name); goto error;