Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
wayland.3007
0003-scanner-Make-fail-function-use-va_list-and...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0003-scanner-Make-fail-function-use-va_list-and-elaborate.patch of Package wayland.3007
From 5a4dd7649553524b3229038b351d24f87f3e5740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= <krh@bitplanet.net> Date: Fri, 15 Nov 2013 14:29:40 -0800 Subject: [PATCH] scanner: Make fail() function use va_list and elaborate a few errors --- src/scanner.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 81ca1f6..a96d3e7 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -255,10 +255,16 @@ desc_dump(char *desc, const char *fmt, ...) } static void -fail(struct location *loc, const char *msg) +fail(struct location *loc, const char *msg, ...) { - fprintf(stderr, "%s:%d: error: %s\n", - loc->filename, loc->line_number, msg); + va_list ap; + + va_start(ap, msg); + fprintf(stderr, "%s:%d: error: ", + loc->filename, loc->line_number); + vfprintf(stderr, msg, ap); + fprintf(stderr, "\n"); + va_end(ap); exit(EXIT_FAILURE); } @@ -378,7 +384,8 @@ start_element(void *data, const char *element_name, const char **atts) if (since != NULL) { version = strtol(since, &end, 0); if (errno == EINVAL || end == since || *end != '\0') - fail(&ctx->loc, "invalid integer\n"); + fail(&ctx->loc, + "invalid integer (%s)\n", since); if (version < ctx->interface->since) fail(&ctx->loc, "since version not increasing\n"); ctx->interface->since = version; @@ -414,7 +421,7 @@ start_element(void *data, const char *element_name, const char **atts) } else if (strcmp(type, "object") == 0) { arg->type = OBJECT; } else { - fail(&ctx->loc, "unknown type"); + fail(&ctx->loc, "unknown type (%s)", type); } switch (arg->type) { @@ -431,7 +438,7 @@ start_element(void *data, const char *element_name, const char **atts) break; default: if (interface_name != NULL) - fail(&ctx->loc, "interface not allowed"); + fail(&ctx->loc, "interface attribute not allowed for type %s", type); break; } @@ -440,7 +447,7 @@ start_element(void *data, const char *element_name, const char **atts) else if (strcmp(allow_null, "true") == 0) arg->nullable = 1; else - fail(&ctx->loc, "invalid value for allow-null attribute"); + fail(&ctx->loc, "invalid value for allow-null attribute (%s)", allow_null); if (allow_null != NULL && !is_nullable_type(arg)) fail(&ctx->loc, "allow-null is only valid for objects, strings, and arrays"); -- 2.8.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor