Fix bison 2.6 and clang warnings Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/src/list.h b/src/list.h
index 6ad384c..c15a78b 100644
--- a/src/list.h
+++ b/src/list.h
@@ -293,7 +293,7 @@ list_replace(struct list *old, struct list *new)
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) \
- - ((char *)&(sample)->member - (char *)(sample)))
+ - offsetof(__typeof(*sample), member))
/**
* Loop through the list given by head and set pos to struct in the list.
*
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index 2744881..ba26fde 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -28,6 +28,8 @@
#include "xkbcomp-priv.h"
#include "parseutils.h"
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+
extern int yylex(union YYSTYPE *val, struct YYLTYPE *loc, void *scanner);
#define scanner param->scanner
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index c767b71..02501f1 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -30,7 +30,6 @@
#include <stdio.h>
#include "xkbcomp-priv.h"
-#include "parser.h"
struct parser_param {
struct xkb_context *ctx;
@@ -38,6 +37,8 @@ struct parser_param {
XkbFile *rtrn;
};
+#include "parser.h"
+
struct scanner_extra {
char *scanFile;
char scanBuf[1024];
diff --git a/src/xkbcomp/scanner.l b/src/xkbcomp/scanner.l
index daf233a..39e8759 100644
--- a/src/xkbcomp/scanner.l
+++ b/src/xkbcomp/scanner.l
@@ -30,6 +30,9 @@
#include "xkbcomp-priv.h"
#include "parseutils.h"
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#pragma GCC diagnostic ignored "-Wmissing-noreturn"
+
extern int yyparse(struct parser_param *param);
#define YY_USER_ACTION { \
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index e2ce206..3af053d 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -824,7 +824,8 @@ AddSymbolsToKey(KeyInfo *keyi, struct xkb_keymap *keymap,
{
xkb_group_index_t ndx;
size_t nSyms, nLevels;
- size_t i, j;
+ size_t i;
+ int j;
if (!GetGroupIndex(keyi, keymap, arrayNdx, SYMBOLS, &ndx))
return false;
@@ -1544,7 +1545,7 @@ PrepareKeyDef(KeyInfo *keyi)
defined = keyi->symsDefined | keyi->actsDefined | keyi->typesDefined;
/* get highest group number */
- for (i = XkbNumKbdGroups - 1; i >= 0; i--) {
+ for (i = XkbNumKbdGroups - 1; i > 0; i--) {
if (defined & (1 << i))
break;
}