Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/lang.c: 2 * bad parameter to va_start ? #68

Closed
dcb314 opened this issue Nov 29, 2018 · 4 comments
Closed

src/lang.c: 2 * bad parameter to va_start ? #68

dcb314 opened this issue Nov 29, 2018 · 4 comments

Comments

@dcb314
Copy link

dcb314 commented Nov 29, 2018

src/lang.c:59]: (warning) 'msgstr' given to va_start() is not last named argument of the function. Did you intend to pass 'msgid'?

Source code is

int lang_print(FILE *const file, const enum MessageID msgid, ...) {
char *msgstr = lang_getmsg(msgid);
if(msgstr == NULL) return -1;

    va_list args;
    va_start(args, msgstr);

Also:

src/lang.c:71]: (warning) 'msgstr' given to va_start() is not last named argument of the function. Did you intend to pass 'number'?

Duplicate.

@suve
Copy link
Owner

suve commented Nov 30, 2018

This is as intended - lang_print() takes a message ID as a parameter, whereas va_start() expects a format string. The ID is resolved to a message string via the lang_getmsg() call.

Apart from adding some comments saying "this will emit a warning, this is intended", or maybe some #pragma GCC directives, I don't really see what can be changed here.

@dcb314
Copy link
Author

dcb314 commented Nov 30, 2018

Suggest look again. I checked the reference manual for C and the only thing va_start
is documented to work with is the last named parameter. This is different to the local variable
it is given in your code.

@suve
Copy link
Owner

suve commented Nov 30, 2018

Oh, truly. For whatever reason I was convinced that va_start() expects a format string, like printf(). Though thinking about it now, that wouldn't make much sense.

@suve
Copy link
Owner

suve commented Nov 30, 2018

Fixed in f55e41b.

@suve suve closed this as completed Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants