From patchwork Thu Nov 12 07:23:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOpbWV0aCBNw6FydG9u?= X-Patchwork-Id: 2057 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Thu, 12 Nov 2009 07:23:48 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra.chehab.org with IMAP (fetchmail-6.3.6) for (single-drop); Thu, 12 Nov 2009 08:16:42 -0200 (BRST) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1N8U1z-0007Dv-W7; Thu, 12 Nov 2009 07:23:48 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751334AbZKLHXk (ORCPT + 1 other); Thu, 12 Nov 2009 02:23:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751314AbZKLHXk (ORCPT ); Thu, 12 Nov 2009 02:23:40 -0500 Received: from mail01a.mail.t-online.hu ([84.2.40.6]:53852 "EHLO mail01a.mail.t-online.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbZKLHXk (ORCPT ); Thu, 12 Nov 2009 02:23:40 -0500 Received: from [192.168.1.64] (dsl5402C46E.pool.t-online.hu [84.2.196.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail01a.mail.t-online.hu (Postfix) with ESMTPSA id 9BDB779856F; Thu, 12 Nov 2009 08:23:09 +0100 (CET) Message-ID: <4AFBB7FD.5090607@freemail.hu> Date: Thu, 12 Nov 2009 08:23:41 +0100 From: =?UTF-8?B?TsOpbWV0aCBNw6FydG9u?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; hu-HU; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16 MIME-Version: 1.0 To: Hans Verkuil CC: Hans de Goede , Jean-Francois Moine , V4L Mailing List Subject: Re: [PATCH] v4l2-dbg: report fail reason to the user References: <4AF6BA72.4070809@freemail.hu> <200911091116.06578.hverkuil@xs4all.nl> <4AF8F8EB.8090705@freemail.hu> In-Reply-To: <4AF8F8EB.8090705@freemail.hu> X-DCC-mail.t-online.hu-Metrics: mail01a.mail.t-online.hu 32721; Body=4 Fuz1=4 Fuz2=4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Márton Németh Report the fail reason to the user when writing a register even if the verbose mode is switched off. Remove duplicated code ioctl() call which may cause different ioctl() function call in case of verbose and non verbose if not handled carefully. Signed-off-by: Márton Németh --- -- 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 -r 60f784aa071d v4l2-apps/util/v4l2-dbg.cpp --- a/v4l2-apps/util/v4l2-dbg.cpp Wed Nov 11 18:28:53 2009 +0100 +++ b/v4l2-apps/util/v4l2-dbg.cpp Thu Nov 12 08:21:20 2009 +0100 @@ -353,14 +353,21 @@ static int doioctl(int fd, int request, void *parm, const char *name) { int retVal; + int ioctl_errno; if (!options[OptVerbose]) return ioctl(fd, request, parm); retVal = ioctl(fd, request, parm); - printf("%s: ", name); - if (retVal < 0) - printf("failed: %s\n", strerror(errno)); - else - printf("ok\n"); + if (options[OptVerbose]) { + /* Save errno because printf() may modify it */ + ioctl_errno = errno; + printf("%s: ", name); + if (retVal < 0) + printf("failed: %s\n", strerror(errno)); + else + printf("ok\n"); + /* Restore errno for caller's use */ + errno = ioctl_errno; + } return retVal; } @@ -586,8 +593,8 @@ printf(" set to 0x%llx\n", set_reg.val); } else { - printf("Failed to set register 0x%08llx value 0x%llx\n", - set_reg.reg, set_reg.val); + printf("Failed to set register 0x%08llx value 0x%llx: %s\n", + set_reg.reg, set_reg.val, strerror(errno)); } set_reg.reg++; }