From 3178430b32c71c0348eb33521d8323122714a58b Mon Sep 17 00:00:00 2001 From: Igor Ivanov Date: Wed, 16 Dec 2020 13:46:17 +0200 Subject: [PATCH] Fix issues for gcc-11 1. The register storage class specifier is deprecated in C++11 2. Disable -Wno-free-nonheap-object diagnostic that looks as incorrect for gcc-11 Signed-off-by: Igor Ivanov --- configure.ac | 8 ++++++-- src/utils/asm-x86.h | 2 +- src/vma/sock/cleanable_obj.h | 9 ++++++++- src/vma/util/utils.cpp | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 1540324a..811eb421 100644 --- a/configure.ac +++ b/configure.ac @@ -144,8 +144,12 @@ AC_MSG_CHECKING([for compiler]) case $CC in gcc*|g++*) AC_MSG_RESULT([gcc]) - CFLAGS="$CFLAGS -Wall -Wextra -Werror -Wundef -ffunction-sections -fdata-sections -Wsequence-point -pipe -Winit-self -Wmissing-include-dirs" - CXXFLAGS="$CXXFLAGS -Wshadow -Wall -Wextra -Werror -Wundef -ffunction-sections -fdata-sections -Wsequence-point -pipe -Winit-self -Wmissing-include-dirs" + CFLAGS="$CFLAGS -Wall -Wextra -Werror -Wundef \ + -ffunction-sections -fdata-sections -Wsequence-point -pipe -Winit-self -Wmissing-include-dirs \ + -Wno-free-nonheap-object " + CXXFLAGS="$CXXFLAGS -Wshadow -Wall -Wextra -Werror -Wundef \ + -ffunction-sections -fdata-sections -Wsequence-point -pipe -Winit-self -Wmissing-include-dirs \ + -Wno-free-nonheap-object " ;; icc*|icpc*) AC_MSG_RESULT([icc]) diff --git a/src/utils/asm-x86.h b/src/utils/asm-x86.h index 5dfb6f42..4e8f03ca 100644 --- a/src/utils/asm-x86.h +++ b/src/utils/asm-x86.h @@ -110,7 +110,7 @@ static inline int atomic_fetch_and_add(int x, volatile int *ptr) */ static inline void gettimeoftsc(unsigned long long *p_tscval) { - register uint32_t upper_32, lower_32; + uint32_t upper_32, lower_32; // ReaD Time Stamp Counter (RDTCS) __asm__ __volatile__("rdtsc" : "=a" (lower_32), "=d" (upper_32)); diff --git a/src/vma/sock/cleanable_obj.h b/src/vma/sock/cleanable_obj.h index 34801712..ea38f24b 100644 --- a/src/vma/sock/cleanable_obj.h +++ b/src/vma/sock/cleanable_obj.h @@ -44,7 +44,14 @@ public: virtual ~cleanable_obj(){}; - virtual void clean_obj(){ set_cleaned(); delete this; }; + /* This function should be used just for objects that + * was allocated via new() (not by new[], nor by placement new, nor a local object on the stack, + * nor a namespace-scope / global, nor a member of another object; but by plain ordinary new) + */ + virtual void clean_obj(){ + set_cleaned(); + delete this; + }; bool is_cleaned(){ return m_b_cleaned; }; diff --git a/src/vma/util/utils.cpp b/src/vma/util/utils.cpp index 5c0fe3e9..a4c3ce66 100644 --- a/src/vma/util/utils.cpp +++ b/src/vma/util/utils.cpp @@ -235,7 +235,7 @@ unsigned short compute_ip_checksum(const unsigned short *buf, unsigned int nshor * */ unsigned short compute_tcp_checksum(const struct iphdr *p_iphdr, const uint16_t *p_ip_payload) { - register unsigned long sum = 0; + unsigned long sum = 0; uint16_t tcpLen = ntohs(p_iphdr->tot_len) - (p_iphdr->ihl<<2); // shift left 2 will multiply by 4 for converting to octets //add the pseudo header @@ -277,7 +277,7 @@ unsigned short compute_tcp_checksum(const struct iphdr *p_iphdr, const uint16_t */ unsigned short compute_udp_checksum_rx(const struct iphdr *p_iphdr, const struct udphdr *udphdrp, mem_buf_desc_t* p_rx_wc_buf_desc) { - register unsigned long sum = 0; + unsigned long sum = 0; unsigned short udp_len = htons(udphdrp->len); const uint16_t *p_ip_payload = (const uint16_t *) udphdrp; mem_buf_desc_t *p_ip_frag = p_rx_wc_buf_desc; -- 2.18.1