Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2928919lqp; Mon, 25 Mar 2024 13:24:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/FyfBJTArSiuz4B9IcV7zAvAGkOCLiBuy4Gip3zyqTKuwccbPbr+BJyM2rhG/5azLtnGy/rsLN0h2BAJ6Ob77VjdTnElyQ92NhAv4VA== X-Google-Smtp-Source: AGHT+IGSI1ZyHEsjCWrhdEwoaYHVhBOE5Kbu3PIuOUqmlRN5BcX9JFBGzluOwvkfQsMQIWw2y2R1 X-Received: by 2002:ac8:5bca:0:b0:431:5fad:ddbd with SMTP id b10-20020ac85bca000000b004315fadddbdmr2741876qtb.29.1711398260470; Mon, 25 Mar 2024 13:24:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711398260; cv=pass; d=google.com; s=arc-20160816; b=JpqYvYeuFBHBlRgzXDWGBg3g6l/9B/6ciiGsDbH8MC1HE51AcikcGRMhuzqicb6oCw PKIH5lqIrUKGymEi4tnsqdHhuzHmSAPDaiS9L7qVn7YLNWfDmQg/XR9tInhZVnfNQ5Ps ZXpHPs+KMjHqX9W/+ijs63FkUvZR0xkgkZtdaRSHRZvi1A2DVt/9yZr+smlGVMKOHUWp 4iHCWqmTs6nDqLIW4rv8tfsreAgN625f8qdDelDrcBHqNruOuxndbXaTtySfy84e17sS AASGCHSCvF/KnH4dv8SX/9U+kpYhYhgZzLfE98qBP9f0yFEEWGmUWllAf9C9YFHcC6JX tjUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=NfG8cRcyYQ813sTNi9ceL90yA4r6LblrfamP/p6uJhU=; fh=1cHgEmDNMh32Nj/qSxwLpYUo5nRtD7wvP1+x8sexb8Y=; b=Okgpv885DlO+PXkOOeEBZ1XLYga34LNR1qWYBzgJWQ0EphtVlHh/6AZ5f+dpD3yw9U 1dGcEDTuxVxAHDyjqkgSmEo9cVjOXpng5NZs1Trc5TaDyxWVLLGxXzmZZ3E+mmgAqYNU 6ZFq/s8ZKtsJ1K0yLFe+12Yf01NbWvPiq3nLIPONwnPnkZuxrk3wOHpsMd4vHx+XG91X kW7k8eTymJqywZGurCf+xE/15Fb1d3F3Q0S1JIMm3tiQisvoMJ2QiFGCwhyHwSIFC9to SdYnt5SOtKsdF0mMdNM9ukXmnlnldkXzL3BX3Tkdmd7T7YAVlJu4ZivI1QrPUx0lug3p WmiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KGjiBMZJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117917-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fx13-20020a05622a4acd00b0043123c89c4esi6336796qtb.781.2024.03.25.13.24.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:24:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117917-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KGjiBMZJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117917-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117917-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B8731C248C3 for ; Mon, 25 Mar 2024 20:24:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14C5545BE6; Mon, 25 Mar 2024 20:24:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KGjiBMZJ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33DA543AB6; Mon, 25 Mar 2024 20:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711398250; cv=none; b=Es34zwfLTqEwrBZGQbPEHJQaWEOOLbpAFu9FTgTxau3V2I7VHEcBkADeF6+IWDN7OXsTxlm5bxS9sR2iaEt4ucWnmGCii/vJx7SI3ZbAbxs2PB8bPOUsr3RuuSLBVjwEl1QH85BCy9JOf18siUkdoq0HUeTlzTSsfs+CYlvNjd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711398250; c=relaxed/simple; bh=s4mxlWFOQHsHeS33PiyHipgWfd/TWr7AQKJn8SBt0b4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=O2AOyOLkFXd3k604kDY7L9rSYACKExphR60LIBchlcZznb1lDXkXrEtXVJz0giSCiHIfyT73Z4Ivf/sS5YJGruy25NLmvnmyDRnMXW9qwAkjJ4lmSlUVOG8NbyiWZPPqmylbq6z2n+0dwM+sM4BLHr9OvDkL6Q432FStNyeV0j4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KGjiBMZJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25D26C433F1; Mon, 25 Mar 2024 20:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711398249; bh=s4mxlWFOQHsHeS33PiyHipgWfd/TWr7AQKJn8SBt0b4=; h=Date:From:To:Cc:Subject:From; b=KGjiBMZJdEp8z12YgVYHXGqAElUMr5TUVI1UZfcxsXWAgZqcigfebkrckxkkTw+jh JLgwdPYIGVbo6HCnRdKVc06iEUdb6nRMzAoG73t3B8AKCCKH+9qkjA2fxi/NJ8E5AT SrnTJ9MsM2gMsKxaTXkK/tp99WtQDkK7G9uZadbkZbsoDSgmrRc7fBErGrMLPSgMpH B4Z4DbyPnlK3m/kHvPkfzuiE3U415PHmAbC9ihYwrWLQe323SNjZgiZywBt7eqRPzW s4j4JkMb/qf/ebZl+BdeGF/APtOUVBH/GEgRw5dzNneIKSGYHWx9DhH/vyFj5GywsI /9OUfIFrl0a8w== Date: Mon, 25 Mar 2024 14:24:07 -0600 From: "Gustavo A. R. Silva" To: Jason Gunthorpe , Leon Romanovsky Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] RDMA/cm: Avoid -Wflex-array-member-not-at-end warning Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally. Use the `struct_group_tagged()` helper to separate the flexible array from the rest of the members in flexible `struct cm_work`, and avoid embedding the flexible-array member in `struct cm_timewait_info`. Also, use `container_of()` to retrieve a pointer to the flexible structure. So, with these changes, fix the following warning: drivers/infiniband/core/cm.c:196:24: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva --- drivers/infiniband/core/cm.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index bf0df6ee4f78..80c87085499c 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -182,18 +182,21 @@ struct cm_av { }; struct cm_work { - struct delayed_work work; - struct list_head list; - struct cm_port *port; - struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */ - __be32 local_id; /* Established / timewait */ - __be32 remote_id; - struct ib_cm_event cm_event; + /* New members must be added within the struct_group() macro below. */ + struct_group_tagged(cm_work_hdr, hdr, + struct delayed_work work; + struct list_head list; + struct cm_port *port; + struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */ + __be32 local_id; /* Established / timewait */ + __be32 remote_id; + struct ib_cm_event cm_event; + ); struct sa_path_rec path[]; }; struct cm_timewait_info { - struct cm_work work; + struct cm_work_hdr work; struct list_head list; struct rb_node remote_qp_node; struct rb_node remote_id_node; @@ -3440,7 +3443,7 @@ static int cm_timewait_handler(struct cm_work *work) struct cm_timewait_info *timewait_info; struct cm_id_private *cm_id_priv; - timewait_info = container_of(work, struct cm_timewait_info, work); + timewait_info = container_of(&work->hdr, struct cm_timewait_info, work); spin_lock_irq(&cm.lock); list_del(&timewait_info->list); spin_unlock_irq(&cm.lock); -- 2.34.1