va_start and va_end should be in one block of code
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 61
- Forks
- 35
- Avg merge
- 21m
- Merged PRs (30d)
- 2
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open printbuf.c and inspect sprintbuf() around the va_start, vasprintf, and va_end calls. Search the file for other va_start/va_end usage and check the project's build or tests if available. Done means the variadic macros are used in a portable arrangement and the library still builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100