From patchwork Tue Nov 5 12:00:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1189635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 476pCd4qZnz9sNT for ; Tue, 5 Nov 2019 23:01:01 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9ADD33C22C6 for ; Tue, 5 Nov 2019 13:00:58 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id A61A33C2296 for ; Tue, 5 Nov 2019 13:00:56 +0100 (CET) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id CD90C601715 for ; Tue, 5 Nov 2019 13:00:55 +0100 (CET) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E3783B50E; Tue, 5 Nov 2019 12:00:54 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Tue, 5 Nov 2019 13:00:53 +0100 Message-Id: <20191105120053.9173-1-chrubis@suse.cz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH] lib/tst_test: Warn on repeated options X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The library is not designed in a way that would allow us to pass an option mutiple times, if such case the last option occurence replaces all previous ones. This patch adds a warning in a case that the option pointer is non-NULL, which means that it has been set at least once already. Signed-off-by: Cyril Hrubis CC: Jan Stancek Acked-by: Jan Stancek --- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tst_test.c b/lib/tst_test.c index c7b46d0d5..f41baf3cf 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -468,6 +468,9 @@ static void parse_topt(unsigned int topts_len, int opt, char *optarg) if (i >= topts_len) tst_brk(TBROK, "Invalid option '%c' (should not happen)", opt); + if (*toptions[i].arg) + tst_res(TWARN, "Option passed -%c multiple times", opt); + *(toptions[i].arg) = optarg ? optarg : ""; }