From 7baf2c4bf1347f7ba8bf0fc9415ae08fe4b0ed5b Mon Sep 17 00:00:00 2001 From: George Joseph Date: Thu, 30 Apr 2020 09:56:03 -0600 Subject: [PATCH] app_voicemail: Add workaround for a gcc 10 issue with -Wrestrict The gcc 10 -Wrestrict option was causing "overlap" errors when snprintf was copying one char[256] structure member to another char[256] member in the same structure. Using ast_alloca instead of declaring the structure inline solves the issue. Here's a link to the "enhancement": https://gcc.gnu.org/legacy-ml/gcc-patches/2019-10/msg00570.html We may follow up with a gcc bug report. Change-Id: Ie0099adcb0a9727bd9aa99e024dd912a67eaf534 --- apps/app_voicemail.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 7dbebddac0..0b14934f13 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -14534,6 +14534,12 @@ exit_vmsayname_test: return res ? AST_TEST_FAIL : AST_TEST_PASS; } +struct test_files { + char dir[256]; + char file[256]; + char txtfile[256]; +}; + AST_TEST_DEFINE(test_voicemail_msgcount) { int i, j, res = AST_TEST_PASS, syserr; @@ -14543,11 +14549,8 @@ AST_TEST_DEFINE(test_voicemail_msgcount) #ifdef IMAP_STORAGE struct ast_channel *chan = NULL; #endif - struct { - char dir[256]; - char file[256]; - char txtfile[256]; - } tmp[3]; + /* Using ast_alloca instead of just declaring tmp as an array is a workaround for a GCC 10 issue with -Wrestrict */ + struct test_files *tmp = ast_alloca(sizeof(struct test_files) * 3); char syscmd[256]; const char origweasels[] = "tt-weasels"; const char testcontext[] = "test";