[Asterisk-code-review] app_voicemail: Add workaround for a gcc 10 issue with -Wrestrict (asterisk[13])

Joshua Colp asteriskteam at digium.com
Thu Apr 30 12:45:31 CDT 2020


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14334 )

Change subject: app_voicemail: Add workaround for a gcc 10 issue with -Wrestrict
......................................................................

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
---
M apps/app_voicemail.c
1 file changed, 8 insertions(+), 5 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  Kevin Harwell: Looks good to me, approved



diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e73198c..9f58088 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -14778,6 +14778,12 @@
 	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;
@@ -14787,11 +14793,8 @@
 #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";

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14334
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Ie0099adcb0a9727bd9aa99e024dd912a67eaf534
Gerrit-Change-Number: 14334
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200430/f020b5e0/attachment-0001.html>


More information about the asterisk-code-review mailing list