From d5b102a21d92979ba70695577be20866fdf797ec Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 5 Jul 2017 12:26:37 +0200 Subject: [PATCH] Fix compilation for Debian Stretch with GCC 6.3 --- bacula/src/lib/smartall.c | 7 +++++++ bacula/src/lib/smartall.h | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index 61282d68a6..49a8c9fe8f 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -556,3 +556,10 @@ void operator delete(void *buf) #endif #endif + +/* Avoid aggressive optimization */ +void *bmemset(void *s, int c, size_t n) +{ + void *ret = memset(s, c, n); + return ret; +} diff --git a/bacula/src/lib/smartall.h b/bacula/src/lib/smartall.h index 2bde7620e8..49af581627 100644 --- a/bacula/src/lib/smartall.h +++ b/bacula/src/lib/smartall.h @@ -35,6 +35,9 @@ extern uint32_t DLL_IMP_EXP sm_buffers; #define SMARTALLOC SMARTALLOC +/* Avoid aggressive GCC optimization */ +extern void *bmemset(void *s, int c, size_t n); + extern void *sm_malloc(const char *fname, int lineno, unsigned int nbytes), *sm_calloc(const char *fname, int lineno, unsigned int nelem, unsigned int elsize), @@ -109,13 +112,13 @@ void *operator new(size_t s, const char *fname, int line) { size_t size = s > sizeof(int) ? (unsigned int)s : sizeof(int); void *p = sm_malloc(fname, line, size); - return memset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ + return bmemset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ } void *operator new[](size_t s, const char *fname, int line) { size_t size = s > sizeof(int) ? (unsigned int)s : sizeof(int); void *p = sm_malloc(fname, line, size); - return memset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ + return bmemset(p, 0, size); /* return memset() result to avoid GCC 6.1 issue */ } void operator delete(void *ptr) @@ -151,12 +154,12 @@ class SMARTALLOC public: void *operator new(size_t s) { void *p = malloc(s); - memset(p, 0, s); + bmemset(p, 0, s); return p; } void *operator new[](size_t s) { void *p = malloc(s); - memset(p, 0, s); + bmemset(p, 0, s); return p; } void operator delete(void *ptr) { -- 2.39.5