From patchwork Mon Mar 25 12:51:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10869091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 316EF15AC for ; Mon, 25 Mar 2019 12:52:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EE7E291A3 for ; Mon, 25 Mar 2019 12:52:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D58A2939E; Mon, 25 Mar 2019 12:52:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B188F291A3 for ; Mon, 25 Mar 2019 12:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731236AbfCYMwK (ORCPT ); Mon, 25 Mar 2019 08:52:10 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:38175 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731088AbfCYMwK (ORCPT ); Mon, 25 Mar 2019 08:52:10 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1N1Oft-1gy2xS483n-012s2n; Mon, 25 Mar 2019 13:51:50 +0100 From: Arnd Bergmann To: Ilya Dryomov , "Yan, Zheng" , Sage Weil Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Alex Elder , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] ceph: fix clang warning for CEPH_DEFINE_OID_ONSTACK Date: Mon, 25 Mar 2019 13:51:43 +0100 Message-Id: <20190325125147.1436083-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:KWvfQc+4evNO9m8S8p3AoDmHUjX122/NcSdbgNhhaPGoBLr2fC3 PZnt8of6Rnv8G4b4Ppnp6L30MFl96pxnIIjlLTJ2uSgHb0boHEol0gWaP7sPtKBPiOEXh+4 dpKmvTIuSVBknRjZBX0B98K+x9NZp3w48l7AC8fJ7DAXwyPZHbpHL5MpkjUjQF5uWcpjvD9 Y05wUJVGLKDdvUUE0qzCg== X-UI-Out-Filterresults: notjunk:1;V03:K0:eua1NsCnv1M=:L+K/YOrApGbhdwyDDeSJ8j uJ3V8KvnJxU95e0ftrqbkXQ1vlG0x/22VfE4/opMABDFsjE4IDm17Nur3yFMN0GPKPY7FNPtj 4Pa/eZM/kKKmFh+Et5pF99pJV+A1Fji8uID9YFt0fDcVFbQh6CAsd7drKdXXX+yGVUR7Xs+Vr y4olNimSb+1AcY1/jAJlHD523K0NJL5VsODDQKAY3OyanwlJvHGoDtscgy1xpsml9WRFBE24s xV6OWO+N7hqfYUqAy8hEphPVyCNGfhuEvm3623taxvoJwAWBxIg9IYoonqVgCrSuCIvU91qj6 4lx5VWYxD5yn/Q10udxap2Y/umFdONUhK9xyMcdbPawb/xhFEyCFBYeW+IXD8WSonX+q5DXRX jgG2PjHsjdB8LwMRNk3ZBRbinqvgKDD2wMW0WaHwZ9C5AL2K6WVZGARyMum8uIfos0ae472Xu REDE98raCMtZUSPK8H0gyQYqS9V8hGdjuDf4EaectfboZburMKWk4NNHSbDb7iaAia+gF2mC6 Y48XO2IFHIBUEcdBd5ZcUT6687JMHLOmBFMiDsqBnS2o5+WiBlrmIPeWnXZKIgO5xb/zRx/s4 rRWZs+kuuLJuQdEPW4GVmIOoro82wB381J2P8CQrzHMpTxxOt161nYl5ZOh/YaXq2jMuluB8j FjVfG1bIMWI520eIF3hJtxHYBnrYfZIXETg774/TXrk7GjT9dbBPYs7HgRlNd/Ji4jZ1e6PKN 3o6eYofop2HUxbSuWEHhnDmWP2skuNsev2TenA== Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang complains about assigning a variable to itself during the declaration: fs/ceph/ioctl.c:187:26: error: variable 'oid' is uninitialized when used within its own initialization [-Werror,-Wuninitialized] CEPH_DEFINE_OID_ONSTACK(oid); ^~~ include/linux/ceph/osdmap.h:122:52: note: expanded from macro 'CEPH_DEFINE_OID_ONSTACK' struct ceph_object_id oid = CEPH_OID_INIT_ONSTACK(oid) ~~~ ^~~ include/linux/ceph/osdmap.h:120:29: note: expanded from macro 'CEPH_OID_INIT_ONSTACK' ({ ceph_oid_init(&oid); oid; }) ^~~ We use this trick in other places, but it is completely unnecessary here, as we can just use a regular struct initializer. Signed-off-by: Arnd Bergmann --- v2: rearrange to only have one instance of the initializer --- include/linux/ceph/osdmap.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h index 5675b1f09bc5..8794cf0f0b39 100644 --- a/include/linux/ceph/osdmap.h +++ b/include/linux/ceph/osdmap.h @@ -110,17 +110,16 @@ struct ceph_object_id { int name_len; }; +#define CEPH_OID_INITIALIZER(oid) { .name = (oid).inline_name } + +#define CEPH_DEFINE_OID_ONSTACK(oid) \ + struct ceph_object_id oid = CEPH_OID_INITIALIZER(oid) + static inline void ceph_oid_init(struct ceph_object_id *oid) { - oid->name = oid->inline_name; - oid->name_len = 0; + *oid = (struct ceph_object_id)CEPH_OID_INITIALIZER(*oid); } -#define CEPH_OID_INIT_ONSTACK(oid) \ - ({ ceph_oid_init(&oid); oid; }) -#define CEPH_DEFINE_OID_ONSTACK(oid) \ - struct ceph_object_id oid = CEPH_OID_INIT_ONSTACK(oid) - static inline bool ceph_oid_empty(const struct ceph_object_id *oid) { return oid->name == oid->inline_name && !oid->name_len;