Skip to content

va_start and va_end should be in one block of code #154

Description

@rockdaboot

In printbuf.c, sprintbuf() this piece of code might not compile or work as expected everywhere:

va_start(ap, msg);
if((size = vasprintf(&t, msg, ap)) < 0) { va_end(ap); return -1; }
va_end(ap);

From the man page:

On some systems, va_end contains a closing '}' matching a '{' in va_start, so that both macros must  occur  in the same function, and in a way that allows this.

Should be

va_start(ap, msg);
size = vasprintf(&t, msg, ap);
va_end(ap);
if(size < 0) return -1;

I didn't check if that kind of code is used somewhere - it was just a random encounter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions