From patchwork Mon Sep 17 08:04: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: 1465901 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 93FB03FCFC for ; Mon, 17 Sep 2012 08:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754824Ab2IQIFR (ORCPT ); Mon, 17 Sep 2012 04:05:17 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:55405 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754516Ab2IQIFO (ORCPT ); Mon, 17 Sep 2012 04:05:14 -0400 Received: by weyx8 with SMTP id x8so3702197wey.19 for ; Mon, 17 Sep 2012 01:05:13 -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:in-reply-to:references; bh=uLP95kJVd1ACAJ8It9fTppsp8RTs1ySkTMcGbZUvyEY=; b=DNBoqLVTfTE1OoTTJryi9PuUVLIQMw50I5NWd5UpKq7Yoi9v3SBTUE0fBvQ7gpT+/v E01a5/dMKNE3p1DlSxvk05g+Chwl28Lw6RZBHpfQiRsxfhCJ4cjLuxirHPV2/6OqIf2h 0eQH2dR9eixkvkA+lU9yyQSQ9TLq4eUTPVv+/DlOsKgRlxydkJo3Px7Zn5qAyz583aCn m40z2Ipb3aJgH5U8+VKycKc8v7Xr+3rB3PQE4/ReSl5f3g0WzPvzTQB5LQZViT7qpAHP eoJZNvVc3RJo86+kehJvkeJOq2bcoPqrhYhp9+0YcgCeS3mf729mYHPIeCX/aRKNsyO3 FIGg== Received: by 10.216.234.100 with SMTP id r78mr5494241weq.107.1347869113060; Mon, 17 Sep 2012 01:05:13 -0700 (PDT) Received: from ace.home.fr (ppeter.rsr.lip6.fr. [132.227.76.16]) by mx.google.com with ESMTPS id o2sm24216119wiz.11.2012.09.17.01.05.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 01:05:12 -0700 (PDT) From: Peter Senna Tschudin To: mchehab@infradead.org Cc: leonidsbox@gmail.com, peter.senna@gmail.com, thomas@m3y3r.de, hans.verkuil@cisco.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] cx25821: Cleanup filename assignment code Date: Mon, 17 Sep 2012 10:04:58 +0200 Message-Id: <1347869098-2236-3-git-send-email-peter.senna@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1347869098-2236-1-git-send-email-peter.senna@gmail.com> References: <1347869098-2236-1-git-send-email-peter.senna@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org I'm pasting the original code and my proposal on the commit message for make it easy to compare the two versions. Line 62 of cx25821-audio-upstream.h contains: char *_defaultAudioName = "/root/audioGOOD.wav"; Original code after replace kmemdup for kstrdup, and after fix return error code: if (dev->input_audiofilename) { dev->_audiofilename = kstrdup(dev->input_audiofilename, GFP_KERNEL); if (!dev->_audiofilename) { err = -ENOMEM; goto error; } /* Default if filename is empty string */ if (strcmp(dev->input_audiofilename, "") == 0) dev->_audiofilename = "/root/audioGOOD.wav"; } else { dev->_audiofilename = kstrdup(_defaultAudioName, GFP_KERNEL); if (!dev->_audiofilename) { err = -ENOMEM; goto error; } } Code proposed in this patch: if ((dev->input_audiofilename) && (strcmp(dev->input_audiofilename, "") != 0)) dev->_audiofilename = kstrdup(dev->input_audiofilename, GFP_KERNEL); else dev->_audiofilename = kstrdup(_defaultAudioName, GFP_KERNEL); if (!dev->_audiofilename) { err = -ENOMEM; goto error; } Signed-off-by: Peter Senna Tschudin --- drivers/media/pci/cx25821/cx25821-audio-upstream.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c index 1cc797e..83316a8 100644 --- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c @@ -728,26 +728,17 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER; _line_size = AUDIO_LINE_SIZE; - if (dev->input_audiofilename) { + if ((dev->input_audiofilename) && + (strcmp(dev->input_audiofilename, "") != 0)) dev->_audiofilename = kstrdup(dev->input_audiofilename, GFP_KERNEL); - - if (!dev->_audiofilename) { - err = -ENOMEM; - goto error; - } - - /* Default if filename is empty string */ - if (strcmp(dev->input_audiofilename, "") == 0) - dev->_audiofilename = "/root/audioGOOD.wav"; - } else { + else dev->_audiofilename = kstrdup(_defaultAudioName, GFP_KERNEL); - if (!dev->_audiofilename) { - err = -ENOMEM; - goto error; - } + if (!dev->_audiofilename) { + err = -ENOMEM; + goto error; } cx25821_sram_channel_setup_upstream_audio(dev, sram_ch,