Compilation fixes for GCC 7
cover Compilation fixes for GCC 7
Some compilation fixes for GCC 7, done in Fedora 26 environment.
This isn't complete yet - some compilation issues are still there (more on it in separate thread), but those patches do solve some problems.
Additionally Xen 4.6 - 4.8 (haven't checked others) require those patches to be backported:
796dea3 tools: include sys/sysmacros.h on Linux
f49fa65 tools:misc:xenlockprof: fix possible format string overflow
Marek Marczykowski-Górecki (3):
stubdom: fix vtpm compilation on GCC-7
tools/xenpmd: fix potential string truncation
Disable -Wint-in-bool-context
Config.mk | 1 + stubdom/Makefile | 1 + stubdom/vtpm-implicit-fallthrough.patch | 10 ++++++++++ tools/xenpmd/xenpmd.c | 8 ++++---- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 stubdom/vtpm-implicit-fallthrough.patch
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/3 stubdom: fix vtpm compilation on GCC-7
GCC-7 have -Wimplicit-fallthrough enabled with -Wextra. Add appropriate comment which both mute the warning and improve readibility.
--- stubdom/Makefile | 1 + stubdom/vtpm-implicit-fallthrough.patch | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 stubdom/vtpm-implicit-fallthrough.patch
stubdom/Makefile +1 -0
@@ -228,6 +228,7 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz patch -d $@ -p1 < vtpm-deepquote.patch patch -d $@ -p1 < vtpm-deepquote-anyloc.patch patch -d $@ -p1 < vtpm-cmake-Wextra.patch + patch -d $@ -p1 < vtpm-implicit-fallthrough.patch mkdir $@/build cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement" touch $@
stubdom/vtpm-implicit-fallthrough.patch new file +10 -0
@@ -0,0 +1,10 @@ +--- tpm_emulator-x86_64/tpm/tpm_cmd_handler.c.orig 2017-04-27 13:37:14.408000000 +0200 ++++ tpm_emulator-x86_64/tpm/tpm_cmd_handler.c 2017-04-27 13:39:53.585000000 +0200 +@@ -3397,6 +3397,7 @@ + sizeof(rsp->auth2->nonceOdd.nonce)); + tpm_hmac_update(&hmac, (BYTE*)&rsp->auth2->continueAuthSession, 1); + tpm_hmac_final(&hmac, rsp->auth2->auth); ++ /* fall-thru */ + case TPM_TAG_RSP_AUTH1_COMMAND: + tpm_hmac_init(&hmac, rsp->auth1->secret, sizeof(rsp->auth1->secret)); + tpm_hmac_update(&hmac, rsp->auth1->digest, sizeof(rsp->auth1->digest));
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 1/3] stubdom: fix vtpm compilation on GCC-7
Quoted 4 lines · Marek Marczykowski-Górecki
GCC-7 have -Wimplicit-fallthrough enabled with -Wextra. Add appropriate comment which both mute the warning and improve readibility.
Signed-off-by Marek Marczykowski-Górecki <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/3 tools/xenpmd: fix potential string truncation
In reply to Marek Marczykowski-GóreckiGCC 7 warns (and thanks to -Werror, fails) about potential string truncation by snprintf in get_next_battery_file. Since the code already check if string is no longer than 4 chars, tell gcc about it.
--- tools/xenpmd/xenpmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/xenpmd/xenpmd.c +4 -4
@@ -87,12 +87,12 @@ static struct xs_handle *xs;#ifdef RUN_IN_SIMULATE_MODE #define BATTERY_DIR_PATH "/tmp/battery" -#define BATTERY_INFO_FILE_PATH "/tmp/battery/%s/info" -#define BATTERY_STATE_FILE_PATH "/tmp/battery/%s/state" +#define BATTERY_INFO_FILE_PATH "/tmp/battery/%.4s/info" +#define BATTERY_STATE_FILE_PATH "/tmp/battery/%.4s/state"#else #define BATTERY_DIR_PATH "/proc/acpi/battery" -#define BATTERY_INFO_FILE_PATH "/proc/acpi/battery/%s/info" -#define BATTERY_STATE_FILE_PATH "/proc/acpi/battery/%s/state" +#define BATTERY_INFO_FILE_PATH "/proc/acpi/battery/%.4s/info" +#define BATTERY_STATE_FILE_PATH "/proc/acpi/battery/%.4s/state"#endif FILE *get_next_battery_file(DIR *battery_dir,
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/3] tools/xenpmd: fix potential string truncation
Quoted 5 lines · Marek Marczykowski-Górecki
GCC 7 warns (and thanks to -Werror, fails) about potential string truncation by snprintf in
get_next_battery_file. Since the code already check if string is no longer than 4 chars, tell gcc about it.Signed-off-by Marek Marczykowski-Górecki <[email protected]>
I think this is fixed in staging by enlarging the size of the buffers. Have you tried the latest code?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/3 Disable -Wint-in-bool-context
In reply to Marek Marczykowski-GóreckiGCC 7 is too sensitive here.
See https://bugs.debian.org/853710
--- Config.mk | 1 + 1 file changed, 1 insertion(+)
Config.mk +1 -0
@@ -216,6 +216,7 @@ $(call cc-option-add,HOSTCFLAGS,HOSTCC,-Wdeclaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wdeclaration-after-statement) $(call cc-option-add,CFLAGS,CC,-Wno-unused-but-set-variable) $(call cc-option-add,CFLAGS,CC,-Wno-unused-local-typedefs) +$(call cc-option-add,CFLAGS,CC,-Wno-int-in-bool-context) LDFLAGS += $(foreach i, $(EXTRA_LIB), -L$(i)) CFLAGS += $(foreach i, $(EXTRA_INCLUDES), -I$(i))
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 3/3] Disable -Wint-in-bool-context
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Marek Marczykowski-Górecki <[email protected]> 06/27/17 7:35 PM >>>
GCC 7 is too sensitive here.
See https://bugs.debian.org/853710
The issue pointed out in that bug was fixed already without disabling the generally useful warning. That fix has been backported to the 4.8 branch already.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel