Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp1942230rwa; Sun, 21 Aug 2022 21:56:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5QhQwXa0lwHcjQEBeaZw8pUWoB+7YYwQKylCiaW8F3b1ny0tP5nFkuGA2GhPFv/O4bqwlK X-Received: by 2002:a17:907:2e01:b0:730:9ecc:cd28 with SMTP id ig1-20020a1709072e0100b007309ecccd28mr11609460ejc.360.1661144218760; Sun, 21 Aug 2022 21:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661144218; cv=none; d=google.com; s=arc-20160816; b=eOIIsPb2uFhHL8mVecDZduacFMiRorVuSY+EIcIIlRccFPVk1gV5tK4UksJh1mG4h/ 8c2OQmLYWYU6pLp7voS8HB4PW+8mj9SMEOAJm8DncxaWngpmkv+AnJ6OmO+PjLB6FJDj 47Cwns3MtwxxNhF8baJCnkYtRnX9OBMBxJHJjkKCNpzP16qGVv7vx2Wcm40VuZeUosBF GUtWWiO9AwHgPmRxw0a4mw9TJkMnmZu5wq2Y6DzcrRkc07fSVCVugzxF4T/LLSsX7H6h +hahnsSUmG2bWQBh8ut6uRh8HAktT/wuIZapWsMtuWVnnRpwW7MzyPz4o7CZDE+bfJhe Db6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=v7F/xEy+yiOuK0I/tTnDMOg8QD+MS/nIrUIMdpEr5ws=; b=c2LZDG8Jt4qMaRsRYJygWGaeabVrlME9NUF+DhATfR5TXyLSgldo/n3gRG8qUBu8HR ZP6qlwIY8S+VeLVEIGH3SK9MrMNkjWlZo25oHfL703Qhj7gc/SUIeMAu0a5Y/cfoZ/Et Gk6OkupDTUqqkbBzMhE0bW8NLIoj6+FzVZfatbNq5KokYZUxPHvGMHL0QA5wmLSJ46KW RDhC6xBma9omrrgSE548xJTHhs9CZBBbX4D57qSIRdHBmfx1piTwN/vx/5+5E2SqOCnn gKrUJwlurOWye2C3Th8a3mAQDMn6Ua0rpNVUOZ+G89iLd6kYFZvJwZNFC4gigFRPlBaZ rHTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=VIF2TB3g; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt17-20020a1709072d9100b00730ac298aa9si9988424ejc.783.2022.08.21.21.56.32; Sun, 21 Aug 2022 21:56:58 -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=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=VIF2TB3g; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232656AbiHVEZ5 (ORCPT + 99 others); Mon, 22 Aug 2022 00:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbiHVEZy (ORCPT ); Mon, 22 Aug 2022 00:25:54 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEEA619019 for ; Sun, 21 Aug 2022 21:25:52 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id bq23so4559813lfb.7 for ; Sun, 21 Aug 2022 21:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=v7F/xEy+yiOuK0I/tTnDMOg8QD+MS/nIrUIMdpEr5ws=; b=VIF2TB3gN0v1LgnAX4rTBRiH3pJrJsIT3DVwYn6lMnaabtml4kigUksvHq2LAQoEYG g5hK0XTDG4qOvF7SGOKsgMTxrQgv+yN0II8raa0HPXyXXQEmjqnec5dqXv8iuBunHfes oeN1pt2asK+1hXJCkgX83bwkOEndCF9KqBZrx4LG47S2FldZc0IREOoFHUZYpJ9lNaW/ 2oM13LvMJvBUC4cjhpsiK8BFXluMHCmBzEKaGUMC200llEjVB5koGlOvPD9hU8bElMU+ K8O4wi5mp/PcvxvVX/9aCfx+wgZ8k+W+Xp3Lv3fetq1XoNuAXrf5SyLPH7g+G/Fi6eXK DrsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=v7F/xEy+yiOuK0I/tTnDMOg8QD+MS/nIrUIMdpEr5ws=; b=BX2UqDeDPr85mYk9w/dYmdI2AZR6CHnnJedEBR04YqZ1dcnbBfmP2KqFQ5sHzVvxme URpLkuFEwdDJOGr0TBvTbZRemZM4svG5OizDNzAvbkw8mY4GtPFMBjTrEvRmaDTP3KSV QEqaXoNOINeFOXz74ZMIaSBCAh2MpjLMs2d1GQymQoWFLWUwHt2wvboVImZi7xUvlVcK YtPKOvneW7EXF1lcVgNfTjiLy8qZt6cek6jDDCaF9u1oZX4SyYaZ85Zvf6j22m8ma0qS PZI+NWKmE0zH2jTDU9BN+bGoma7oAqKaFWh+05Vm5OPpqw1wnzYFrJ/zwaLeSMwOBWZI JUfA== X-Gm-Message-State: ACgBeo1isBt0NSeqOexUTfHEzK9w4fMjcabtGbPATwlKeYsrkyo6l1U0 Q/NyYcMXb1E7E7Oyuq5tkXD/pU+A1Avb92/ln5+Sgg== X-Received: by 2002:a05:6512:3c87:b0:492:d161:c014 with SMTP id h7-20020a0565123c8700b00492d161c014mr3818137lfv.490.1661142351182; Sun, 21 Aug 2022 21:25:51 -0700 (PDT) MIME-Version: 1.0 References: <20220819145018.35732-1-manivannan.sadhasivam@linaro.org> <20220819145018.35732-4-manivannan.sadhasivam@linaro.org> In-Reply-To: <20220819145018.35732-4-manivannan.sadhasivam@linaro.org> From: Shunsuke Mie Date: Mon, 22 Aug 2022 13:25:34 +0900 Message-ID: Subject: Re: [PATCH 3/5] tools: PCI: Fix parsing the return value of IOCTLs To: Manivannan Sadhasivam Cc: Kishon Vijay Abraham I , Greg Kroah-Hartman , Lorenzo Pieralisi , linux-pci@vger.kernel.org, Linux Kernel Mailing List , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 2022=E5=B9=B48=E6=9C=8819=E6=97=A5(=E9=87=91) 23:50 Manivannan Sadhasivam <= manivannan.sadhasivam@linaro.org>: > > "pci_endpoint_test" driver now returns 0 for success and negative error > code for failure. So adapt to the change by reporting FAILURE if the > return value is < 0, and SUCCESS otherwise. > > Signed-off-by: Manivannan Sadhasivam > --- > tools/pci/pcitest.c | 41 +++++++++++++++++++++-------------------- > 1 file changed, 21 insertions(+), 20 deletions(-) > > diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c > index 441b54234635..a4e5b17cc3b5 100644 > --- a/tools/pci/pcitest.c > +++ b/tools/pci/pcitest.c > @@ -18,7 +18,6 @@ > > #define BILLION 1E9 > > -static char *result[] =3D { "NOT OKAY", "OKAY" }; > static char *irq[] =3D { "LEGACY", "MSI", "MSI-X" }; > > struct pci_test { > @@ -54,9 +53,9 @@ static int run_test(struct pci_test *test) > ret =3D ioctl(fd, PCITEST_BAR, test->barnum); > fprintf(stdout, "BAR%d:\t\t", test->barnum); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->set_irqtype) { > @@ -65,16 +64,18 @@ static int run_test(struct pci_test *test) > if (ret < 0) > fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->get_irqtype) { > ret =3D ioctl(fd, PCITEST_GET_IRQTYPE); > fprintf(stdout, "GET IRQ TYPE:\t\t"); > - if (ret < 0) > + if (ret < 0) { > fprintf(stdout, "FAILED\n"); > - else > + } else { > fprintf(stdout, "%s\n", irq[ret]); > + ret =3D 0; > + } > } > > if (test->clear_irq) { > @@ -83,34 +84,34 @@ static int run_test(struct pci_test *test) > if (ret < 0) > fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->legacyirq) { > ret =3D ioctl(fd, PCITEST_LEGACY_IRQ, 0); > fprintf(stdout, "LEGACY IRQ:\t"); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->msinum > 0 && test->msinum <=3D 32) { > ret =3D ioctl(fd, PCITEST_MSI, test->msinum); > fprintf(stdout, "MSI%d:\t\t", test->msinum); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->msixnum > 0 && test->msixnum <=3D 2048) { > ret =3D ioctl(fd, PCITEST_MSIX, test->msixnum); > fprintf(stdout, "MSI-X%d:\t\t", test->msixnum); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->write) { > @@ -120,9 +121,9 @@ static int run_test(struct pci_test *test) > ret =3D ioctl(fd, PCITEST_WRITE, ¶m); > fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->read) { > @@ -132,9 +133,9 @@ static int run_test(struct pci_test *test) > ret =3D ioctl(fd, PCITEST_READ, ¶m); > fprintf(stdout, "READ (%7ld bytes):\t\t", test->size); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > if (test->copy) { > @@ -144,14 +145,14 @@ static int run_test(struct pci_test *test) > ret =3D ioctl(fd, PCITEST_COPY, ¶m); > fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size); > if (ret < 0) > - fprintf(stdout, "TEST FAILED\n"); > + fprintf(stdout, "FAILED\n"); > else > - fprintf(stdout, "%s\n", result[ret]); > + fprintf(stdout, "SUCCESS\n"); > } > > fflush(stdout); > close(fd); > - return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded *= / > + return ret; > } > > int main(int argc, char **argv) > -- > 2.25.1 > Don't you use the errno of ioctl? Thanks, Shunsuke