From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EB30C43331 for ; Sun, 29 Mar 2020 06:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6994C2073E for ; Sun, 29 Mar 2020 06:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585464294; bh=ZSnBqyHG5vDVbqdvVr9ONDnFEQ3e49b7/0eFOIyHldY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=SBIyutItvc7ZaavYi0uPJPBhmHNLiGkr1eNaZ3STqk8H+CiQoIboL/NS2V0JSkAPH 0zYT7sRrms2KHSfffRjqWFCxIamTdb9nGKB/qec4+AIkf779XUNtv9fym6VedAL3jG AVu0+z/buo2+X+8fXWT62YGyYD60QA3zwXjF24p0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbgC2Gox (ORCPT ); Sun, 29 Mar 2020 02:44:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727335AbgC2Gox (ORCPT ); Sun, 29 Mar 2020 02:44:53 -0400 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBE7A2073B; Sun, 29 Mar 2020 06:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585464292; bh=ZSnBqyHG5vDVbqdvVr9ONDnFEQ3e49b7/0eFOIyHldY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iNhC7IuyvAcjXOfOyAubx3mjeb00g4pZcWPG6IKKqn2JXRgNcTc6LvAONDP1qElRC mvtcjhQ4X/HFYe3NohY4uwUCIo1xmJzzHQaip4QTP4SfYIOZTphko3rENsHA9P4cTa 300DbDxUI9+Hv/zjBxJXJDQxD3MTyVpywEEaQCyc= Date: Sun, 29 Mar 2020 09:44:49 +0300 From: Leon Romanovsky To: Jacob Keller Cc: netdev@vger.kernel.org, tanhuazhong Subject: Re: [PATCH net-next] mlx4: fix "initializer element not constant" compiler error Message-ID: <20200329064449.GA2454444@unreal> References: <20200327210835.2576135-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200327210835.2576135-1-jacob.e.keller@intel.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Mar 27, 2020 at 02:08:35PM -0700, Jacob Keller wrote: > A recent commit e8937681797c ("devlink: prepare to support region > operations") used the region_cr_space_str and region_fw_health_str > variables as initializers for the devlink_region_ops structures. > > This can result in compiler errors: > drivers/net/ethernet/mellanox//mlx4/crdump.c:45:10: error: initializer > element is not constant > .name = region_cr_space_str, > ^ > drivers/net/ethernet/mellanox//mlx4/crdump.c:45:10: note: (near > initialization for ‘region_cr_space_ops.name’) > drivers/net/ethernet/mellanox//mlx4/crdump.c:50:10: error: initializer > element is not constant > .name = region_fw_health_str, > > The variables were made to be "const char * const", indicating that both > the pointer and data were constant. This was enough to resolve this on > recent GCC (gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) for this author). > > Unfortunately this is not enough for older compilers to realize that the > variable can be treated as a constant expression. > > Fix this by introducing macros for the string and use those instead of > the variable name in the region ops structures. > > Reported-by: tanhuazhong > Fixes: e8937681797c ("devlink: prepare to support region operations") > Signed-off-by: Jacob Keller > --- > drivers/net/ethernet/mellanox/mlx4/crdump.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > Thanks, Reviewed-by: Leon Romanovsky