[ovs-dev] [PATCH] CodingStyle: Fix indentation.
Ben Pfaff
blp at nicira.com
Fri Nov 16 22:10:27 UTC 2012
Occasionally when I've found it hard to read I'll put the { down a
line, like this:
if (!isdigit((unsigned char)s[0])
|| !isdigit((unsigned char)s[1])
|| !isdigit((unsigned char)s[2]))
{
printf("string %s does not start with 3-digit code\n", s);
}
I'd be open to actually putting that suggestion into the style guide,
if you like it too.
On Fri, Nov 16, 2012 at 11:43:40AM -0800, Justin Pettit wrote:
> Okay, I find that style hard to read with "if" blocks, but I'm sure
> I'll get used to it. I'll update my patch to use that style.
>
> --Justin
>
>
> On Nov 16, 2012, at 11:39 AM, Ben Pfaff <blp at nicira.com> wrote:
>
> > Hmm, the indentation looks different from what I expect in your quote
> > below. (It looks OK to me in the original message I posted.)
> >
> > Here's another look at the style I've always used in OVS, and that I am
> > suggesting to use in CodingStyle, with leading spaces replaced by
> > underscores in case something weird happens again:
> >
> > ____if (!isdigit((unsigned char)s[0])
> > ________|| !isdigit((unsigned char)s[1])
> > ________|| !isdigit((unsigned char)s[2])) {
> > ________printf("string %s does not start with 3-digit code\n", s);
> > ____}
> >
> >
> > On Fri, Nov 16, 2012 at 11:21:44AM -0800, Justin Pettit wrote:
> >> So you're preferred style is for continued if statements to have one
> >> space in from the code block? I'm fine with it, but just want to
> >> confirm.
> >>
> >> --Justin
> >>
> >>
> >> On Nov 16, 2012, at 11:19 AM, Ben Pfaff <blp at nicira.com> wrote:
> >>
> >>> This got changed away from what I actually prefer in commit be2c418b73fc
> >>> (Cleanup isdigit() warnings.).
> >>>
> >>> Signed-off-by: Ben Pfaff <blp at nicira.com>
> >>> ---
> >>> CodingStyle | 4 ++--
> >>> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/CodingStyle b/CodingStyle
> >>> index b0aeb4e..ee7a0e6 100644
> >>> --- a/CodingStyle
> >>> +++ b/CodingStyle
> >>> @@ -432,8 +432,8 @@ precedence makes it necessary, or unless the operands are themselves
> >>> expressions that use && and ||. Thus:
> >>>
> >>> if (!isdigit((unsigned char)s[0])
> >>> - || !isdigit((unsigned char)s[1])
> >>> - || !isdigit((unsigned char)s[2])) {
> >>> + || !isdigit((unsigned char)s[1])
> >>> + || !isdigit((unsigned char)s[2])) {
> >>> printf("string %s does not start with 3-digit code\n", s);
> >>> }
> >>>
> >>> --
> >>> 1.7.10.4
> >>>
> >>> _______________________________________________
> >>> dev mailing list
> >>> dev at openvswitch.org
> >>> http://openvswitch.org/mailman/listinfo/dev
> >>
>
More information about the dev
mailing list