[go: up one dir, main page]

Skip to content

Incorrect indent-label formatting when C function returns struct

Astyle 3.4.10

.astylerc:

style=kr
mode=c
lineend=linux

indent=spaces=4
indent-switches
indent-preproc-define
indent-col1-comments

pad-oper
pad-comma
pad-header

unpad-paren

squeeze-lines=1

break-one-line-headers
break-after-logical

keep-one-line-blocks
keep-one-line-statements

align-pointer=name
align-reference=name

attach-extern-c
attach-closing-while
attach-return-type
attach-return-type-decl

convert-tabs

min-conditional-indent=0
max-continuation-indent=80
max-code-length=100

My .astylerc doesn't have the indent-labels option, so labels shouldn't be indented. And that's how it is for normal functions, but when the function returns struct, then labels are indented:

static struct foo *foo_new(void)
{
    struct foo *bar = malloc(123);

    if (!bar)
        goto error;

    return bar;

    error:
    return NULL;
}

Label error: was indented by astyle.

If change the function to return int, then everything works as expected:

static int *foo_new(void)
{
    int *bar = malloc(123);

    if (!bar)
        goto error;

    return bar;

error:
    return NULL;
}
Edited by pavelxdd