From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75337A0562; Tue, 31 Mar 2020 16:53:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 52EE91BFC1; Tue, 31 Mar 2020 16:53:49 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 2E9CB322C for ; Tue, 31 Mar 2020 16:53:48 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id g18so8226185plq.0 for ; Tue, 31 Mar 2020 07:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PQ6Wbw/GI0AWN4WbSZ9aqgUx/8DJ3NhBCanhwxp7S2A=; b=iecZmZvKbherwKZIf+pcxHEXXHe0ituQyvjj7ILN4MoCJXyuwBnMncHlvjQdJi9Tvn i1ZOalUPja0uqG5DBZMqL1t7v38ujl+d2O6tpHTcLWk730D9pDeToU7qSLar+0DFvgK0 R/Lvt2VAca+uPiSGyremOSh7DrTtKZ5aVEHSBDkwHZE2fIVY+4FPQf+z8eukMKi/G4Hu KSXpIvMn7M5bWDtwvgy2ADshh2NItFnFbKuvx+/Vitjwke+uO7o8cYSbgNTkAqslDrUH onVCJQ26l6GLwzuOPjt7XJ3E73sc3CoBPTT3cK7psirqzCOFK+QU6HKj1hveukbpkK9u QdWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PQ6Wbw/GI0AWN4WbSZ9aqgUx/8DJ3NhBCanhwxp7S2A=; b=Tb15c5K8IBMGxssyNfFVB2VDnCqp0EwYF+F8n/z0ozMDsPYgg1mgvsqyVAuFDN84mp ab2+x0PmIJYltVAySY/26Y7JjvLHl7vxtiLEPXE1Lnm1JCNWkuNbEqSFeS7rk1dWpZHw dMpf+EvUhdiRrQYw8neP5Ad3qnpVWasFiqf/s18UbXMTsHWl2m7YauA3c8kVjXINvh7v 4xtWbdSC2M/2UTXcAxd5Ndqbd0fQgBX99Zvd9DQnud3coEiDHTO6kGBNLiaax0+gyXPL 3g0xuAY7ylKmog89jTJMf8GVwiP5op16MkoaBhRESzVuhLPqlUlezHhjz9t9+t3XD4GY LZEA== X-Gm-Message-State: AGi0PuZ6Ng/20dXqVfXNgvKig+lXgYZ8b9DWA7H4y3GW3+nIK6YbPA99 QlmJmUfx7MRqWlOQMrkBA1oluA== X-Google-Smtp-Source: APiQypL49MsitsxYlxEJRhoU61pkgdRIBMLSq1LQDY8gA0jrNfE4HkYbIofiKfn25yXLKYz0wrdiyg== X-Received: by 2002:a17:902:760f:: with SMTP id k15mr4808330pll.0.1585666427217; Tue, 31 Mar 2020 07:53:47 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id nh14sm2153143pjb.17.2020.03.31.07.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 07:53:46 -0700 (PDT) Date: Tue, 31 Mar 2020 07:53:37 -0700 From: Stephen Hemminger To: Kevin Traynor Cc: Thomas Monjalon , dev@dpdk.org, bruce.richardson@intel.com, ravi1.kumar@amd.com, g.singh@nxp.com, hemant.agrawal@nxp.com, akhil.goyal@nxp.com, johndale@cisco.com, hyonkim@cisco.com, jingjing.wu@intel.com, wenzhuo.lu@intel.com, rmody@marvell.com, shshaikh@marvell.com, matan@mellanox.com, shahafs@mellanox.com, declan.doherty@intel.com, cristian.dumitrescu@intel.com Message-ID: <20200331075337.222cc047@hermes.lan> In-Reply-To: <4613d437-5a0c-b664-8435-699c43b63f94@redhat.com> References: <20200325141137.7088-1-ktraynor@redhat.com> <11831469.VsHLxoZxqI@xps> <4613d437-5a0c-b664-8435-699c43b63f94@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [RFC 0/2] gcc 10 disable stringop-overflow warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 31 Mar 2020 15:08:26 +0100 Kevin Traynor wrote: > struct virtchnl_rss_key { > u16 vsi_id; > u16 key_len; > u8 key[1]; /* RSS hash key, packed bytes */ > ^^^^^^^^^ > }; > > Then in iavf_configure_rss_key() > > len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1; > ^^^^^^^^^^^^ > rss_key = rte_zmalloc("rss_key", len, 0); > ^^^ extra space beyond key[1] allocated here > > > rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size); > ^^^ ^^^^^^^^^^^^ > > At runtime we have allocated extra space at the end of the struct for > key, and the same size used in the malloc is also considered when > finding the right branches in the memcpy fns. But the compiler does not > know value of size and it simply sees there can be casts of a 1 byte key > to 16 or 32 bytes in some branches of the memcpy fns, so gives a warning. The standard way to do such a thing is to use an empty array. The Linux kernel has just gone through cleaning up all these zero length (and it this case one) array at end of function.