lib:util: Fix parameter aliasing in tfork test
authorAndreas Schneider <asn@samba.org>
Wed, 9 May 2018 15:52:19 +0000 (17:52 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 17 May 2018 15:30:09 +0000 (17:30 +0200)
../lib/util/tests/tfork.c:483:24: error: passing argument 1 to
    restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
   ret = pthread_create(&threads[i],
                        ^~~~~~~~~~~
../lib/util/tests/tfork.c:486:10:
          (void *)&threads[i]);
          ~~~~~~~~~~~~~~~~~~~

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
lib/util/tests/tfork.c

index 9bcdc2f3d6d14be626f3a68217499f7bd879839a..3c73355b3f092c0256379c3a6136c4afb957dbd9 100644 (file)
@@ -417,8 +417,7 @@ static void *tfork_thread(void *p)
        struct tfork *t = NULL;
        int status;
        pid_t child;
-       pthread_t *ptid = (pthread_t *)p;
-       uint64_t tid;
+       uint64_t tid = (uint64_t)pthread_self();
        uint64_t *result = NULL;
        int up[2];
        ssize_t nread;
@@ -429,8 +428,6 @@ static void *tfork_thread(void *p)
                pthread_exit(NULL);
        }
 
-       tid = (uint64_t)*ptid;
-
        t = tfork_create();
        if (t == NULL) {
                pthread_exit(NULL);
@@ -480,7 +477,7 @@ static bool test_tfork_threads(struct torture_context *tctx)
 #endif
 
        for (i = 0; i < num_threads; i++) {
-               ret = pthread_create(&threads[i], NULL, tfork_thread, &threads[i]);
+               ret = pthread_create(&threads[i], NULL, tfork_thread, NULL);
                torture_assert_goto(tctx, ret == 0, ok, done,
                                    "pthread_create failed\n");
        }