[Asterisk-code-review] app queue: Silence GCC 8 compiler warning (asterisk[16])

Joshua Colp asteriskteam at digium.com
Wed Aug 22 11:35:50 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9982 )

Change subject: app_queue: Silence GCC 8 compiler warning
......................................................................

app_queue: Silence GCC 8 compiler warning

I'm only seeing an error in 14+, so I assume it is due to different
compiler options:

app_queue.c: In function ‘handle_queue_add_member’:
app_queue.c:10234:19: error: ‘%d’ directive writing between 1 and 11
    bytes into a region of size 3 [-Werror=format-overflow=]
     sprintf(num, "%d", state);
                   ^~
app_queue.c:10234:18: note: directive argument in the range
    [-2147483648, 99]
     sprintf(num, "%d", state);
                  ^~~~

Compiler: gcc version 8.0.1 20180414 (experimental)
    [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2) 

Change-Id: I18577590da46829c1ea7d8b82e41d69f105baa10
---
M apps/app_queue.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Matthew Fredrickson: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/apps/app_queue.c b/apps/app_queue.c
index ee252f9..136dec5 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -10354,7 +10354,7 @@
 	case 6: /* only one possible match, "penalty" */
 		return state == 0 ? ast_strdup("penalty") : NULL;
 	case 7:
-		if (state < 100) {      /* 0-99 */
+		if (0 <= state && state < 100) {      /* 0-99 */
 			char *num;
 			if ((num = ast_malloc(3))) {
 				sprintf(num, "%d", state);

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: I18577590da46829c1ea7d8b82e41d69f105baa10
Gerrit-Change-Number: 9982
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180822/b4ae216d/attachment.html>


More information about the asterisk-code-review mailing list