Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 24 May 2012 17:41:33 +0400
From: Solar Designer <solar@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: declarations intermixed with statements (was: allocating salts)

On Thu, May 24, 2012 at 08:04:00AM -0500, jfoug wrote:
> As a final item to some of your coding Dhiru, please declare all variables
> at the top of blocks, and only at the top of blocks.  There are compilers
> that when compiling C programs will only allow declarations at top of a
> block, prior to any code.  Just because gcc allows a variable to be declared
> at an arbitrary location in C compiles does not mean that all compilers
> allow this.

Yes, let's avoid such intermixed declarations and statements.  I avoid
them in the main JtR tree.  gcc has this warning option, which we may
want to enable:

       -Wdeclaration-after-statement (C and Objective-C only)
           Warn when a declaration is found after a statement in a block.
           This construct, known from C++, was introduced with ISO C99 and is
           by default allowed in GCC.  It is not supported by ISO C90 and was
           not supported by GCC versions before GCC 3.0.

Let's be using extra blocks for limiting scope of variables where
desired - e.g., I do that in rules.c: rules_apply().

Alexander

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.