public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Joerg Vehlow <lkml@jv-coder.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Joerg Vehlow <joerg.vehlow@aox-tech.de>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 05/12] posix/conformance/interfaces: Fix all unused variable warnings
Date: Mon, 22 Nov 2021 07:41:39 +0100	[thread overview]
Message-ID: <5979aa76-ca07-2bf2-58cc-33bafe4a280b@jv-coder.de> (raw)
In-Reply-To: <YZfBcfs8VZApzMU9@yuki>

Hi Cyril,

On 11/19/2021 4:23 PM, Cyril Hrubis wrote:
> Hi!
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> index e1ae59e3b..cd1aa0318 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c
>> @@ -48,7 +48,6 @@ int main(void)
>>   	int i;
>>   	struct aiocb aiocbs[NUM_AIOCBS];
>>   	int last_req;
>> -	int err;
>>   	int ret;
>>   
>>   	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
>> @@ -85,7 +84,7 @@ int main(void)
>>   	}
>>   
>>   	for (i = 0; i < last_req - 1; i++) {
>> -		err = aio_error(&aiocbs[i]);
>> +		aio_error(&aiocbs[i]);
>>   		ret = aio_return(&aiocbs[i]);
>>   
>>   	}
> Looking at the test the whole loop here is pointless, can we remove it
> completely?
I thought the same, but I have never used aio, so I have no clue, if 
there are any side effects.
So I went for a minimal  change approach.
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> index aaf1403f9..9a0b148d9 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
>> @@ -51,7 +51,7 @@
>>   
>>   static void read_catalog(nl_catd cat, char *who)
>>   {
>> -	char *msg = NULL;
>> +	char *msg PTS_ATTRIBUTE_UNUSED = NULL;
>>   	int i, j;
> I guess that in this case the test is wrong as well. It does not seem
> that catgets() fails when it returns the pointer to the "not found"
> string and does not even touch errno.
Yes looks like you are right. Looks like this test can never fail.

I would fix it like this in a next revision:

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
index 46350b7f0..5c03b04ed 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c
@@ -49,33 +49,22 @@
  #define MESSCAT_IN  "messcat.txt"
  #define MESSCAT_OUT "messcat.cat"

-static void read_catalog(nl_catd cat, char *who)
+static int read_catalog(nl_catd cat)
  {
+    static const char *notfound = "not found";
      char *msg PTS_ATTRIBUTE_UNUSED = NULL;
      int i, j;

-#if VERBOSE > 0
-    output("Reading the message catalog from %s...\n", who);
-#endif
-
-    errno = 0;
-
      for (i = 1; i <= 2; i++) {
          for (j = 1; j <= 2; j++) {

-            msg = catgets(cat, i, j, "not found");
-
-            if (errno != 0)
-                UNRESOLVED(errno, "catgets returned an error");
-#if VERBOSE > 1
-            output("set %i msg %i: %s\n", i, j, msg);
-#endif
+            msg = catgets(cat, i, j, notfound);
+            if (msg == notfound) {
+                return 1;
+            }
          }
      }
-
-#if VERBOSE > 0
-    output("Message catalog read successfully in %s\n", who);
-#endif
+    return 0;
  }

  static char *messcat_in =
@@ -132,7 +121,10 @@ int main(void)
      if (messcat == (nl_catd) - 1)
          UNRESOLVED(errno, "Could not open ./" MESSCAT_OUT);

-    read_catalog(messcat, "parent");
+    if (read_catalog(messcat)) {
+        printf("UNRESOLVED: Unable to read message catalog in parent");
+        return PTS_UNRESOLVED;
+    }

      child = fork();

@@ -140,8 +132,11 @@ int main(void)
          UNRESOLVED(errno, "Failed to fork");

      if (child == 0) {
-        read_catalog(messcat, "child");
-        exit(PTS_PASS);
+        if (read_catalog(messcat)) {
+            printf("FAILED: Unable to read message catalog in child");
+            return PTS_FAIL;
+        }
+        return PTS_PASS;
      }

      ctl = waitpid(child, &status, 0);


Joerg

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-11-22  6:41 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  7:45 [LTP] [Patch 00/12] Fix or suppress compiler warnings in posix/conformance/interfaces Joerg Vehlow
2021-11-19  7:45 ` [LTP] [PATCH 01/12] posix/pthread_create/15-1: Supress warning Joerg Vehlow
2021-11-19 14:34   ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting Joerg Vehlow
2021-11-19 14:44   ` Cyril Hrubis
2021-11-22  6:45     ` Joerg Vehlow
2021-11-22  9:10       ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 03/12] posix/pthread_create/*: Remove unused variable Joerg Vehlow
2021-11-19 14:51   ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 04/12] posix/conformance/interfaces: Fix unsued-variable for testfrmw Joerg Vehlow
2021-11-19 15:07   ` Cyril Hrubis
2021-11-22  6:48     ` Joerg Vehlow
2021-11-19  7:45 ` [LTP] [PATCH 05/12] posix/conformance/interfaces: Fix all unused variable warnings Joerg Vehlow
2021-11-19 15:23   ` Cyril Hrubis
2021-11-22  6:41     ` Joerg Vehlow [this message]
2021-11-22  9:43       ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 06/12] posix/conformance/interfaces: Fix all unused function warnings Joerg Vehlow
2021-11-19 15:27   ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 07/12] posix/pthread_key_create/2-1: Remove invalid part of test Joerg Vehlow
2021-11-19 15:32   ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 08/12] posix/asctime: Fix potentioal buffer overflow Joerg Vehlow
2021-11-19 15:33   ` Cyril Hrubis
2021-11-19  7:45 ` [LTP] [PATCH 09/12] posix/conformance/interfaces/pthread_*_destroy: Suppress nonnull warning Joerg Vehlow
2021-11-19 15:35   ` Cyril Hrubis
2021-11-19  7:46 ` [LTP] [PATCH 10/12] posix/conformance/interfaces: Fix all sign-compare warnings Joerg Vehlow
2021-11-19 15:37   ` Cyril Hrubis
2021-11-19  7:46 ` [LTP] [PATCH 11/12] posix/conformance/interface/mmap/5-1: Remove invalid static Joerg Vehlow
2021-11-19 15:38   ` Cyril Hrubis
2021-11-19  7:46 ` [LTP] [PATCH 12/12] posix/interface/conformance: Fix/supress all unused-result warnings Joerg Vehlow
2021-11-19 15:43   ` Cyril Hrubis
2021-11-22  6:42     ` Joerg Vehlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5979aa76-ca07-2bf2-58cc-33bafe4a280b@jv-coder.de \
    --to=lkml@jv-coder.de \
    --cc=chrubis@suse.cz \
    --cc=joerg.vehlow@aox-tech.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox