From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424438AbdKRSMr (ORCPT ); Sat, 18 Nov 2017 13:12:47 -0500 Received: from us-smtp-delivery-194.mimecast.com ([63.128.21.194]:46510 "EHLO us-smtp-delivery-194.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967431AbdKRSMh (ORCPT ); Sat, 18 Nov 2017 13:12:37 -0500 From: Trond Myklebust To: "boris.ostrovsky@oracle.com" , "Anna.Schumaker@Netapp.com" CC: "linux-kernel@vger.kernel.org" , "linux-nfs@vger.kernel.org" Subject: Re: Commit fcd8843c40 breaks old compilers Thread-Topic: Commit fcd8843c40 breaks old compilers Thread-Index: AQHTYJGKUkJnaosyNE65IzhKw2g0qqMaZ0yAgAAHzQCAAAFcAA== Date: Sat, 18 Nov 2017 18:12:32 +0000 Message-ID: <1511028750.14386.1.camel@primarydata.com> References: <09a3d9ca-d191-5899-613d-8d0dbe0b68ea@oracle.com> <1511026783.10238.2.camel@primarydata.com> <49fec52f-229a-4657-a80d-d1a40a9d38e4@oracle.com> In-Reply-To: <49fec52f-229a-4657-a80d-d1a40a9d38e4@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [68.49.162.121] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR11MB0073;20:xApLMvnN5QKYCejj2ErZbcA6BR9iTED4Q+6QfhSXJoTs8Q+hovDq/hwKuFQMUZtxTD8i7Uluq9i3ruA+K8JwoJ6VoKARdSFCct9UXPkTFvbD4yysrkuQoice932mGhUxUP/hQbuwEyLPs0ZXKDziOPEVDwVJjyg2hRHtFgWpqnA= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: c1042477-481f-4818-f64a-08d52eaff005 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4603075)(4627115)(201702281549075)(2017052603258);SRVR:DM5PR11MB0073; x-ms-traffictypediagnostic: DM5PR11MB0073: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(131327999870524); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3231022)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6041248)(20161123555025)(2016111802025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123562025)(20161123564025)(6043046)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR11MB0073;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR11MB0073; x-forefront-prvs: 04953B1F22 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(39830400002)(346002)(377424004)(24454002)(199003)(189002)(478600001)(6246003)(316002)(103116003)(6512007)(53936002)(3660700001)(4326008)(2900100001)(66066001)(101416001)(8676002)(33646002)(81156014)(81166006)(54356999)(25786009)(36756003)(7736002)(3846002)(50986999)(102836003)(6116002)(2906002)(106356001)(305945005)(105586002)(76176999)(68736007)(8936002)(575784001)(86362001)(3280700002)(14454004)(4001150100001)(99286004)(2501003)(2950100002)(229853002)(189998001)(6506006)(6436002)(110136005)(53546010)(97736004)(6486002)(77096006)(54906003)(5660300001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR11MB0073;H:DM5PR11MB0075.namprd11.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: primarydata.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1042477-481f-4818-f64a-08d52eaff005 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2017 18:12:32.2932 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 03193ed6-8726-4bb3-a832-18ab0d28adb7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB0073 X-MC-Unique: TO676WxkMFCchFpzKhRZPA-1 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vAIICqgn000802 On Sat, 2017-11-18 at 13:07 -0500, Boris Ostrovsky wrote: > > On 11/18/2017 12:39 PM, Trond Myklebust wrote: > > On Sat, 2017-11-18 at 12:19 -0500, Boris Ostrovsky wrote: > > > Commit fcd8843c406b46433857ae45e5e9d84b01a7d20b breaks on older > > > compilers which cannot process initializers for anonymous > > > structures: > > > > > > +const nfs4_stateid invalid_stateid = { > > > + { > > > + .seqid = cpu_to_be32(0xffffffffU), > > > + .other = { 0 }, > > > + }, > > > + .type = NFS4_INVALID_STATEID_TYPE, > > > +}; > > > > > > > > > /home/build/linux-linus/fs/nfs/nfs4state.c:74: error: unknown > > > field > > > ‘seqid’ specified in initializer > > > /home/build/linux-linus/fs/nfs/nfs4state.c:74: warning: missing > > > braces > > > around initializer > > > /home/build/linux-linus/fs/nfs/nfs4state.c:74: warning: (near > > > initialization for ‘invalid_stateid..data’) > > > /home/build/linux-linus/fs/nfs/nfs4state.c:74: warning: overflow > > > in > > > implicit constant conversion > > > /home/build/linux-linus/fs/nfs/nfs4state.c:75: error: unknown > > > field > > > ‘other’ specified in initializer > > > /home/build/linux-linus/fs/nfs/nfs4state.c:75: error: extra brace > > > group > > > at end of initializer > > > /home/build/linux-linus/fs/nfs/nfs4state.c:75: error: (near > > > initialization for ‘invalid_stateid.’) > > > /home/build/linux-linus/fs/nfs/nfs4state.c:75: warning: excess > > > elements > > > in union initializer > > > /home/build/linux-linus/fs/nfs/nfs4state.c:75: warning: (near > > > initialization for ‘invalid_stateid.’) > > > make[4]: *** [fs/nfs/nfs4state.o] Error 1 > > > make[3]: *** [fs/nfs] Error 2 > > > > > > > > > FC-64 gcc --version > > > gcc (GCC) 4.4.4 20100503 (Red Hat 4.4.4-2) > > > > > > > > > A similar bug was fixed by > > > e0714ec4f9efe7b86828b0dcc077fd8f5d8e5e91 > > > but > > > I don't think the same approach can work here. > > > > > > I don't have any setups with gcc 4.4.4. What is it expecting here? > > Is > > it expecting an extra set of braces due to the anonymous "struct"? > > > > No, that won't work (at least I couldn't get it to work) because the > solution from e0714ec4f9e assumes that the anonymous struct is the > first > one in the enveloping struct. > > It worked only if I (this is a small C program with equivalent > structs): > > struct nfs4_stateid_struct { > union { > //char data[4]; > struct { > unsigned seqid; > char other[6]; > } __attribute__ ((packed)); > char data[4]; > }; > and then > > const nfs4_stateid invalid_stateid = { > { > {.seqid = 0xffffffffU, > .other = { 0 } }, > }, > .type = NFS4_INVALID_STATEID_TYPE, > }; > > If I keep data[4] where it is now I get compiler error > > an.c:35:20: error: field name not in record or union initializer > {.seqid = 0xffffffffU, > ^ > an.c:35:20: note: (near initialization for > 'invalid_stateid..data') > an.c:35:29: warning: overflow in implicit constant conversion [- > Woverflow] > {.seqid = 0xffffffffU, > ^~~~~~~~~~~ > an.c:36:19: error: field name not in record or union initializer > .other = { 0 } }, > ^ > an.c:36:19: note: (near initialization for > 'invalid_stateid..data') > an.c:36:19: warning: braces around scalar initializer > an.c:36:19: note: (near initialization for > 'invalid_stateid..data[1]') > > I don't know if you want to change public header file just to get > around > this problem. Sigh.... OK, how about something like the following then: { .data = { 0xff, 0xff, 0xff, 0xff, 0 }, } -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com