From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A9298A00C5; Wed, 2 Feb 2022 18:28:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40D1841169; Wed, 2 Feb 2022 18:28:43 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 77CCB410FF for ; Wed, 2 Feb 2022 18:28:41 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id d18so18976033plg.2 for ; Wed, 02 Feb 2022 09:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mJ3SG3ld8S2XwSxQ35kVmY2VWX9mz3SM/fL3yuIJ77Q=; b=qjAU9QJzNHektHZSMDRZkL0euOBRFmcniesLI4msvjhIKvWzhuk738TF0FzxJOaKml ZH7mROsukZw719EKWwmaFdDPve1efTHtN4hcOzyTyU6Gbp5Dvrs+NY6qFf9YGxNs4QqC YNbNxYotmHASmmUrH5Gl1B8csSMTqEgxlbjZLckeR1dfpz4fWrSuC5MKYz6LQmgpOM0a mIoqwKp4Q9eJZY+8tAl8V+oD6RJORkluXIlMlMCXicvPO+OwOo4VlNYuyHqFK1ZuBbDU 0TUE6EzM8F2CqIndKKRzd6TKofektj97jLuMBEksWjb7znzK7JCDD4S8Ba12T7Wma4j/ OT4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mJ3SG3ld8S2XwSxQ35kVmY2VWX9mz3SM/fL3yuIJ77Q=; b=XfpVMU3yGYFovu0zZq/0ju8fPpoX5YIM9aJVCMUv9CbbO5nQUIveKRHWxHyt7G/01l lXYxcxhvBAZP/qpew7Y0anOrX2LG3rH7rcym86JuEv4kBin+rjSKMBO+zO7sfJ/4lt/h +KkmIkql1dR0rb5FsKlVkGQ0sXk94oUP7gn190XWKu3TvqSdDscSb77BoMH8esf46W9x 7BcAgJ7E5UzFadZq67adKdDL3CSkWJUChkACbkogqEBg4Q/I3ALoyoTsAjFRBHwvOBqs B43zBNZqHrJzXiBThwhY59s7Agu+9fN5yNxBICVi7qbrfXvZgCs04ozURaJQohvahhHx crUA== X-Gm-Message-State: AOAM530TFNUXGrqM1Jh6gA7+iuxyblWs4Qj+KtvlW6vSAxXxFbsUq6pH wNpXTv1iWi6Am5n/CVfz9itK4O60fG5g9XNB X-Google-Smtp-Source: ABdhPJxiHwzwkwsU7+FTRP19NAQ/AkvcmbDA2+1iJ57z+EKPtYmbNhHKaVoL+EqXHUPz80w5u5MQ3g== X-Received: by 2002:a17:902:e812:: with SMTP id u18mr31765161plg.12.1643822920381; Wed, 02 Feb 2022 09:28:40 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id q17sm16949055pgh.58.2022.02.02.09.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 09:28:39 -0800 (PST) Date: Wed, 2 Feb 2022 09:28:36 -0800 From: Stephen Hemminger To: Bruce Richardson Cc: Morten =?UTF-8?B?QnLDuHJ1cA==?= , Sean Morrissey , Reshma Pattan , dev@dpdk.org Subject: Re: [PATCH v6 20/50] pdump: remove unneeded header includes Message-ID: <20220202092836.5e1aadbb@hermes.local> In-Reply-To: References: <20220117201943.873922-1-sean.morrissey@intel.com> <20220202094802.3618978-1-sean.morrissey@intel.com> <20220202094802.3618978-21-sean.morrissey@intel.com> <20220202075458.3f8cd2c1@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35D86E6B@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 2 Feb 2022 17:03:44 +0000 Bruce Richardson wrote: > On Wed, Feb 02, 2022 at 05:45:47PM +0100, Morten Br=C3=B8rup wrote: > > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > > Sent: Wednesday, 2 February 2022 17.01 > > >=20 > > > On Wed, Feb 02, 2022 at 07:54:58AM -0800, Stephen Hemminger wrote: =20 > > > > On Wed, 2 Feb 2022 09:47:32 +0000 > > > > Sean Morrissey wrote: > > > > =20 > > > > > These header includes have been flagged by the iwyu_tool > > > > > and removed. > > > > > > > > > > Signed-off-by: Sean Morrissey > > > > > --- =20 > >=20 > > [...] > > =20 > > > > =20 > > > > > diff --git a/lib/pdump/rte_pdump.h b/lib/pdump/rte_pdump.h > > > > > index 6efa0274f2..41c4b7800b 100644 > > > > > --- a/lib/pdump/rte_pdump.h > > > > > +++ b/lib/pdump/rte_pdump.h > > > > > @@ -13,8 +13,6 @@ > > > > > */ > > > > > > > > > > #include > > > > > -#include > > > > > -#include > > > > > #include > > > > > > > > > > #ifdef __cplusplus =20 > > > > > > > > This header does use rte_mempool and rte_ring in rte_pdump_enable(). > > > > Not sure why IWYU thinks they should be removed. =20 > > >=20 > > > Because they are only used as pointer types, not as structures > > > themselves. > > > Normally in cases like this, I would put in just "struct rte_mempool;" > > > at > > > the top of the file rather than including a whole header just for one > > > structure. =20 > >=20 > > I don't think we should introduce such a hack! > > If a module uses something from a library, it makes sense to include th= e header file for the library. > >=20 > > Putting in "struct rte_mempool;" is essentially copy-pasting from the l= ibrary, although only a structure. What happens if the type changes or disa= ppears, or depends on some #ifdef? It could have one type in some cases and= another type in other cases - e.g. the atomic counters in the mbuf once ha= d different types, depending on compile time flags. The copy-pasted code wo= uld not get fixed if the type evolved over time. =20 >=20 > By "struct rte_mempool;" I mean literally just that. All it does is > indicate that there is a structure defined somewhere else that will be us= ed > via pointer in the file later on. There is no copy-pasting involved and t= he > reference does not need to change as the structure changes. >=20 > From what I read, having this forward declaration is not necessary for C, > but for C++ if you use the struct pointer in a function definition later > on, you may get an error. >=20 > Therefore, if you are using a struct only as a pointer parameter, the best > option is to forward declare it (to keep C++ happy), and not include a > whole header file unnecessarily. >=20 > /Bruce Using the empty structure definition is reasonable and is done a couple oth= er places.