From patchwork Sun May 8 23:03:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Oberritter X-Patchwork-Id: 6552 Return-path: Envelope-to: mchehab@gaivota Delivery-date: Sun, 08 May 2011 23:27:23 -0300 Received: from mchehab by gaivota with local (Exim 4.73) (envelope-from ) id 1QJGBv-0001oB-Ho for mchehab@gaivota; Sun, 08 May 2011 23:27:23 -0300 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.19) for (single-drop); Sun, 08 May 2011 23:27:23 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QJDAX-0000lm-58; Sun, 08 May 2011 23:13:45 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755794Ab1EHXNb (ORCPT + 1 other); Sun, 8 May 2011 19:13:31 -0400 Received: from mail.dream-property.net ([82.149.226.172]:52925 "EHLO mail.dream-property.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755703Ab1EHXNW (ORCPT ); Sun, 8 May 2011 19:13:22 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.dream-property.net (Postfix) with ESMTP id 12DA83150C69; Mon, 9 May 2011 01:03:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.dream-property.net Received: from mail.dream-property.net ([127.0.0.1]) by localhost (mail.dream-property.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UgsAwGsD3drs; Mon, 9 May 2011 01:03:44 +0200 (CEST) Received: from pepe.multimedia-labs.de (dreamboxupdate.com [82.149.226.174]) by mail.dream-property.net (Postfix) with SMTP id 9434B3150C73; Mon, 9 May 2011 01:03:43 +0200 (CEST) Received: by pepe.multimedia-labs.de (sSMTP sendmail emulation); Sun, 08 May 2011 23:03:43 +0000 From: Andreas Oberritter To: linux-media@vger.kernel.org Cc: Thierry LELEGARD Subject: [PATCH 1/8] DVB: return meaningful error codes in dvb_frontend Date: Sun, 8 May 2011 23:03:34 +0000 Message-Id: <1304895821-21642-2-git-send-email-obi@linuxtv.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1304895821-21642-1-git-send-email-obi@linuxtv.org> References: <1304895821-21642-1-git-send-email-obi@linuxtv.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab - Return values should not be ORed. Abort early instead. - Return -EINVAL instead of -1. Signed-off-by: Andreas Oberritter --- drivers/media/dvb/dvb-core/dvb_frontend.c | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index d04ef09..be0f631 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -1327,12 +1327,12 @@ static int dtv_property_process_get(struct dvb_frontend *fe, tvp->u.data = fe->dtv_property_cache.dvbt2_plp_id; break; default: - r = -1; + return -EINVAL; } dtv_property_dump(tvp); - return r; + return 0; } static int dtv_property_process_set(struct dvb_frontend *fe, @@ -1344,11 +1344,11 @@ static int dtv_property_process_set(struct dvb_frontend *fe, dtv_property_dump(tvp); /* Allow the frontend to validate incoming properties */ - if (fe->ops.set_property) + if (fe->ops.set_property) { r = fe->ops.set_property(fe, tvp); - - if (r < 0) - return r; + if (r < 0) + return r; + } switch(tvp->cmd) { case DTV_CLEAR: @@ -1367,7 +1367,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe, dprintk("%s() Finalised property cache\n", __func__); dtv_property_cache_submit(fe); - r |= dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND, + r = dvb_frontend_ioctl_legacy(file, FE_SET_FRONTEND, &fepriv->parameters); break; case DTV_FREQUENCY: @@ -1485,7 +1485,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe, fe->dtv_property_cache.dvbt2_plp_id = tvp->u.data; break; default: - r = -1; + return -EINVAL; } return r; @@ -1559,8 +1559,10 @@ static int dvb_frontend_ioctl_properties(struct file *file, } for (i = 0; i < tvps->num; i++) { - (tvp + i)->result = dtv_property_process_set(fe, tvp + i, file); - err |= (tvp + i)->result; + err = dtv_property_process_set(fe, tvp + i, file); + if (err < 0) + goto out; + (tvp + i)->result = err; } if(fe->dtv_property_cache.state == DTV_TUNE) @@ -1591,8 +1593,10 @@ static int dvb_frontend_ioctl_properties(struct file *file, } for (i = 0; i < tvps->num; i++) { - (tvp + i)->result = dtv_property_process_get(fe, tvp + i, file); - err |= (tvp + i)->result; + err = dtv_property_process_get(fe, tvp + i, file); + if (err < 0) + goto out; + (tvp + i)->result = err; } if (copy_to_user(tvps->props, tvp, tvps->num * sizeof(struct dtv_property))) {