From patchwork Thu Nov 3 13:57:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Kacur X-Patchwork-Id: 14895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp549499wru; Thu, 3 Nov 2022 07:01:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6E9bZQf2QjI9G4Y4+vYR69zep9RF8k4UN9xnikKEAVpb8ZfxnNWS9ZqpkplYRyeR9W0GyM X-Received: by 2002:a17:90a:d990:b0:214:2404:19f3 with SMTP id d16-20020a17090ad99000b00214240419f3mr11516273pjv.125.1667484107015; Thu, 03 Nov 2022 07:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667484107; cv=none; d=google.com; s=arc-20160816; b=eGst9D+D88DJQxQJy+kVTxw5sO5cTP1ktqojaDLYd0CxVhHhR6CGv8xMa8M7HxRscE eKYt5sqOG1wcr8ZWqHk4mfiYLL9srhbcDuRnKthRvOfjXj4OlBPGL2AvG63/p/qtjtti 5kwPM5Kt0rYbtm06iGXpBFtF4Fp94iFIUtP+ZR+5JhgAa9H4DK5Qc6go2K0iJEy5+Cg5 86uAS0D8RiqXsnx0oF0zKNmxLXs4carmDQdBFPEwMr21mViTMDM6sgwy0IrOhZQp9sru 58gaMZX3YT59R/iqt8zduQdWjC8lLAg7iPjwfC5r7raYqcd775rRkiT8uQcVihT5MEXe 9TzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=6zKL0p3k+0bFPIxIyqcrWd3FoCp9vRs2pREmUvTJ8Mc=; b=otm53VHHnBiZ+coaVsPjI3e7IWcmmGFsTJjawNTQ+ecThl9WPIEpGCCZLwDqUd8OMq 9fol5qNVIVnxOhSIbTtrggzAodaUIbKSnnDy81p7EoygphqfJVUYmlLyIAf01C4oGmuc 6SjEtxDCRf0EDGucK2xqaoOl5R/dWS5xmQLxvJxAk49Q2UZX6hIzUNK+/w7+A7tTbaf0 nE9iE+t5KxqZ3aRUTuI14ie67kQRBxGGfrkEjSoFiPpmL6xKwDUvdaN7hqjcAgSihl4v LQmVUaVgxvtFLcSRGyLg79yqHd7XxdAkHiIb5p6KJSnLCUWMIJAF1nA8sIhQJMMDXsrT rk4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=babiasjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s73-20020a63774c000000b00460b572d264si1100566pgc.579.2022.11.03.07.01.22; Thu, 03 Nov 2022 07:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=babiasjM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbiKCN6Q (ORCPT + 99 others); Thu, 3 Nov 2022 09:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbiKCN55 (ORCPT ); Thu, 3 Nov 2022 09:57:57 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56DAD15719; Thu, 3 Nov 2022 06:57:56 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id f8so1143051qkg.3; Thu, 03 Nov 2022 06:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=6zKL0p3k+0bFPIxIyqcrWd3FoCp9vRs2pREmUvTJ8Mc=; b=babiasjMmhUjUIckFVWjAZtfE17QYWSm+6fjmgKMKmggCs6wXlXlJVICsnMg1GEozV 3/xUu0VB83OyZjeiJiTsQbEuxjiHs9Re7Mc27IjSaL+Uwelsgq+NQ0E25p6rAeF8svBt Y5TldH4xoWYk07OTl2gaj3xstddjsS3ZlLeJket0UWkSCgbW0hNfYNPUX66v/F3/oTx7 Pqz5VqOjPPYPM5lVeUuECyHI74r68sbbwmu6mpb660rEPs0oADd4iT+HYjOEzCj5CgVy 24Tx6QO/y9EvxwnF0QD23l0XDevvN7Xue7SO3sDI4uiRoZuzuO727WJCaazaKY8MumXG rqtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6zKL0p3k+0bFPIxIyqcrWd3FoCp9vRs2pREmUvTJ8Mc=; b=cUE3M8rVTsugIGiHUnmvedW5isnOVWHCRjN5gkObnj9zQz9MzZ5blirZbC2GAJhnO0 V3F+HX2sB2Mur+OG548Rh2k/P4LGboDE39uYOShv6EEgxpzaULw/Bi6dX2p3GkMD1w3G eWeE5235VCTLZa4d6Ds6qsjC+oOYuySQ2EaeLqdTVp1mNJj6Q3Mm+YztfW94ekbNf7d+ nVYQ27yCpFmGfagXvAyFltckl+MyBMbh9eiRckMqaFyVN9YVPZ0QgRmxAz7L8mOYVG1+ yCAASlDy5nInDJ0Ga4/qOr7gwLMAyzG1AIqJPwwpsPcrm+jCvqAD75M6wNZ+dc+Dylgv pIEw== X-Gm-Message-State: ACrzQf00NAzrin5WADeq+L3eCcYV0tXCshUg23kGOEMhnZSgeQY3BxLW /I2imONsK2tEmdGHcN/Ho3EW8AgR5tA= X-Received: by 2002:a05:620a:84a:b0:6fa:2f1d:2ec with SMTP id u10-20020a05620a084a00b006fa2f1d02ecmr16069592qku.669.1667483875447; Thu, 03 Nov 2022 06:57:55 -0700 (PDT) Received: from fionn.redhat.com (bras-base-rdwyon0600w-grc-08-184-147-142-10.dsl.bell.ca. [184.147.142.10]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a430c00b006b640efe6dasm763495qko.132.2022.11.03.06.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 06:57:53 -0700 (PDT) Sender: John Kacur From: John Kacur To: Steven Rostedt , Daniel Bristot de Oliveria Cc: linux-trace-devel@vger.kernel.org, lkml , Clark Williams , Chang Yin , John Kacur Subject: [PATCH] rtla: Fix exit status when returning from calls to usage() Date: Thu, 3 Nov 2022 09:57:42 -0400 Message-Id: <20221103135742.9523-1-jkacur@redhat.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748483815215161962?= X-GMAIL-MSGID: =?utf-8?q?1748483815215161962?= rtla_usage(), osnoise_usage() and timerlat_usage() all exit with an error status However when these are called from help, they should exit with a non-error status. Fix this by passing the exit status to the functions Note, although we remove the subsequent call to exit after calling usage, we leave it in at the end of a function to supress the compiler warning "control reaches end of a non-void function" Signed-off-by: John Kacur --- tools/tracing/rtla/src/osnoise.c | 9 ++++----- tools/tracing/rtla/src/rtla.c | 12 +++++------- tools/tracing/rtla/src/timerlat.c | 9 ++++----- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise.c b/tools/tracing/rtla/src/osnoise.c index b8ec6c15bccb..4dee343909b1 100644 --- a/tools/tracing/rtla/src/osnoise.c +++ b/tools/tracing/rtla/src/osnoise.c @@ -903,7 +903,7 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer) return NULL; } -static void osnoise_usage(void) +static void osnoise_usage(int err) { int i; @@ -923,7 +923,7 @@ static void osnoise_usage(void) for (i = 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); - exit(1); + exit(err); } int osnoise_main(int argc, char *argv[]) @@ -941,8 +941,7 @@ int osnoise_main(int argc, char *argv[]) } if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { - osnoise_usage(); - exit(0); + osnoise_usage(0); } else if (strncmp(argv[1], "-", 1) == 0) { /* the user skipped the tool, call the default one */ osnoise_top_main(argc, argv); @@ -956,6 +955,6 @@ int osnoise_main(int argc, char *argv[]) } usage: - osnoise_usage(); + osnoise_usage(1); exit(1); } diff --git a/tools/tracing/rtla/src/rtla.c b/tools/tracing/rtla/src/rtla.c index 09bd21b8af81..52e8f1825281 100644 --- a/tools/tracing/rtla/src/rtla.c +++ b/tools/tracing/rtla/src/rtla.c @@ -14,7 +14,7 @@ /* * rtla_usage - print rtla usage */ -static void rtla_usage(void) +static void rtla_usage(int err) { int i; @@ -33,7 +33,7 @@ static void rtla_usage(void) for (i = 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); - exit(1); + exit(err); } /* @@ -70,11 +70,9 @@ int main(int argc, char *argv[]) goto usage; if (strcmp(argv[1], "-h") == 0) { - rtla_usage(); - exit(0); + rtla_usage(0); } else if (strcmp(argv[1], "--help") == 0) { - rtla_usage(); - exit(0); + rtla_usage(0); } retval = run_command(argc, argv, 1); @@ -82,6 +80,6 @@ int main(int argc, char *argv[]) exit(0); usage: - rtla_usage(); + rtla_usage(1); exit(1); } diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/timerlat.c index 97abbf494fee..21cdcc5c4a29 100644 --- a/tools/tracing/rtla/src/timerlat.c +++ b/tools/tracing/rtla/src/timerlat.c @@ -14,7 +14,7 @@ #include "timerlat.h" -static void timerlat_usage(void) +static void timerlat_usage(int err) { int i; @@ -34,7 +34,7 @@ static void timerlat_usage(void) for (i = 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); - exit(1); + exit(err); } int timerlat_main(int argc, char *argv[]) @@ -52,8 +52,7 @@ int timerlat_main(int argc, char *argv[]) } if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) { - timerlat_usage(); - exit(0); + timerlat_usage(0); } else if (strncmp(argv[1], "-", 1) == 0) { /* the user skipped the tool, call the default one */ timerlat_top_main(argc, argv); @@ -67,6 +66,6 @@ int timerlat_main(int argc, char *argv[]) } usage: - timerlat_usage(); + timerlat_usage(1); exit(1); }