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: <fd3b2d10912030718q30176616r1ac3b71a4399fc0b@mail.gmail.com>
Date:	Thu, 3 Dec 2009 08:18:11 -0700
From:	Joe Peterson <joe@...rush.com>
To:	Cong Wang <amwang@...hat.com>
Cc:	Alan Cox <alan@...ux.intel.com>, linux-kernel@...r.kernel.org,
	akpm@...ux-foundation.org, Greg Kroah-Hartman <gregkh@...e.de>
Subject: Re: [Patch] tty: move a definition out of switch block

On Thu, Dec 3, 2009 at 01:36, Cong Wang <amwang@...hat.com> wrote:
> Generally putting variables local in the local scope is fine, but
> not for 'switch' block, to be more precisely, not for the case
> where putting local variables between 'switch' and its _first_
> label, IMO.

It is fine to declare variables at the start of a switch statement.
What *is* incorrect is either initializing such declared variables
(they won't get initialized) or declaring variables *after* a case
label (throws a compile error).

> It can lead to misunderstanding easily, since 'switch'
> jumps to its first label at a first glance. I know in this case
> the code is _not_ wrong, but again, it's not good for reading.

I would think the declaration inside the start of the switch block
would just indicate to the reader that the variable is local to the
switch block scope.

> Also, there's no conflicts if we put it out of 'switch' block.

But then the scope of these variables becomes larger than it need be.

-Joe
--
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