[PATCH -perfbook 3/6] CodeSamples/advsync: Add explicit type cast in xchg()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Building with CLANG, you'll see a couple of warnings while building
under CodeSamples/ as follows:

    cc -g -O3 -Wall -o q -DTEST q.c -lpthread
    q.c:39:12: warning: incompatible pointer types passing 'struct el *'
      to parameter of type 'struct el **'; take the address with &
      [-Wincompatible-pointer-types]
            oldtail = xchg(&q->tail, p);
                      ^~~~~~~~~~~~~~~~~
    ./../api.h:778:49: note: expanded from macro 'xchg'
                                                 ^~~
    1 warning generated.

and:

    cc -g -O3 -Wall -o wfenqueue -DTEST wfenqueue.c -lpthread
    wfenqueue.c:38:9: warning: incompatible pointer types passing
      'struct el *' to parameter of type 'struct el **'; take the
      address with & [-Wincompatible-pointer-types]
            tail = xchg(&qp->tail, ep);
                   ^~~~~~~~~~~~~~~~~~~
    ./../api.h:778:49: note: expanded from macro 'xchg'
                                                 ^~~
    1 warning generated.

This is due to indirection-level mismatch in the argument of xchg().
Add explicit cast and silence those warnings.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 CodeSamples/advsync/q.c         | 2 +-
 CodeSamples/advsync/wfenqueue.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CodeSamples/advsync/q.c b/CodeSamples/advsync/q.c
index 4198b3c8..8997a460 100644
--- a/CodeSamples/advsync/q.c
+++ b/CodeSamples/advsync/q.c
@@ -36,7 +36,7 @@ int q_push(struct el *p, struct queue *q)
 	struct el **oldtail;
 
 	p->next = NULL;
-	oldtail = xchg(&q->tail, p);
+	oldtail = xchg(&q->tail, (struct el **)p);
 	*oldtail = p;
 	return 1;
 }
diff --git a/CodeSamples/advsync/wfenqueue.c b/CodeSamples/advsync/wfenqueue.c
index fed8d87b..9970b075 100644
--- a/CodeSamples/advsync/wfenqueue.c
+++ b/CodeSamples/advsync/wfenqueue.c
@@ -35,7 +35,7 @@ int q_push(struct el *ep, struct queue *qp)
 	struct el **tail;
 
 	ep->next = NULL;
-	tail = xchg(&qp->tail, ep);
+	tail = xchg(&qp->tail, (struct el **)ep);
 	*tail = ep;
 	return 1;
 }
-- 
2.34.1






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux