lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4FBC505A.9000102@gmail.com>
Date:	Wed, 23 May 2012 12:50:02 +1000
From:	Ryan Mallon <rmallon@...il.com>
To:	Joe Perches <joe@...ches.com>
CC:	Phil Carmody <ext-phil.2.carmody@...ia.com>,
	linux-kernel@...r.kernel.org, apw@...onical.com
Subject: Re: [PATCH 1/1] checkpatch: don't fake typedefs with #define

On 23/05/12 12:02, Joe Perches wrote:

> On Wed, 2012-05-23 at 11:54 +1000, Ryan Mallon wrote:
>> On 18/05/12 07:16, Phil Carmody wrote:
>>> Too many. Alas I can't share them. 
>> That sounds like the cases you have seen are in code which is not
>> public. I don't think I have ever seen code in the kernel, or in
>> proposed patches which fakes a typedef with a #define.
>>
>> Is this an issue for public code, or for a private company tree? In the
>> latter case, the checkpatch addition should go in your private tree,
>> rather than mainline. It looks like, at least for mainline Linux, you
>> are trying to solve a non-existent problem.
> 
> I agree it's pretty rare.
> 
> $ git grep -E "#\s*define\s+\w+\s+(struct|union)\b"|wc -l
> 57


Some of those do look a bit broken, or easily replaced by typedefs.
Several of them appear to be completely unused. However some of them
look like they need to be defines. The ones in include/net/netfilter are
defines because of this:

  #define nf_ct_ext_find(ext, id) \
          ((id##_TYPE *)__nf_ct_ext_find((ext), (id)))

This one:

  #define __videocard struct card_info
    __attribute__((section(".videocards")))

I'm guessing is because typedefs don't handle __attribute__.

The YYLTYPE one in scripts/dtc/srcpos.h I think is a requirement of
Yacc/Bison.

The acpi_cache_t looks a bit odd, but it is doing an ifdef acpi_cache_t
test (quick glance - looks like it allows a platform specific
definition), though that could probably be reworked to use a typedef and
a __ACPI_CACHE_T_DEFINED or something.

So there are some legitimate reasons for using #define instead of typedef.

However, my real point was that I don't think the problem is rampant. 57
instances across the kernel is not that many, and I haven't seen a lot
of patches trying to add code with #defines where typedefs should be
used. We could test for lots of things in checkpatch, but it seems more
sensible to check for issues which are likely.

~Ryan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ