netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Alexander Duyck <alexander.duyck@gmail.com>,
	linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org,
	netdev@vger.kernel.org, Don Dutile <ddutile@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH mlx5-next v4 1/4] PCI: Add sysfs callback to allow MSI-X table size change of SR-IOV VFs
Date: Tue, 26 Jan 2021 10:48:17 +0200	[thread overview]
Message-ID: <20210126084817.GD1053290@unreal> (raw)
In-Reply-To: <48c5a16657bb7b6c0f619253e57133137d4e825c.camel@perches.com>

On Tue, Jan 26, 2021 at 12:20:11AM -0800, Joe Perches wrote:
> On Tue, 2021-01-26 at 08:01 +0200, Leon Romanovsky wrote:
> > On Mon, Jan 25, 2021 at 01:52:29PM -0800, Jakub Kicinski wrote:
> > > On Sun, 24 Jan 2021 15:11:16 +0200 Leon Romanovsky wrote:
> > > > +static int pci_enable_vfs_overlay(struct pci_dev *dev) { return 0; }
> > > > +static void pci_disable_vfs_overlay(struct pci_dev *dev) {}
> > >
> > > s/static /static inline /
> >
> > Thanks a lot, I think that we should extend checkpatch.pl to catch such
> > mistakes.
>
> Who is this "we" you refer to? ;)

"We" == community :)

>
> > How hard is it to extend checkpatch.pl to do regexp and warn if in *.h file
> > someone declared function with implementation but didn't add "inline" word?
>
> Something like this seems reasonable and catches these instances in
> include/linux/*.h

Thanks

>
> $ ./scripts/checkpatch.pl -f include/linux/*.h --types=static_inline --terse --nosummary
> include/linux/dma-mapping.h:203: WARNING: static function definition might be better as static inline
> include/linux/genl_magic_func.h:55: WARNING: static function definition might be better as static inline
> include/linux/genl_magic_func.h:78: WARNING: static function definition might be better as static inline
> include/linux/kernel.h:670: WARNING: static function definition might be better as static inline
> include/linux/kprobes.h:213: WARNING: static function definition might be better as static inline
> include/linux/kprobes.h:231: WARNING: static function definition might be better as static inline
> include/linux/kprobes.h:511: WARNING: static function definition might be better as static inline
> include/linux/skb_array.h:185: WARNING: static function definition might be better as static inline
> include/linux/slab.h:606: WARNING: static function definition might be better as static inline
> include/linux/stop_machine.h:62: WARNING: static function definition might be better as static inline
> include/linux/vmw_vmci_defs.h:850: WARNING: static function definition might be better as static inline
> include/linux/zstd.h:95: WARNING: static function definition might be better as static inline
> include/linux/zstd.h:106: WARNING: static function definition might be better as static inline
>
> A false positive exists when __must_check is used between
> static and inline.  It's an unusual and IMO not a preferred use.

Maybe just filter and ignore such functions for now?
Will you send proper patch or do you want me to do it?

> ---
>  scripts/checkpatch.pl | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 4f8494527139..0ac366481962 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4451,6 +4451,18 @@ sub process {
>  			}
>  		}
>
> +# check for static function definitions without inline in .h files
> +# only works for static in column 1 and avoids multiline macro definitions
> +		if ($realfile =~ /\.h$/ &&
> +		    defined($stat) &&
> +		    $stat =~ /^\+static(?!\s+(?:$Inline|union|struct))\b.*\{.*\}\s*$/s &&
> +		    $line =~ /^\+static(?!\s+(?:$Inline|union|struct))\b/ &&
> +		    $line !~ /\\$/) {
> +			WARN("STATIC_INLINE",
> +			     "static function definition might be better as static inline\n" .
> +				$herecurr);
> +		}
> +
>  # check for non-global char *foo[] = {"bar", ...} declarations.
>  		if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
>  			WARN("STATIC_CONST_CHAR_ARRAY",
>
>

  reply	other threads:[~2021-01-26 18:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 13:11 [PATCH mlx5-next v4 0/4] Dynamically assign MSI-X vectors count Leon Romanovsky
2021-01-24 13:11 ` [PATCH mlx5-next v4 1/4] PCI: Add sysfs callback to allow MSI-X table size change of SR-IOV VFs Leon Romanovsky
2021-01-24 16:47   ` Alexander Duyck
2021-01-24 19:00     ` Leon Romanovsky
2021-01-25 18:47       ` Leon Romanovsky
2021-01-25 18:50         ` Alexander Duyck
2021-01-25 18:54           ` Leon Romanovsky
2021-01-25 21:52   ` Jakub Kicinski
2021-01-26  6:01     ` Leon Romanovsky
2021-01-26  8:20       ` Joe Perches
2021-01-26  8:48         ` Leon Romanovsky [this message]
2021-01-26  8:57           ` Joe Perches
2021-01-26  9:26             ` Leon Romanovsky
2021-01-24 13:11 ` [PATCH mlx5-next v4 2/4] net/mlx5: Add dynamic MSI-X capabilities bits Leon Romanovsky
2021-01-24 13:11 ` [PATCH mlx5-next v4 3/4] net/mlx5: Dynamically assign MSI-X vectors count Leon Romanovsky
2021-01-24 13:11 ` [PATCH mlx5-next v4 4/4] net/mlx5: Allow to the users to configure number of MSI-X vectors Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210126084817.GD1053290@unreal \
    --to=leon@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=alexander.duyck@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=davem@davemloft.net \
    --cc=ddutile@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=joe@perches.com \
    --cc=kuba@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).