From 199aff8e6d0414a4bceedc502954b8e9cfe9ec18 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 6 Feb 2016 23:34:00 +0000 Subject: Correctly annotate unused variables with a macro --- src/nsgenbind-ast.c | 2 +- src/nsgenbind-parser.y | 7 +++++-- src/utils.h | 9 ++++++++- src/webidl-ast.c | 2 +- src/webidl-parser.y | 5 +++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/nsgenbind-ast.c b/src/nsgenbind-ast.c index 9be8bc7..49732a0 100644 --- a/src/nsgenbind-ast.c +++ b/src/nsgenbind-ast.c @@ -160,7 +160,7 @@ genbind_node_foreach_type(struct genbind_node *node, static int genbind_enumerate_node(struct genbind_node *node, void *ctx) { - node = node; + UNUSED(node); (*((int *)ctx))++; return 0; } diff --git a/src/nsgenbind-parser.y b/src/nsgenbind-parser.y index 7c2f7ce..a970ad2 100644 --- a/src/nsgenbind-parser.y +++ b/src/nsgenbind-parser.y @@ -78,6 +78,7 @@ typedef struct YYLTYPE { (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) +#include "utils.h" #include "nsgenbind-lexer.h" #include "webidl-ast.h" #include "nsgenbind-ast.h" @@ -90,14 +91,16 @@ static void nsgenbind_error(YYLTYPE *locp, const char *str) { int errlen; + + UNUSED(genbind_ast); + UNUSED(filename); + errlen = snprintf(NULL, 0, "%s:%d:%s", locp->filename, locp->first_line, str); errtxt = malloc(errlen + 1); snprintf(errtxt, errlen + 1, "%s:%d:%s", locp->filename, locp->first_line, str); - genbind_ast = genbind_ast; - filename = filename; } static struct genbind_node * diff --git a/src/utils.h b/src/utils.h index a46946a..c9dfd36 100644 --- a/src/utils.h +++ b/src/utils.h @@ -41,6 +41,13 @@ int genb_fclose_tmp(FILE *filef, const char *fname); char *strndup(const char *s, size_t n); #endif -#define SLEN(x) (sizeof((x)) - 1) +#ifndef SLEN +/* Calculate length of a string constant */ +#define SLEN(s) (sizeof((s)) - 1) /* -1 for '\0' */ +#endif + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) +#endif #endif diff --git a/src/webidl-ast.c b/src/webidl-ast.c index 253a3ba..26851c3 100644 --- a/src/webidl-ast.c +++ b/src/webidl-ast.c @@ -173,7 +173,7 @@ int webidl_cmp_node_type(struct webidl_node *node, void *ctx) static int webidl_enumerate_node(struct webidl_node *node, void *ctx) { - node = node; + UNUSED(node); (*((int *)ctx))++; return 0; } diff --git a/src/webidl-parser.y b/src/webidl-parser.y index b48b449..ec3309c 100644 --- a/src/webidl-parser.y +++ b/src/webidl-parser.y @@ -26,6 +26,7 @@ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) +#include "utils.h" #include "webidl-parser.h" #include "webidl-lexer.h" @@ -36,8 +37,8 @@ char *errtxt; static void webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str) { - locp = locp; - winbind_ast = winbind_ast; + UNUSED(locp); + UNUSED(winbind_ast); errtxt = strdup(str); } -- cgit v1.2.3