test: fix missing va_end in case of test failures

Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
master
Peter Hutterer 2021-03-18 11:13:43 +10:00 committed by Ran Benita
parent 7a205e25ac
commit 694b8f7127
1 changed files with 15 additions and 6 deletions

View File

@ -282,18 +282,21 @@ find_models(struct rxkb_context *ctx, ...)
va_list args; va_list args;
const char *name; const char *name;
int idx = 0; int idx = 0;
bool rc = false;
va_start(args, ctx); va_start(args, ctx);
name = va_arg(args, const char *); name = va_arg(args, const char *);
while(name) { while(name) {
assert(++idx < 20); /* safety guard */ assert(++idx < 20); /* safety guard */
if (!find_model(ctx, name)) if (!find_model(ctx, name))
return false; goto out;
name = va_arg(args, const char *); name = va_arg(args, const char *);
}; };
rc = true;
out:
va_end(args); va_end(args);
return true; return rc;
} }
static struct rxkb_layout * static struct rxkb_layout *
@ -326,6 +329,7 @@ find_layouts(struct rxkb_context *ctx, ...)
va_list args; va_list args;
const char *name, *variant; const char *name, *variant;
int idx = 0; int idx = 0;
bool rc = false;
va_start(args, ctx); va_start(args, ctx);
name = va_arg(args, const char *); name = va_arg(args, const char *);
@ -333,14 +337,16 @@ find_layouts(struct rxkb_context *ctx, ...)
while(name) { while(name) {
assert(++idx < 20); /* safety guard */ assert(++idx < 20); /* safety guard */
if (!find_layout(ctx, name, variant)) if (!find_layout(ctx, name, variant))
return false; goto out;
name = va_arg(args, const char *); name = va_arg(args, const char *);
if (name) if (name)
variant = va_arg(args, const char *); variant = va_arg(args, const char *);
}; };
rc = true;
out:
va_end(args); va_end(args);
return true; return rc;
} }
static struct rxkb_option_group * static struct rxkb_option_group *
@ -396,6 +402,7 @@ find_options(struct rxkb_context *ctx, ...)
va_list args; va_list args;
const char *grp, *opt; const char *grp, *opt;
int idx = 0; int idx = 0;
bool rc = false;
va_start(args, ctx); va_start(args, ctx);
grp = va_arg(args, const char *); grp = va_arg(args, const char *);
@ -403,14 +410,16 @@ find_options(struct rxkb_context *ctx, ...)
while(grp) { while(grp) {
assert(++idx < 20); /* safety guard */ assert(++idx < 20); /* safety guard */
if (!find_option(ctx, grp, opt)) if (!find_option(ctx, grp, opt))
return false; goto out;
grp = va_arg(args, const char *); grp = va_arg(args, const char *);
if (grp) if (grp)
opt = va_arg(args, const char *); opt = va_arg(args, const char *);
}; };
rc = true;
out:
va_end(args); va_end(args);
return true; return rc;
} }
static bool static bool