|
Message-ID: <CABtNtWGTVpsJOgGe02en8ce9VOhcixJUhHt3fyZApyv5E3W1-w@mail.gmail.com>
Date: Mon, 27 Jul 2015 11:08:47 +0800
From: Kai Zhao <loverszhao@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: Coding Style
Hi magnum,
> On Sat, Jul 25, 2015 at 10:41 PM, magnum
> <john.magnum@...hmail.com> wrote:
>
> On 2015-07-25 15:05, Kai Zhao wrote:
>>
>> There are some rules that some people like while others don't. I am very
>> glad to get your advice for each rules whether agree or disagree.Thus, I
>> can finish this coding style documentation and there are less coding
style
>> problems.
>
>
> Here are my two cents. In general I think we should should have a terse
> and liberal code style, allowing some variations (details below).
>
>> 3.2 Spaces
>>
>> 3.2.1 Use a space after (most) keywords.
>
>
> OK.
>
>> 3.2.2 Do not add spaces around (inside) parenthesized expressions.
>>
>> This example is *bad*:
>>
>> s = sizeof( struct file );
>
>
> I never write it like that but maybe we should be more liberal here.
In order to use a automated formatter, I think we should recommend
the:
s = sizeof(struct file);
>> 3.2.4 When type conversion, add a space before '*'.
>>
>> E.g:
>>
>> hostSalt = (cl_uint *) mem_alloc(SALT_BUFFER_SIZE);
>
>
> I personally disagree. We should mandate NOT adding a space,
> or just be liberal about it. Actually I always drop the space after
> the paren too:
>
> hostSalt = (cl_uint*)mem_alloc(SALT_BUFFER_SIZE);
>
> I think we should allow (not require) a space after the paren, and
> either allow or require that there's space before the '*'.
>
Here, I do't know how to choose ? But, if we use 'indent', it will add
a space before '*', and after ')'.
indent -kr -i8 -ts8 -nlp -ci4 -nbbo -ncs -l80 -lc80 -bad -il0 test.c
hostSalt = (cl_uint *) mem_alloc(SALT_BUFFER_SIZE);
>
>> Chapter 6: Functions
>
>
> Our code style should not be a programming tutorial. IMHO drop
> all of chapter 6.
>
What do you think on 6.4 ?
Thanks,
Kai
Content of type "text/html" skipped
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.