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] [day] [month] [year] [list]
Date:   Sat, 29 Oct 2022 11:47:31 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Alexey Dobriyan' <adobriyan@...il.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>
CC:     "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "catalin.marinas@....com" <catalin.marinas@....com>,
        "will@...nel.org" <will@...nel.org>,
        "rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>,
        "masahiroy@...nel.org" <masahiroy@...nel.org>
Subject: RE: [PATCH] kbuild: drop -Wdeclaration-after-statement

From: Alexey Dobriyan
> Sent: 28 October 2022 21:55
> 
> On Fri, Oct 28, 2022 at 01:29:08PM -0700, Linus Torvalds wrote:
> > On Fri, Oct 28, 2022 at 1:00 PM Alexey Dobriyan <adobriyan@...il.com> wrote:
> > >
> > > Putting declarations in the beginning of the block is an afterfact from
> > > single pass compiler era. Compiler would parse all declarations, layout
> > > stack frame and proceed to generate code.
> >
> > No, putting declarations at the beginning is still kernel syntax.
> >
> > Don't declare variables in multiple places. It gets really confusing.
> 
> It is not. Somehow millions of programmers manage to find their
> variables just fine in C and other programming languages.

Have you ever tried it when -Wshadow isn't enabled and variables
with the same name are redefined in the middle of blocks?

C++ has to allow it (and it is annoying to find definitions)
because the initialiser has to be called.
But you can't use a 'goto' to jump past a declaration.

> > Put all declarations at the top of the block they are contained in.

Or better, either at the top of the function or in a small block
(where the limited scope is absolutely obvious).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ