[igt-dev] [PATCH i-g-t] assembler: Fix or suppress clang warnings
Chris Wilson
chris at chris-wilson.co.uk
Sun Jan 31 10:26:13 UTC 2021
For the simple assigment of constant strings to a char*, fix the type.
For the autogenerated bison output, tell gcc/clang to ignore the
warnings.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
assembler/brw_context.h | 2 +-
assembler/gen4asm.h | 2 +-
assembler/gen8_disasm.c | 2 ++
assembler/gram.y | 2 ++
assembler/lex.l | 2 +-
assembler/main.c | 2 +-
assembler/ralloc.c | 2 ++
7 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/assembler/brw_context.h b/assembler/brw_context.h
index 90e66f714..335234e37 100644
--- a/assembler/brw_context.h
+++ b/assembler/brw_context.h
@@ -62,7 +62,7 @@ brw_init_context(struct brw_context *brw, int gen);
/* brw_disasm.c */
struct opcode_desc {
- char *name;
+ const char *name;
int nsrc;
int ndst;
};
diff --git a/assembler/gen4asm.h b/assembler/gen4asm.h
index 9537d4573..b1680ebc7 100644
--- a/assembler/gen4asm.h
+++ b/assembler/gen4asm.h
@@ -46,7 +46,7 @@ extern int errors;
#define WARN_ALL (1 << 31)
extern unsigned int warning_flags;
-extern char *input_filename;
+extern const char *input_filename;
extern struct brw_context genasm_context;
extern struct brw_compile genasm_compile;
diff --git a/assembler/gen8_disasm.c b/assembler/gen8_disasm.c
index 68bc03347..99b062ea3 100644
--- a/assembler/gen8_disasm.c
+++ b/assembler/gen8_disasm.c
@@ -31,6 +31,8 @@
#include "brw_defines.h"
#include "gen8_instruction.h"
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static const struct opcode_desc *m_opcode = opcode_descs;
static const char *const m_conditional_modifier[16] = {
diff --git a/assembler/gram.y b/assembler/gram.y
index d6f4a195b..77975e072 100644
--- a/assembler/gram.y
+++ b/assembler/gram.y
@@ -36,6 +36,8 @@
#include "brw_eu.h"
#include "gen8_instruction.h"
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
#define DEFAULT_EXECSIZE (ffs(program_defaults.execute_size) - 1)
#define DEFAULT_DSTREGION -1
diff --git a/assembler/lex.l b/assembler/lex.l
index 1ba576bfe..c12c5054c 100644
--- a/assembler/lex.l
+++ b/assembler/lex.l
@@ -7,7 +7,7 @@
#include "string.h"
int saved_state = 0;
-extern char *input_filename;
+extern const char *input_filename;
/* Locations */
int yycolumn = 1;
diff --git a/assembler/main.c b/assembler/main.c
index a1eca5251..2d39d4536 100644
--- a/assembler/main.c
+++ b/assembler/main.c
@@ -45,7 +45,7 @@ long int gen_level = 40;
int advanced_flag = 0; /* 0: in unit of byte, 1: in unit of data element size */
unsigned int warning_flags = WARN_ALWAYS;
int need_export = 0;
-char *input_filename = "<stdin>";
+const char *input_filename = "<stdin>";
int errors;
struct brw_context genasm_brw_context;
diff --git a/assembler/ralloc.c b/assembler/ralloc.c
index 69c1da4d3..772c34448 100644
--- a/assembler/ralloc.c
+++ b/assembler/ralloc.c
@@ -36,6 +36,8 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr);
#include "ralloc.h"
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
#ifndef va_copy
#ifdef __va_copy
#define va_copy(dest, src) __va_copy((dest), (src))
--
2.30.0
More information about the igt-dev
mailing list