From patchwork Mon Nov 3 11:31:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5216361 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 749F29F295 for ; Mon, 3 Nov 2014 11:31:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABC212010F for ; Mon, 3 Nov 2014 11:31:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D90BE20117 for ; Mon, 3 Nov 2014 11:31:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F8996E4EA; Mon, 3 Nov 2014 03:31:11 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 864506E501 for ; Mon, 3 Nov 2014 03:31:09 -0800 (PST) Received: by mail-wi0-f181.google.com with SMTP id n3so6100208wiv.2 for ; Mon, 03 Nov 2014 03:31:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=6r51rNdXvDYTxRLBnwmUpRF0r1KN6qisT067NMJVOT8=; b=QhWolMNfSyeEiCl2PIBd2ZvpqnntFaF7b+W2t4y59m7Mpu4+53A4bYtVK1CfsTa5DW 1enMS4hxBHVukT1sofiMfa+iLnsIG3g4002a0V/ZQ1q5yjtuIo0j1EdHN+SswxXehZOE PlTPrHJo0TPBHmUFdQon9+bjCyvNKTfAlxgQRsehs0f0U+zerHbem1XEKbk6Bo119cCt lXYfJ0gTqjViebMWRqhvC0WqJXvQHAE4RWDda5DJBeoAe9w0WEzEw6x/m5QjPclkIGwJ U4ezQboU94ST9/BfWakke1P1GsOd6KEDmzpNvd0vheiQoCxgiDDhejDlUbI3ip4hTCmf 8KPw== X-Gm-Message-State: ALoCoQmzM7ayqpq6tpDDWcE/0MUsBdd5v/2eaoWyrbBhZ3hyn6JzYHhvZPjfl/V8+KC64e+gEyXf X-Received: by 10.194.241.194 with SMTP id wk2mr1552956wjc.132.1415014268730; Mon, 03 Nov 2014 03:31:08 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id p3sm21845688wjf.49.2014.11.03.03.31.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Nov 2014 03:31:07 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Mon, 3 Nov 2014 11:31:03 +0000 Message-Id: <1415014265-858-3-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1415014265-858-1-git-send-email-thomas.wood@intel.com> References: <1415014265-858-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/5] testdisplay: ensure invalid long option exit status is non-zero X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The optopt variable is not set if an invalid long option is used, so check the current option character instead. Signed-off-by: Thomas Wood --- tests/testdisplay.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testdisplay.c b/tests/testdisplay.c index 09e07f0..8c6bc62 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -545,7 +545,7 @@ int update_display(void) static char optstr[] = "3hiaf:s:d:p:mrto:j:"; -static void __attribute__((noreturn)) usage(char *name) +static void __attribute__((noreturn)) usage(char *name, char opt) { igt_info("usage: %s [-hiasdpmtf]\n", name); igt_info("\t-i\tdump info\n"); @@ -563,7 +563,7 @@ static void __attribute__((noreturn)) usage(char *name) igt_info("\t\t,,,\n"); igt_info("\t\ttest force mode\n"); igt_info("\tDefault is to test all modes.\n"); - exit((optopt) ? -1 : 0); + exit((opt != 'h') ? -1 : 0); } #define dump_resource(res) if (res) dump_##res() @@ -665,7 +665,7 @@ int main(int argc, char **argv) if(sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu", &force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal, &force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9) - usage(argv[0]); + usage(argv[0], c); force_timing.clock = force_clock*1000; break; @@ -685,7 +685,7 @@ int main(int argc, char **argv) if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width, &plane_height, &crtc_x, &crtc_y, &crtc_w, &crtc_h) != 6) - usage(argv[0]); + usage(argv[0], c); test_plane = 1; break; case 'm': @@ -707,7 +707,7 @@ int main(int argc, char **argv) default: /* fall through */ case 'h': - usage(argv[0]); + usage(argv[0], c); break; } }