From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 069E7267B9B for ; Sat, 8 Nov 2025 17:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762623013; cv=none; b=it4t/nTjDwf4hi5RBdkS0a2jbPRh7+OqqmUBxmSG0GfRCBemtKAItpBwslY0Synzmbc8WCcFL9yQbFNFUAo1qfGzS9PuEoq3VEMHDFTcwElCdpqbEyCUoCVl40wgJualkzNnq7QCXd/l+ySO+lmrNWsh/PbkrSU6hjqMXglvwDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762623013; c=relaxed/simple; bh=mqvOz/c5PMEmaEMrlMTr9mIFRYBwkDh40KxWBaUTkP0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=F22BiPHq9qzllkbP/YhgPOhAPOwVxCHUDxN2vWM7xh8Nny/Bb1fqie+YDqpQN5ah9rXFYJ70H2P74E+ihKKg4bmWMXdjYCQ5Hlmj+ejiMs6R7J6tg8EcezukkvZJjXbjxlFiRl8oxejt8rga3NXHtEfnrbtPii25IOBo8JCfMg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xz7PhYlN; arc=none smtp.client-ip=209.85.214.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xz7PhYlN" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-29555415c5fso22058965ad.1 for ; Sat, 08 Nov 2025 09:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762623010; x=1763227810; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ksh9yCu4UesSZktaqp077/wo5kGK4/tiGrzTuoLqT7M=; b=Xz7PhYlN7QTrZUnk7vH9yXuvdg9pHlnstZrtSYCJ4rBT6tpcyp3w01cJ/sPGTP5nwS 2mYMqN6cRkR1XTdbATmjJ5bRrcRPIVZtAHX4tfrXYVtmRiX9xSWj0gYvaQasTc7dfCw1 g4mmHseOONvyXw+6NJ9ofaiTrvFPoaSG4RnPQqGrmslUEcFB6Ojgz34engdIkjWdgLVo UduqA2rm6968FfzKoeExcrYtoQKVakkccjkE3V8//OfNw7iv66nZ8Iipk0yGy0CJZQmC 9XvLvKVRdH9n/93wifslMqka4cGgKRrTvrJINn+r9jMPhJsPlyE6ga51lGyt5aVHWmu/ zhrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762623010; x=1763227810; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ksh9yCu4UesSZktaqp077/wo5kGK4/tiGrzTuoLqT7M=; b=LGhBKPdxow6YO/fQzXd3wwmPinN/B8KLcNP9TdrE3/n/qctZD+ukc4Unq2q0SqLYOS v4bOFzBR1kvc60TH2oJIq9lewbqv03YOT9uRDVTS1jfSsYJvFZGHV/AhkeSxTlxtJjXG GfURox8krZ8oEO0rFRDQdVKTV2mbVUvKZNfJsBP5me2dqLphc0waowCIV0GdlY+RtrAr 0Zq3JxOq0mYYvG1HmAMcd2zvMs7UKp1R3oVjSXUh0RE7c02WUIs6n8vJ1TKawLZXNj0r mvOOfHvPmIfUjhXS9PBLlE7Wq/U0Lx+iby28zANwQNX3YXkVZHmvQbrBxpdI4XWXjzr9 1UoQ== X-Forwarded-Encrypted: i=1; AJvYcCXc2yVTCqz43tVwkMAV5i+Nn/PVdeAR8SA8cJ0sxN3/1uDNODRKwCyPU438wGHiPT8uajacEQmUEiNnd+M=@vger.kernel.org X-Gm-Message-State: AOJu0YwNvutKqwVyhNAXpUJcUzUFf7GnU9+ge+Wt8vD5NzrVfOd5+nkW 9scO46Wx+YmlVOlLrLKUjF/ELXzLDxiJBqnzo9SgJYTfWE+hTsHSypeZ X-Gm-Gg: ASbGncvxj7M7jirIG3mDHNghpIc28Y2A/FDy0HioR+2RpPEpMNVKGOEohiZMhK8JiX3 1wgCRtpzF/RbpsZfFjfA8hDmyxZnJXK/gXF97l3SH6c1QCndj2Om8EETES6loalpLiK5C7phrDh iaNojmr7KglfxSXtZGaUJB4ZTNfUurc/LCuBdZ/CQXkSYTQN99f9LgB2pKp1DfWqK8Ss7Tk9yJD LxHwD6WVeH5uheIYMk9++nm7AowPAyTpUxNnMdQKW/XPnPXb0rHmODRTmINDsGZHJ4mRm9WQiCZ BwtG+6OX9A426Z7QY5PS+6jfZ1FmTAN0IkbU5+C+RtszRhAq1757X0zWirGRv4xeFBM0B4rqfSg 9ETtPdzari27KBVH2h3qPT4jQtnuiCvvROmLSkM+9iIGAf5bjkIAWFDSUEbuVhvCH1/8d5jgbh+ fMdn0wUlkGMERo4nyhrbg= X-Google-Smtp-Source: AGHT+IFLUU/VWag8EJzSY/0xYAOHUmVtlabS8D9NAS2JD/HU1e2hrzCK0vE/MQxp1herrE49UHd/uA== X-Received: by 2002:a17:902:e848:b0:296:3f23:b939 with SMTP id d9443c01a7336-297e56ce0b1mr51308795ad.42.1762623010252; Sat, 08 Nov 2025 09:30:10 -0800 (PST) Received: from fedora ([103.120.31.122]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29650c5c72esm93914635ad.33.2025.11.08.09.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Nov 2025 09:30:09 -0800 (PST) Date: Sat, 8 Nov 2025 22:59:59 +0530 From: Ankit Khushwaha To: Simon Horman Cc: Steffen Klassert , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Willem de Bruijn , Jason Xing , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [PATCH] selftest: net: fix variable sized type not at the end of struct warnings Message-ID: References: <20251027050856.30270-1-ankitkhushwaha.linux@gmail.com> 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 In-Reply-To: On Tue, Oct 28, 2025 at 05:23:12PM +0000, Simon Horman wrote: > On Mon, Oct 27, 2025 at 10:38:56AM +0530, Ankit Khushwaha wrote: > > Some network selftests defined variable-sized types defined at the end of > > struct causing -Wgnu-variable-sized-type-not-at-end warning. > > > > warning: > > timestamping.c:285:18: warning: field 'cm' with variable sized type > > 'struct cmsghdr' not at the end of a struct or class is a GNU > > extension [-Wgnu-variable-sized-type-not-at-end] > > 285 | struct cmsghdr cm; > > | ^ > > > > ipsec.c:835:5: warning: field 'u' with variable sized type 'union > > (unnamed union at ipsec.c:831:3)' not at the end of a struct or class > > is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > > 835 | } u; > > | ^ > > > > This patch move these field at the end of struct to fix these warnings. > > > > Signed-off-by: Ankit Khushwaha > > Hi Ankit, > > I don't believe this change is correct. > > I think that the intention of the code is the char arrays (buf and control) > provide the buffer space for the variable-length trailing field > of the preceding structure. Where we basically have a header followed > by data. But your patch would place the before the header. > Hi Simon, So if buf and control providing the buffer space, then i think it is better to suppress `-Wgnu-variable-sized-type-not-at-end` warning within this block of code. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end" struct { union { struct xfrm_algo alg; struct xfrm_algo_aead aead; struct xfrm_algo_auth auth; } u; char buf[XFRM_ALGO_KEY_BUF_SIZE]; } alg = {}; #pragma GCC diagnostic pop I think this would be fine. Thanks -- Ankit