Whamcloud - gitweb
LU-4987 lustre: Remove static declaration in anonymous union 76/10176/2
authorChristopher J. Morrone <morrone2@llnl.gov>
Wed, 30 Apr 2014 21:20:27 +0000 (14:20 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 13 May 2014 14:44:03 +0000 (14:44 +0000)
It is not permitted in C++ to have a static declaration inside
of an anonymous union.  Before "LUSTRE_ANONYMOUS_UNION_NAME"
was added to the code in commit b40f6327bb19b6, the g++ compiler
most likely complained with an error like this:

  error: ‘struct ost_id::<anonymous union>::ostid’ invalid; an
  anonymous union can only have non-static data members [-fpermissive]

The fix from b40f6327bb19b6 conditionally eliminated the anonymous
union when a C++ compiler is being used.  That means that the API
varies depending on your choice of compiler, which is not at all
desirable.

The better fix is to address the static data member that the error
complained about.  This patch changes the code to use an unnamed
struct in place of "struct ostid" inside of the anonymous union.
That name declaration was completely unnecessary anyway, since it
was not used anywhere else.

Change-Id: I59f8341f5f9833d8a144cf2feaa178cb76e643dc
Signed-off-by: Christopher J. Morrone <morrone2@llnl.gov>
Reviewed-on: http://review.whamcloud.com/10176
Reviewed-by: Robert Read <robert.read@intel.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/lustre/lustre_user.h

index 2e97ab5..412b717 100644 (file)
 #error Unsupported operating system.
 #endif
 
-#ifdef __cplusplus
-#define LUSTRE_ANONYMOUS_UNION_NAME u
-#else
-#define LUSTRE_ANONYMOUS_UNION_NAME
-#endif
-
 /* for statfs() */
 #define LL_SUPER_MAGIC 0x0BD00BD0
 
@@ -194,12 +188,12 @@ struct lustre_mdt_attrs {
  */
 struct ost_id {
        union {
-               struct ostid {
+               struct {
                        __u64   oi_id;
                        __u64   oi_seq;
                } oi;
                struct lu_fid oi_fid;
-       } LUSTRE_ANONYMOUS_UNION_NAME;
+       };
 };
 
 #define DOSTID LPX64":"LPU64