Skip to contentSkip to conversation

urcu: remove the wrong comma

PATCH New Lai Jiangshan 3 participants 13 messages Dec 7, 2012 – Feb 22, 2013 10 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/3 urcu: remove the wrong comma

---
 tests/test_urcu_wfcq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tests/test_urcu_wfcq.c +1 -1
index 939bf7a..17814a7 100644
@@ -544,7 +544,7 @@ int main(int argc, char **argv)
 		       tot_enqueues, tot_dequeues);
 	printf_verbose("total number of successful enqueues : %llu, "
 		       "enqueues to empty dest : %llu, "
-		       "successful dequeues %llu, ",
+		       "successful dequeues %llu, "
 		       "splice : %llu\n",
 		       tot_successful_enqueues,
 		       tot_empty_dest_enqueues,
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 3/3 urcu: declare test_urcu_multiflavor functions

In reply to a message not in the archive
---
 tests/test_urcu_multiflavor-bp.c     |    1 +
 tests/test_urcu_multiflavor-mb.c     |    1 +
 tests/test_urcu_multiflavor-memb.c   |    1 +
 tests/test_urcu_multiflavor-qsbr.c   |    1 +
 tests/test_urcu_multiflavor-signal.c |    1 +
 tests/test_urcu_multiflavor.c        |    1 +
 tests/test_urcu_multiflavor.h        |   29 +++++++++++++++++++++++++++++
 7 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 tests/test_urcu_multiflavor.h
tests/test_urcu_multiflavor-bp.c +1 -0
index c9f00a3..199818b 100644
@@ -26,6 +26,7 @@
 
 #define RCU_SIGNAL
 #include <urcu-bp.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_bp(void)
 {
tests/test_urcu_multiflavor-mb.c +1 -0
index 5b5d7e4..e4ba6a4 100644
@@ -26,6 +26,7 @@
 
 #define RCU_MB
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_mb(void)
 {
tests/test_urcu_multiflavor-memb.c +1 -0
index c3a0128..583f2e1 100644
@@ -25,6 +25,7 @@
 #endif
 
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_memb(void)
 {
tests/test_urcu_multiflavor-qsbr.c +1 -0
index f4fb145..64f32f4 100644
@@ -25,6 +25,7 @@
 #endif
 
 #include <urcu-qsbr.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_qsbr(void)
 {
tests/test_urcu_multiflavor-signal.c +1 -0
index 5519d36..816c615 100644
@@ -26,6 +26,7 @@
 
 #define RCU_SIGNAL
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_signal(void)
 {
tests/test_urcu_multiflavor.c +1 -0
index 825333e..cd573ca 100644
@@ -21,6 +21,7 @@
  */
 
 #include <stdlib.h>
+#include "test_urcu_multiflavor.h"
 
 int main(int argc, char **argv)
 {
tests/test_urcu_multiflavor.h new file +29 -0
new file mode 100644
index 0000000..419ad5d
@@ -0,0 +1,29 @@
+/*
+ * test_urcu_multiflavor.h
+ *
+ * Userspace RCU library - test multiple RCU flavors into one program
+ *
+ * Copyright February 2012 - Mathieu Desnoyers <[email protected]>
+ * Copyright February 2012 - Lai Jiangshan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+extern int test_mf_memb(void);
+extern int test_mf_mb(void);
+extern int test_mf_signal(void);
+extern int test_mf_qsbr(void);
+extern int test_mf_bp(void);
+
Signature · 1 line
1.7.4.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 1 line · * Lai Jiangshan ([email protected]) wrote:

Merged, thanks!

Mathieu

Quoted 25 lines
---
 tests/test_urcu_wfcq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tests/test_urcu_wfcq.c +1 -1
index 939bf7a..17814a7 100644
@@ -544,7 +544,7 @@ int main(int argc, char **argv)
 		       tot_enqueues, tot_dequeues);
 	printf_verbose("total number of successful enqueues : %llu, "
 		       "enqueues to empty dest : %llu, "
-		       "successful dequeues %llu, ",
+		       "successful dequeues %llu, "
 		       "splice : %llu\n",
 		       tot_successful_enqueues,
 		       tot_empty_dest_enqueues,
Signature · 7 lines
1.7.4.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 3/3] urcu: declare test_urcu_multiflavor functions

Quoted 1 line · * Lai Jiangshan ([email protected]) wrote:

Merged, with Makefile.am edit:

tests/Makefile.am +1 -1
index b029377..f8b4c67 100644
@@ -21,7 +21,7 @@ noinst_PROGRAMS = test_urcu test_urcu_dynamic_link test_urcu_timing \
 	test_urcu_lfq_dynlink test_urcu_lfs_dynlink test_urcu_hash \
 	test_urcu_lfs_rcu_dynlink \
 	test_urcu_multiflavor test_urcu_multiflavor_dynlink
-noinst_HEADERS = rcutorture.h
+noinst_HEADERS = rcutorture.h test_urcu_multiflavor.h
 
 if COMPAT_ARCH
 COMPAT=$(top_srcdir)/compat_arch_@[email protected]

Thanks!

Mathieu

Quoted 126 lines
---
 tests/test_urcu_multiflavor-bp.c     |    1 +
 tests/test_urcu_multiflavor-mb.c     |    1 +
 tests/test_urcu_multiflavor-memb.c   |    1 +
 tests/test_urcu_multiflavor-qsbr.c   |    1 +
 tests/test_urcu_multiflavor-signal.c |    1 +
 tests/test_urcu_multiflavor.c        |    1 +
 tests/test_urcu_multiflavor.h        |   29 +++++++++++++++++++++++++++++
 7 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 tests/test_urcu_multiflavor.h
tests/test_urcu_multiflavor-bp.c +1 -0
index c9f00a3..199818b 100644
@@ -26,6 +26,7 @@
 
 #define RCU_SIGNAL
 #include <urcu-bp.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_bp(void)
 {
tests/test_urcu_multiflavor-mb.c +1 -0
index 5b5d7e4..e4ba6a4 100644
@@ -26,6 +26,7 @@
 
 #define RCU_MB
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_mb(void)
 {
tests/test_urcu_multiflavor-memb.c +1 -0
index c3a0128..583f2e1 100644
@@ -25,6 +25,7 @@
 #endif
 
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_memb(void)
 {
tests/test_urcu_multiflavor-qsbr.c +1 -0
index f4fb145..64f32f4 100644
@@ -25,6 +25,7 @@
 #endif
 
 #include <urcu-qsbr.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_qsbr(void)
 {
tests/test_urcu_multiflavor-signal.c +1 -0
index 5519d36..816c615 100644
@@ -26,6 +26,7 @@
 
 #define RCU_SIGNAL
 #include <urcu.h>
+#include "test_urcu_multiflavor.h"
 
 int test_mf_signal(void)
 {
tests/test_urcu_multiflavor.c +1 -0
index 825333e..cd573ca 100644
@@ -21,6 +21,7 @@
  */
 
 #include <stdlib.h>
+#include "test_urcu_multiflavor.h"
 
 int main(int argc, char **argv)
 {
tests/test_urcu_multiflavor.h new file +29 -0
new file mode 100644
index 0000000..419ad5d
@@ -0,0 +1,29 @@
+/*
+ * test_urcu_multiflavor.h
+ *
+ * Userspace RCU library - test multiple RCU flavors into one program
+ *
+ * Copyright February 2012 - Mathieu Desnoyers <[email protected]>
+ * Copyright February 2012 - Lai Jiangshan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+extern int test_mf_memb(void);
+extern int test_mf_mb(void);
+extern int test_mf_signal(void);
+extern int test_mf_qsbr(void);
+extern int test_mf_bp(void);
+
Signature · 7 lines
1.7.4.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
#7 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

In reply to a message not in the archive
Quoted 2 lines · * Lai Jiangshan ([email protected]) wrote:

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Thoughts ?

Thanks,

Mathieu

Quoted 35 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -1
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ * 	warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)		\
 	({				\
 		__typeof__(x) _v = _CMM_STORE_SHARED(x, v);	\
+		__typeof__(x) _w;	\
 		cmm_smp_wmc();		\
-		_v;			\
+		_w = _v;		\
 	})
 
 #endif /* _URCU_SYSTEM_H */
Signature · 7 lines
1.7.4.4


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): 20121207165848.GB12338@Krystal

#9 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 4 lines · Mathieu Desnoyers
Quoted 2 lines · * Lai Jiangshan ([email protected] <javascript:;>) wrote:

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Quoted 8 lines

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 50 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
Signed-off-by Lai Jiangshan <[email protected] <javascript:;>>
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

Quoted 5 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CACvQF53+x_PDd+aOtM0k2wN0BJZXRMkB3pjXxfvsV=HkdknM=Q@mail.gmail.com

#11 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Quoted 13 lines · Lai Jiangshan
Quoted 10 lines · Mathieu Desnoyers
Quoted 2 lines · * Lai Jiangshan ([email protected]) wrote:

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

Quoted 63 lines
Quoted 3 lines

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 55 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

urcu/system.h +2 -1
index 2a45f22..fe0ee30 100644
@@ -50,8 +50,9 @@
 #define CMM_STORE_SHARED(x, v)		\
 	({				\
 		__typeof__(x) _v = _CMM_STORE_SHARED(x, v);	\
+		__typeof__(x) _w;	\
 		cmm_smp_wmc();		\
-		_v;			\
+		({_w = _v;});		\
 	})
 
 #endif /* _URCU_SYSTEM_H */
urcu/system.h +1 -1
index 2a45f22..f2695e2 100644
@@ -51,7 +51,7 @@
 	({				\
 		__typeof__(x) _v = _CMM_STORE_SHARED(x, v);	\
 		cmm_smp_wmc();		\
-		_v;			\
+		1 ? _v : ({*(volatile __typeof__(x) *)NULL = _v;});	\
 	})
 
 #endif /* _URCU_SYSTEM_H */

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CACvQF514yxBjppYFKJEqX=n31LdU6dTqBg9-7kn5AoTy0i7=Lw@mail.gmail.com

#13 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression). We might want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.
2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

Thoughts ?

Thanks,

Mathieu

Quoted 78 lines · Lai Jiangshan
Quoted 76 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 55 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): 20121208150023.GA16943@Krystal

#15 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 6 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected] <javascript:;>) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Quoted 8 lines

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression). We might want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.

I don't like it either, it is not friendly.

Quoted 2 lines

2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

It will break the original goal:
CMM_STORE_SHARED() can be used as chained assignment:
tmp = CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(y, CMM_STORE_SHARED(x, v)) func(CMM_STORE_SHARED(x,v))

Quoted 90 lines

Thoughts ?

Thanks,

Mathieu

Quoted 2 lines

On Sat, Dec 8, 2012 at 1:27 AM, Lai Jiangshan <[email protected]<javascript:;>>

Quoted 35 lines · wrote:
Quoted 35 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected] <javascript:;>) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 14 lines

Thoughts ?

Thanks,

Mathieu

Quoted 6 lines
Signed-off-by Lai Jiangshan <[email protected] <javascript:;>>
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

urcu/system.h line 47

Quoted 7 lines
urcu/system.h +0 -0
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs

the

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 18 lines
urcu/system.h +4 -2
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Quoted 6 lines

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

#16 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

In reply to a message not in the archive
Quoted 9 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression).

The one in yy.diff:

1 ? _v : statement_which_has_side_affect;

The compiler should not warn for it. "?:" can be used for control flow, the complier should only warn if both branches are warning.

We might

Quoted 96 lines

want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.
2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

Thoughts ?

Thanks,

Mathieu

Quoted 78 lines · Lai Jiangshan
Quoted 76 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 55 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 11 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 9 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression).

Quoted 6 lines

The one in yy.diff:

1 ? _v : statement_which_has_side_affect;

The compiler should not warn for it. "?:" can be used for control flow, the complier should only warn if both branches are warning.

In the case of yy.diff, whether the warning will appear or not would depend on the phase at which the compiler generates the warning, no ? For instance, it it chooses to check for unused return values after eliminating dead code (considering branches that cannot be taken), then we would be in the same situation as we are today, even if we have a statement with side effect.

I am more and more enclined to try asking their opinion to the clang community about this.

Thanks,

Mathieu

Quoted 100 lines

We might

Quoted 96 lines

want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.
2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

Thoughts ?

Thanks,

Mathieu

Quoted 78 lines · Lai Jiangshan
Quoted 76 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 55 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): 20121210140930.GA32034@Krystal

#20 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 26 lines · * Mathieu Desnoyers ([email protected]) wrote:
Quoted 11 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 9 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression).

Quoted 6 lines

The one in yy.diff:

1 ? _v : statement_which_has_side_affect;

The compiler should not warn for it. "?:" can be used for control flow, the complier should only warn if both branches are warning.

In the case of yy.diff, whether the warning will appear or not would depend on the phase at which the compiler generates the warning, no ? For instance, it it chooses to check for unused return values after eliminating dead code (considering branches that cannot be taken), then we would be in the same situation as we are today, even if we have a statement with side effect.

Quoted 2 lines

I am more and more enclined to try asking their opinion to the clang community about this.

I finally found a way to silence warnings both in gcc and clang:

urcu/system.h +5 -5
index 2a45f22..6f31459 100644
@@ -47,11 +47,11 @@
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
  */
-#define CMM_STORE_SHARED(x, v)		\
-	({				\
-		__typeof__(x) _v = _CMM_STORE_SHARED(x, v);	\
-		cmm_smp_wmc();		\
-		_v;			\
+#define CMM_STORE_SHARED(x, v)						\
+	({								\
+		__typeof__(x) _v = _CMM_STORE_SHARED(x, v);		\
+		cmm_smp_wmc();						\
+		_v = _v;	/* Work around clang "unused result" */	\
 	})
 
 #endif /* _URCU_SYSTEM_H */

Thanks,

Mathieu

Quoted 116 lines

Thanks,

Mathieu

Quoted 100 lines

We might

Quoted 96 lines

want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.
2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

Thoughts ?

Thanks,

Mathieu

Quoted 78 lines · Lai Jiangshan
Quoted 76 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 55 lines

Thoughts ?

Thanks,

Mathieu

Quoted 31 lines
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
urcu/system.h +4 -2
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs the
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 9 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): CACvQF53-yf90t5o2-s6vjVvUotvVogrBgu4LM7FrsbWgEa1+ng@mail.gmail.com

#22 lore raw

Re: [PATCH 1/3] urcu: avoid "expression result unused" from clang

Quoted 26 lines · * Lai Jiangshan ([email protected]) wrote:
Quoted 6 lines · Mathieu Desnoyers
Quoted 4 lines · * Lai Jiangshan ([email protected] <javascript:;>) wrote:

How about the one in yy.diff?

xx.diff fixes the one what I had sent in 1/3 patch, but it may still cause warning in future if the complier become more strict.

Quoted 8 lines

Hrm. In any cases, I think that even with the 2 patches you propose, the warning "unused expression return" would still be valid (because we end up not using the result of the outer statement-expression). We might want to consider simpler approaches:

1 - Add the missing (void) casts before each CMM_STORE_SHARED() in the
code. I don't like this because it makes the CMM_STORE_SHARED common case more cumbersome to use.

I don't like it either, it is not friendly.

Quoted 2 lines

2 - Change the CMM_STORE_SHARED() API so it does not return anything.
I think most use-cases don't involve using its return value anyway.

Quoted 5 lines

It will break the original goal:
CMM_STORE_SHARED() can be used as chained assignment:
tmp = CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(y, CMM_STORE_SHARED(x, v)) func(CMM_STORE_SHARED(x,v))

Indeed, I'd hate to have to change this semantic.

Thanks,

Mathieu

Quoted 99 lines
Quoted 99 lines

Thoughts ?

Thanks,

Mathieu

Quoted 2 lines

On Sat, Dec 8, 2012 at 1:27 AM, Lai Jiangshan <[email protected]<javascript:;>>

Quoted 35 lines · wrote:
Quoted 35 lines · Mathieu Desnoyers
Quoted 13 lines · * Lai Jiangshan ([email protected] <javascript:;>) wrote:
Quoted 2 lines

The last expression result is unused and clang will complain. The trick in the patch supresses the complaint

Hrm, but with this patch, gcc complains:

rculfhash.c:1921:3: warning: variable '_w' set but not used [-Wunused-but-set-variable]

using

gcc version 4.7.2 (Debian 4.7.2-4)

Ouch, my gcc is too old

Quoted 14 lines

Thoughts ?

Thanks,

Mathieu

Quoted 6 lines
Signed-off-by Lai Jiangshan <[email protected] <javascript:;>>
---
 urcu/system.h        |    5 ++++-
 2 files changed, 4 insertions(+), 1 deletions(-)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

urcu/system.h line 47

Quoted 7 lines
urcu/system.h +0 -0
index 2a45f22..6b7b0af 100644
@@ -46,12 +46,15 @@
 /*
  * Store v into x, where x is located in shared memory. Performs

the

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 18 lines
urcu/system.h +4 -2
  * required cache flush after writing. Returns v.
+ * "_w" here avoids the warning from clang:
+ *   warning: expression result unused [-Wunused-value]
  */
 #define CMM_STORE_SHARED(x, v)               \
      ({                              \
              __typeof__(x) _v = _CMM_STORE_SHARED(x, v);     \
+             __typeof__(x) _w;       \
              cmm_smp_wmc();          \
-             _v;                     \
+             _w = _v;                \
      })
 
 #endif /* _URCU_SYSTEM_H */
--

1.7.4.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected] <javascript:;>
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com