From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CAD8C3A5A2 for ; Wed, 4 Sep 2019 03:27:36 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B87621897 for ; Wed, 4 Sep 2019 03:27:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HQ+KVCx0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B87621897 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.92) (envelope-from ) id 1i5Lx0-0004Pu-MQ; Tue, 03 Sep 2019 23:27:18 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1i5Lwx-0004Po-IA for kernelnewbies@kernelnewbies.org; Tue, 03 Sep 2019 23:27:15 -0400 Received: by mail-wm1-x343.google.com with SMTP id p13so1759917wmh.1 for ; Tue, 03 Sep 2019 20:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uPWY4BcRbxdFYcsAaUhtcDQqBaN4kyw3BRuklZeTJoo=; b=HQ+KVCx0J0Xl6B92z1AVj8IjZWoFiHR3zq5lEM26BW5qPjjZs8lXckSUlVZhLRZFpq 6HiOrW+0k0YKQS0bDPlHRwvFdrJxPxd+EsDiPjSAXIc9La23+SgOxSN9PXzkzIo0tX6p qRlR4fUZxWtGbqKJxcwI7jioCTeKAXnN6pD0KSSwqoxVtA9+sQAwOLGmu0LzLzycGK1D SvlMKLtbtMN4gFrzfFJnuHdEylkHwvAnrfsNMGhGU9Va8fWBRqnLqX0JWKhk5zXR9ebZ d9xLVsVAlBhKrzI6sy3enma7IZMsu/ZbvYhwelSXOHnUTnyAwmjPwtub0JIbbg2vYefg imew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uPWY4BcRbxdFYcsAaUhtcDQqBaN4kyw3BRuklZeTJoo=; b=gmVRSLHBMnSgWAapWX5WWRzpZh4VKyWRL8gAAZmcy97Uz2GfwMRYn6hys97/lUpZ+J RtA/DysMBVPOPdbGIRmBDVggA628B5kxbiW8BhZyLcDXSKq3cdUwV4dTX+W65IGZ8sLd 3o5XhpSNiEwmGB8kJjWdyA7/eZRGUYGO6OhH/oHPSbweOUegHEvgEg7hDCzsDcNiOVdm N8CPnsHJqUQAqREB8XWzsbig/j2znpF87W5FJLe4YFnAzMdL2emF0CfjECLBcdk3PDUv 3EZ6BizcjDjKfnLDn0NXJVxCmB41n11Jr4EtAC0d0inrfwQ6OXgYbARSlQggpY4lxMgx +rog== X-Gm-Message-State: APjAAAUU+vF1/UjJ3JD/2+R7J9w6WmoK5Y1xMdeZ427PmVHqOOM78LEH qhp7Eif9tannReSvNM+ZWS+xClEiF6sIU+cMM7E= X-Google-Smtp-Source: APXvYqzKuFGQIsk7D828T3yo77v6ejna70WzfF9oMG8Iy0yNT0vNcupPHB2TgHSdCO7pGjh7ALdF4b8LMTqTwV4juwo= X-Received: by 2002:a7b:c7cc:: with SMTP id z12mr2372822wmk.80.1567567633662; Tue, 03 Sep 2019 20:27:13 -0700 (PDT) MIME-Version: 1.0 References: <542004.1567506067@turing-police> In-Reply-To: <542004.1567506067@turing-police> From: Pablo Pellecchia Date: Wed, 4 Sep 2019 00:27:02 -0300 Message-ID: Subject: Re: Staging/netlogic coding style issues with struct To: =?UTF-8?Q?Valdis_Kl=C4=93tnieks?= Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7030693052071403889==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============7030693052071403889== Content-Type: multipart/alternative; boundary="000000000000f747700591b1c7c4" --000000000000f747700591b1c7c4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yeap! That solved the problem. Seems I was not using correctly the checkpatch.pl file. My bad. Now everything seems to be working fine. Thanks for the help! El mar., 3 sept. 2019 a las 7:21, Valdis Kl=C4=93tnieks () escribi=C3=B3: > On Tue, 03 Sep 2019 01:26:17 -0300, Pablo Pellecchia said: > > > *WARNING: struct should normally be const#9: FILE: > > platform_net.h:9:+struct xlr_net_data {* > > > > A similar issue is reported when we declare a variable of type struct > > , but in this case warning is reported on the struct > definition > > itself. > > > > How can we fix this? > > And in today's "How to debug checkpatch" lesson.. :) > > First, figure out if checkpatch is in fact correct. It' just a Perl scrip= t, > and has no real idea of what the code is. > > And double-checking, there's very few 'const struct' declarations in > include/linux/*.h. > > So what's going on? Good question. Actually looking at checkpatch.pl, > we find: > > # check for various structs that are normally const (ops, kgdb, > device_tree) > # and avoid what seem like struct definitions 'struct foo {' > if ($line !~ /\bconst\b/ && > $line =3D~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) = { > WARN("CONST_STRUCT", > "struct $1 should normally be const\n" . > $herecurr); > } > > and $const_structs is initialized from scripts/const_structs.checkpatch > And that tells us 2 things: First, this should only be triggering for > structures > that are listed in that file, and the message *should* say something > like 'struct foo should normally be const', with $1 filling in the struct > name. > > So why is $1 not showing up? Damned good question. And the file > checks just fine for me. > > [/usr/src/linux-next]2 scripts/checkpatch.pl -f > drivers/staging/netlogic/platform_net.h > total: 0 errors, 0 warnings, 0 checks, 21 lines checked > > drivers/staging/netlogic/platform_net.h has no obvious style problems and > is ready for submission. > > Bingo! This is what happens if the permissions on the file are messed up > and it can't read the file: > > [/usr/src/linux-next] scripts/checkpatch.pl -f > drivers/staging/netlogic/platform_net.h > No structs that should be const will be found - file > '/usr/src/linux-next/scripts/const_structs.checkpatch': Permission denied > WARNING: struct should normally be const > #9: FILE: drivers/staging/netlogic/platform_net.h:9: > +struct xlr_net_data { > > So... you probably need to check the permissions, or if the file is missi= ng > from your tree or empty or something. The version in my tree is 64 lines > long. > > Meanwhile, I'm going to go cook up a patch for this.... > > > --000000000000f747700591b1c7c4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yeap! That solved the problem. Seems I was not using = correctly the checkpatch.pl file. My b= ad.

Now everything seems to be working fine.

Thanks for the help!

El mar., 3 sept. 2019 a = las 7:21, Valdis Kl=C4=93tnieks (<valdis.kletnieks@vt.edu>) escribi=C3=B3:
On Tue, 03 Sep 2019 01:26:17 -0300, Pa= blo Pellecchia said:

> *WARNING: struct=C2=A0 should normally be const#9: FILE:
> platform_net.h:9:+struct xlr_net_data {*
>
> A similar issue is reported when we declare a variable of type struct<= br> > <something>, but in this case warning is reported on the struct = definition
> itself.
>
> How can we fix this?

And in today's "How to debug checkpatch" lesson.. :)

First, figure out if checkpatch is in fact correct. It' just a Perl scr= ipt,
and has no real idea of what the code is.

And double-checking, there's very few 'const struct' declaratio= ns in
include/linux/*.h.

So what's going on?=C2=A0 Good question. Actually looking at checkpatch.pl,
we find:

# check for various structs that are normally const (ops, kgdb, device_tree= )
# and avoid what seem like struct definitions 'struct foo {'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ($line !~ /\bcon= st\b/ &&
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $line= =3D~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 WARN("CONST_STRUCT",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"struct $1 should normally be const\n&q= uot; . $herecurr);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }

and $const_structs is initialized from scripts/const_structs.checkpatch And that tells us 2 things:=C2=A0 First, this should only be triggering for= structures
that are listed in that file, and the message *should* say something
like 'struct foo should normally be const', with $1 filling in the = struct name.

So why is $1 not showing up? Damned good question.=C2=A0 And the file
checks just fine for me.

[/usr/src/linux-next]2 scripts/
checkpatch.pl -f drivers/staging/netlogic/pla= tform_net.h
total: 0 errors, 0 warnings, 0 checks, 21 lines checked

drivers/staging/netlogic/platform_net.h has no obvious style problems and i= s ready for submission.

Bingo!=C2=A0 This is what happens if the permissions on the file are messed= up
and it can't read the file:

[/usr/src/linux-next] scripts/checkpatch.pl -f drivers/staging/netlogic/plat= form_net.h
No structs that should be const will be found - file '/usr/src/linux-ne= xt/scripts/const_structs.checkpatch': Permission denied
WARNING: struct=C2=A0 should normally be const
#9: FILE: drivers/staging/netlogic/platform_net.h:9:
+struct xlr_net_data {

So... you probably need to check the permissions, or if the file is missing=
from your tree or empty or something. The version in my tree is 64 lines lo= ng.

Meanwhile, I'm going to go cook up a patch for this....


--000000000000f747700591b1c7c4-- --===============7030693052071403889== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============7030693052071403889==--