Discussion:
[PATCH] module-verifier: make it possible to run checkers on grub-module-verifierxx.c
(too old to reply)
Peter Jones
2018-08-01 14:34:55 UTC
Permalink
This makes it so you can treat grub-module-verifierxx.c as a file you can
build directly, so syntax checkers like vim's "syntastic" plugin, which uses
"gcc -x c -fsyntax-only" to build it, will work.

One still has to do whatever setup is required to make it pick the right
include dirs, which -W options we use, etc., but this makes it so you can do
the checking on the file you're editing, rather than on a different file.

Signed-off-by: Peter Jones <***@redhat.com>
---
util/grub-module-verifier32.c | 2 ++
util/grub-module-verifier64.c | 2 ++
util/grub-module-verifierXX.c | 9 +++++++++
3 files changed, 13 insertions(+)

diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c
index 257229f8f08..ba7d41aafea 100644
--- a/util/grub-module-verifier32.c
+++ b/util/grub-module-verifier32.c
@@ -1,2 +1,4 @@
#define MODULEVERIFIER_ELF32 1
+#ifndef GRUB_MODULE_VERIFIERXX
#include "grub-module-verifierXX.c"
+#endif
diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c
index 4db6b4bedd1..fc23ef800b3 100644
--- a/util/grub-module-verifier64.c
+++ b/util/grub-module-verifier64.c
@@ -1,2 +1,4 @@
#define MODULEVERIFIER_ELF64 1
+#ifndef GRUB_MODULE_VERIFIERXX
#include "grub-module-verifierXX.c"
+#endif
diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c
index 1feaafc9b9e..b7025e9e418 100644
--- a/util/grub-module-verifierXX.c
+++ b/util/grub-module-verifierXX.c
@@ -1,3 +1,12 @@
+#define GRUB_MODULE_VERIFIERXX
+#if !defined(MODULEVERIFIER_ELF32) && !defined(MODULEVERIFIER_ELF64)
+#if __SIZEOF_POINTER__ == 8
+#include "grub-module-verifier64.c"
+#else
+#include "grub-module-verifier64.c"
+#endif
+#endif
+
#include <string.h>

#include <grub/elf.h>
--
2.17.1
Peter Jones
2018-08-02 14:36:33 UTC
Permalink
This makes it so you can treat grub-module-verifierxx.c as a file you can
build directly, so syntax checkers like vim's "syntastic" plugin, which uses
"gcc -x c -fsyntax-only" to build it, will work.

One still has to do whatever setup is required to make it pick the right
include dirs, which -W options we use, etc., but this makes it so you can do
the checking on the file you're editing, rather than on a different file.

v2: fix the typo in the #else clause in util/grub-module-verifierXX.c

Signed-off-by: Peter Jones <***@redhat.com>
---
util/grub-module-verifier32.c | 2 ++
util/grub-module-verifier64.c | 2 ++
util/grub-module-verifierXX.c | 9 +++++++++
3 files changed, 13 insertions(+)

diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c
index 257229f8f08..ba7d41aafea 100644
--- a/util/grub-module-verifier32.c
+++ b/util/grub-module-verifier32.c
@@ -1,2 +1,4 @@
#define MODULEVERIFIER_ELF32 1
+#ifndef GRUB_MODULE_VERIFIERXX
#include "grub-module-verifierXX.c"
+#endif
diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c
index 4db6b4bedd1..fc23ef800b3 100644
--- a/util/grub-module-verifier64.c
+++ b/util/grub-module-verifier64.c
@@ -1,2 +1,4 @@
#define MODULEVERIFIER_ELF64 1
+#ifndef GRUB_MODULE_VERIFIERXX
#include "grub-module-verifierXX.c"
+#endif
diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c
index 1feaafc9b9e..597ded14362 100644
--- a/util/grub-module-verifierXX.c
+++ b/util/grub-module-verifierXX.c
@@ -1,3 +1,12 @@
+#define GRUB_MODULE_VERIFIERXX
+#if !defined(MODULEVERIFIER_ELF32) && !defined(MODULEVERIFIER_ELF64)
+#if __SIZEOF_POINTER__ == 8
+#include "grub-module-verifier64.c"
+#else
+#include "grub-module-verifier32.c"
+#endif
+#endif
+
#include <string.h>

#include <grub/elf.h>
--
2.17.1
Daniel Kiper
2018-09-03 15:40:22 UTC
Permalink
Post by Peter Jones
This makes it so you can treat grub-module-verifierxx.c as a file you can
build directly, so syntax checkers like vim's "syntastic" plugin, which uses
"gcc -x c -fsyntax-only" to build it, will work.
One still has to do whatever setup is required to make it pick the right
include dirs, which -W options we use, etc., but this makes it so you can do
s/-W/-I/?
Post by Peter Jones
the checking on the file you're editing, rather than on a different file.
v2: fix the typo in the #else clause in util/grub-module-verifierXX.c
If apply your patch and call this:

gcc -x c -fsyntax-only -Iinclude -I. util/grub-module-verifierXX.c

I see following warnings:

util/grub-module-verifierXX.c:49:0: warning: "ELF_R_SYM" redefined [enabled by default]
In file included from util/grub-module-verifierXX.c:12:0:
include/grub/elf.h:2498:0: note: this is the location of the previous definition
util/grub-module-verifierXX.c:50:0: warning: "ELF_R_TYPE" redefined [enabled by default]
In file included from util/grub-module-verifierXX.c:12:0:
include/grub/elf.h:2499:0: note: this is the location of the previous definition
util/grub-module-verifierXX.c:51:0: warning: "ELF_ST_TYPE" redefined [enabled by default]
In file included from util/grub-module-verifierXX.c:12:0:
include/grub/elf.h:2495:0: note: this is the location of the previous definition

Should not we drop ELF_R_SYM, ELF_R_TYPE and ELF_ST_TYPE definitions for
64-bits from util/grub-module-verifierXX.c?

Daniel

Continue reading on narkive:
Loading...