kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* checkpatch.pl false positive?
@ 2020-04-02 12:08 Michele Sorcinelli
  2020-04-02 12:13 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Michele Sorcinelli @ 2020-04-02 12:08 UTC (permalink / raw)
  To: kernelnewbies

I tried to run the checkpatch.pl script as follows:

	scripts/checkpatch.pl -f drivers/hwmon/dell-smm-hwmon.c

And I noticed this kind of warnings:

	WARNING: Missing a blank line after declarations
	#122: FILE: drivers/hwmon/dell-smm-hwmon.c:122:
	+       unsigned int eax;
	+       unsigned int ebx __packed;

	WARNING: Missing a blank line after declarations
	#123: FILE: drivers/hwmon/dell-smm-hwmon.c:123:
	+       unsigned int ebx __packed;
	+       unsigned int ecx __packed;

The offending code looks like this:

	struct smm_regs {
		unsigned int eax;
		unsigned int ebx __packed;
		unsigned int ecx __packed;
		unsigned int edx __packed;
		unsigned int esi __packed;
		unsigned int edi __packed;
	};

It looks like a false positive as it excepts a blank line after every struct
field declaration.

Should it be reported to the checkpatch.pl maintainers?


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: checkpatch.pl false positive?
  2020-04-02 12:08 checkpatch.pl false positive? Michele Sorcinelli
@ 2020-04-02 12:13 ` Greg KH
  2020-04-02 12:16   ` Michele Sorcinelli
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2020-04-02 12:13 UTC (permalink / raw)
  To: Michele Sorcinelli; +Cc: kernelnewbies

On Thu, Apr 02, 2020 at 01:08:01PM +0100, Michele Sorcinelli wrote:
> I tried to run the checkpatch.pl script as follows:
> 
> 	scripts/checkpatch.pl -f drivers/hwmon/dell-smm-hwmon.c
> 
> And I noticed this kind of warnings:
> 
> 	WARNING: Missing a blank line after declarations
> 	#122: FILE: drivers/hwmon/dell-smm-hwmon.c:122:
> 	+       unsigned int eax;
> 	+       unsigned int ebx __packed;
> 
> 	WARNING: Missing a blank line after declarations
> 	#123: FILE: drivers/hwmon/dell-smm-hwmon.c:123:
> 	+       unsigned int ebx __packed;
> 	+       unsigned int ecx __packed;
> 
> The offending code looks like this:
> 
> 	struct smm_regs {
> 		unsigned int eax;
> 		unsigned int ebx __packed;
> 		unsigned int ecx __packed;
> 		unsigned int edx __packed;
> 		unsigned int esi __packed;
> 		unsigned int edi __packed;
> 	};
> 
> It looks like a false positive as it excepts a blank line after every struct
> field declaration.
> 
> Should it be reported to the checkpatch.pl maintainers?

No, the structure should be changed to actually be correct, as that is
not how it should be declared in order to not have any padding between
variables in the structure :)

But note, running checkpatch on code outside of drivers/staging/ is not
always welcome by some subsystem maintainers, so be careful about doing
lots of these types of changes in subsystems you do not have experience
contributing to.

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: checkpatch.pl false positive?
  2020-04-02 12:13 ` Greg KH
@ 2020-04-02 12:16   ` Michele Sorcinelli
  2020-04-02 13:21     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Michele Sorcinelli @ 2020-04-02 12:16 UTC (permalink / raw)
  To: Greg KH; +Cc: kernelnewbies

On 4/2/20 1:13 PM, Greg KH wrote:
> No, the structure should be changed to actually be correct, as that is
> not how it should be declared in order to not have any padding between
> variables in the structure :)

What would be the correct way of declaring that structure?


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: checkpatch.pl false positive?
  2020-04-02 12:16   ` Michele Sorcinelli
@ 2020-04-02 13:21     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2020-04-02 13:21 UTC (permalink / raw)
  To: Michele Sorcinelli; +Cc: kernelnewbies

On Thu, Apr 02, 2020 at 01:16:27PM +0100, Michele Sorcinelli wrote:
> On 4/2/20 1:13 PM, Greg KH wrote:
> > No, the structure should be changed to actually be correct, as that is
> > not how it should be declared in order to not have any padding between
> > variables in the structure :)
> 
> What would be the correct way of declaring that structure?
> 

See any of the structures in include/linux/* that have:
	} __packed;
as their closing bracket.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-02 13:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 12:08 checkpatch.pl false positive? Michele Sorcinelli
2020-04-02 12:13 ` Greg KH
2020-04-02 12:16   ` Michele Sorcinelli
2020-04-02 13:21     ` Greg KH

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).