From abd3e4040bd76058d0148884879858894258fb9f Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Fri, 9 May 2014 22:49:26 +0000 Subject: Allow Asterisk to compile under GCC 4.10 This resolves a large number of compiler warnings from GCC 4.10 which cause the build to fail under dev mode. The vast majority are signed/unsigned mismatches in printf-style format strings. ........ Merged revisions 413586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 413587 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 413588 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413589 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_adsiprog.c | 2 +- apps/app_confbridge.c | 6 +++--- apps/app_dial.c | 4 ++-- apps/app_dumpchan.c | 6 +++--- apps/app_festival.c | 2 +- apps/app_getcpeid.c | 8 ++++++-- apps/app_minivm.c | 4 ++-- apps/app_queue.c | 6 +++--- apps/app_sms.c | 34 +++++++++++++++++----------------- apps/app_stack.c | 2 +- apps/app_verbose.c | 2 +- apps/app_voicemail.c | 10 +++++----- apps/confbridge/conf_config_parser.c | 12 ++++++------ 13 files changed, 51 insertions(+), 47 deletions(-) (limited to 'apps') diff --git a/apps/app_adsiprog.c b/apps/app_adsiprog.c index 3654f4d6d..ac803248f 100644 --- a/apps/app_adsiprog.c +++ b/apps/app_adsiprog.c @@ -211,7 +211,7 @@ static int process_token(void *out, char *src, int maxlen, int argtype) if (!(argtype & ARG_NUMBER)) return -1; /* Octal value */ - if (sscanf(src, "%30o", (int *)out) != 1) + if (sscanf(src, "%30o", (unsigned *)out) != 1) return -1; if (argtype & ARG_STRING) { /* Convert */ diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index 48573d54c..bf8773d32 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -2392,7 +2392,7 @@ static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct ast_cli(a->fd, "================================ ====== ====== ========\n"); iter = ao2_iterator_init(conference_bridges, 0); while ((conference = ao2_iterator_next(&iter))) { - ast_cli(a->fd, "%-32s %6i %6i %s\n", conference->name, conference->activeusers + conference->waitingusers, conference->markedusers, (conference->locked ? "locked" : "unlocked")); + ast_cli(a->fd, "%-32s %6u %6u %s\n", conference->name, conference->activeusers + conference->waitingusers, conference->markedusers, (conference->locked ? "locked" : "unlocked")); ao2_ref(conference, -1); } ao2_iterator_destroy(&iter); @@ -2848,8 +2848,8 @@ static int action_confbridgelistrooms(struct mansession *s, const struct message "Event: ConfbridgeListRooms\r\n" "%s" "Conference: %s\r\n" - "Parties: %d\r\n" - "Marked: %d\r\n" + "Parties: %u\r\n" + "Marked: %u\r\n" "Locked: %s\r\n" "\r\n", id_text, diff --git a/apps/app_dial.c b/apps/app_dial.c index 61b2c26a0..df9b72aaf 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1493,7 +1493,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, /* Fall through */ case AST_FRAME_TEXT: if (single && ast_write(in, f)) { - ast_log(LOG_WARNING, "Unable to write frametype: %d\n", + ast_log(LOG_WARNING, "Unable to write frametype: %u\n", f->frametype); } break; @@ -1598,7 +1598,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, case AST_FRAME_DTMF_BEGIN: case AST_FRAME_DTMF_END: if (ast_write(o->chan, f)) { - ast_log(LOG_WARNING, "Unable to forward frametype: %d\n", + ast_log(LOG_WARNING, "Unable to forward frametype: %u\n", f->frametype); } break; diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c index bbe00e907..5c5be18af 100644 --- a/apps/app_dumpchan.c +++ b/apps/app_dumpchan.c @@ -105,7 +105,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size) "RDNIS= %s\n" "Parkinglot= %s\n" "Language= %s\n" - "State= %s (%d)\n" + "State= %s (%u)\n" "Rings= %d\n" "NativeFormat= %s\n" "WriteFormat= %s\n" @@ -115,8 +115,8 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size) "WriteTranscode= %s %s\n" "ReadTranscode= %s %s\n" "1stFileDescriptor= %d\n" - "Framesin= %d %s\n" - "Framesout= %d %s\n" + "Framesin= %u %s\n" + "Framesout= %u %s\n" "TimetoHangup= %ld\n" "ElapsedTime= %dh%dm%ds\n" "BridgeID= %s\n" diff --git a/apps/app_festival.c b/apps/app_festival.c index ffea6e8bf..3ccacb195 100644 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -424,7 +424,7 @@ static int festival_exec(struct ast_channel *chan, const char *vdata) /* Convert to HEX and look if there is any matching file in the cache directory */ for (i = 0; i < 16; i++) { - snprintf(koko, sizeof(koko), "%X", MD5Res[i]); + snprintf(koko, sizeof(koko), "%X", (unsigned)MD5Res[i]); strncat(MD5Hex, koko, sizeof(MD5Hex) - strlen(MD5Hex) - 1); } readcache = 0; diff --git a/apps/app_getcpeid.c b/apps/app_getcpeid.c index 5cdeca113..8192b7619 100644 --- a/apps/app_getcpeid.c +++ b/apps/app_getcpeid.c @@ -87,7 +87,9 @@ static int cpeid_exec(struct ast_channel *chan, const char *idata) res = ast_adsi_get_cpeid(chan, cpeid, 0); if (res > 0) { gotcpeid = 1; - ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", cpeid[0], cpeid[1], cpeid[2], cpeid[3], ast_channel_name(chan)); + ast_verb(3, "Got CPEID of '%02x:%02x:%02x:%02x' on '%s'\n", + (unsigned)cpeid[0], (unsigned)cpeid[1], (unsigned)cpeid[2], + (unsigned)cpeid[3], ast_channel_name(chan)); } if (res > -1) { strcpy(data[1], "Measuring CPE..."); @@ -101,7 +103,9 @@ static int cpeid_exec(struct ast_channel *chan, const char *idata) } if (res > -1) { if (gotcpeid) - snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", cpeid[0], cpeid[1], cpeid[2], cpeid[3]); + snprintf(data[1], 80, "CPEID: %02x:%02x:%02x:%02x", + (unsigned)cpeid[0], (unsigned)cpeid[1], + (unsigned)cpeid[2], (unsigned)cpeid[3]); else strcpy(data[1], "CPEID Unknown"); if (gotgeometry) diff --git a/apps/app_minivm.c b/apps/app_minivm.c index cdcf8b933..d05ead066 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -1406,7 +1406,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu } } - fprintf(p, "Message-ID: \n", (unsigned int)ast_random(), vmu->username, (int)getpid(), who); + fprintf(p, "Message-ID: \n", (unsigned int)ast_random(), vmu->username, (int)getpid(), who); if (ast_strlen_zero(vmu->email)) { snprintf(email, sizeof(email), "%s@%s", vmu->username, vmu->domain); @@ -1457,7 +1457,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu fprintf(p, "MIME-Version: 1.0\n"); /* Something unique. */ - snprintf(bound, sizeof(bound), "voicemail_%s%d%d", vmu->username, (int)getpid(), (unsigned int)ast_random()); + snprintf(bound, sizeof(bound), "voicemail_%s%d%u", vmu->username, (int)getpid(), (unsigned int)ast_random()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"\n\n\n", bound); diff --git a/apps/app_queue.c b/apps/app_queue.c index e83b313f0..17c8c9a9a 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -2355,12 +2355,12 @@ static void device_state_cb(void *unused, struct stasis_subscription *sub, struc ao2_iterator_destroy(&qiter); if (found) { - ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", + ast_debug(1, "Device '%s' changed to state '%u' (%s)\n", dev_state->device, dev_state->state, ast_devstate2str(dev_state->state)); } else { - ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", + ast_debug(3, "Device '%s' changed to state '%u' (%s) but we don't care because they're not a member of any queue.\n", dev_state->device, dev_state->state, ast_devstate2str(dev_state->state)); @@ -6612,7 +6612,7 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a ast_monitor_start(which, qe->parent->monfmt, ast_channel_uniqueid(qe->chan), 1, X_REC_IN | X_REC_OUT, NULL); } else { /* Last ditch effort -- no channel, make up something */ - snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); + snprintf(tmpid, sizeof(tmpid), "chan-%lx", (unsigned long)ast_random()); ast_monitor_start(which, qe->parent->monfmt, tmpid, 1, X_REC_IN | X_REC_OUT, NULL); } if (!ast_strlen_zero(monexec)) { diff --git a/apps/app_sms.c b/apps/app_sms.c index 12fede073..b7d247818 100644 --- a/apps/app_sms.c +++ b/apps/app_sms.c @@ -782,7 +782,7 @@ static void sms_log(sms_t * h, char status) unsigned char n; if (h->mr >= 0) { - snprintf(mrs, sizeof(mrs), "%02X", h->mr); + snprintf(mrs, sizeof(mrs), "%02X", (unsigned)h->mr); } snprintf(line, sizeof(line), "%s %c%c%c%s %s %s %s ", isodate(time(NULL), buf, sizeof(buf)), @@ -999,7 +999,7 @@ static void sms_writefile(sms_t * h) snprintf(fn, sizeof(fn), "%s/sms/%s", ast_config_AST_SPOOL_DIR, h->smsc ? h->rx ? "morx" : "mttx" : h->rx ? "mtrx" : "motx"); ast_mkdir(fn, 0777); /* ensure it exists */ ast_copy_string(fn2, fn, sizeof(fn2)); - snprintf(fn2 + strlen(fn2), sizeof(fn2) - strlen(fn2), "/%s.%s-%d", h->queue, isodate(h->scts.tv_sec, buf, sizeof(buf)), seq++); + snprintf(fn2 + strlen(fn2), sizeof(fn2) - strlen(fn2), "/%s.%s-%u", h->queue, isodate(h->scts.tv_sec, buf, sizeof(buf)), seq++); snprintf(fn + strlen(fn), sizeof(fn) - strlen(fn), "/.%s", fn2 + strlen(fn) + 1); if ((o = fopen(fn, "w")) == NULL) { return; @@ -1015,7 +1015,7 @@ static void sms_writefile(sms_t * h) unsigned int p; fprintf(o, "udh#"); for (p = 0; p < h->udhl; p++) { - fprintf(o, "%02X", h->udh[p]); + fprintf(o, "%02X", (unsigned)h->udh[p]); } fprintf(o, "\n"); } @@ -1048,13 +1048,13 @@ static void sms_writefile(sms_t * h) if (p == h->udl) { /* can write in ucs-1 hex */ fprintf(o, "ud#"); for (p = 0; p < h->udl; p++) { - fprintf(o, "%02X", h->ud[p]); + fprintf(o, "%02X", (unsigned)h->ud[p]); } fprintf(o, "\n"); } else { /* write in UCS-2 */ fprintf(o, "ud##"); for (p = 0; p < h->udl; p++) { - fprintf(o, "%04X", h->ud[p]); + fprintf(o, "%04X", (unsigned)h->ud[p]); } fprintf(o, "\n"); } @@ -1071,7 +1071,7 @@ static void sms_writefile(sms_t * h) fprintf(o, "dcs=%d\n", h->dcs); } if (h->vp) { - fprintf(o, "vp=%d\n", h->vp); + fprintf(o, "vp=%u\n", h->vp); } if (h->srr) { fprintf(o, "srr=1\n"); @@ -1139,7 +1139,7 @@ static unsigned char sms_handleincoming (sms_t * h) return 0xFF; /* duh! */ } } else { - ast_log(LOG_WARNING, "Unknown message type %02X\n", h->imsg[2]); + ast_log(LOG_WARNING, "Unknown message type %02X\n", (unsigned)h->imsg[2]); return 0xFF; } } else { /* client */ @@ -1162,7 +1162,7 @@ static unsigned char sms_handleincoming (sms_t * h) return 0xFF; /* duh! */ } } else { - ast_log(LOG_WARNING, "Unknown message type %02X\n", h->imsg[2]); + ast_log(LOG_WARNING, "Unknown message type %02X\n", (unsigned)h->imsg[2]); return 0xFF; } } @@ -1244,7 +1244,7 @@ static char *sms_hexdump(unsigned char buf[], int size, char *s /* destination * int f; for (p = s, f = 0; f < size && f < MAX_DEBUG_LEN; f++, p += 3) { - sprintf(p, "%02X ", (unsigned char)buf[f]); + sprintf(p, "%02X ", (unsigned)buf[f]); } return(s); } @@ -1270,7 +1270,7 @@ static int sms_handleincoming_proto2(sms_t *h) msgsz += (h->imsg[f++] * 256); switch (msg) { case 0x13: /* Body */ - ast_verb(3, "SMS-P2 Body#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); + ast_verb(3, "SMS-P2 Body#%02X=[%.*s]\n", (unsigned)msg, msgsz, &h->imsg[f]); if (msgsz >= sizeof(h->ud)) { msgsz = sizeof(h->ud) - 1; } @@ -1288,27 +1288,27 @@ static int sms_handleincoming_proto2(sms_t *h) tm.tm_min = ( (h->imsg[f + 6] * 10) + h->imsg[f + 7] ); tm.tm_sec = 0; h->scts = ast_mktime(&tm, NULL); - ast_verb(3, "SMS-P2 Date#%02X=%02d/%02d %02d:%02d\n", msg, tm.tm_mday, tm.tm_mon + 1, tm.tm_hour, tm.tm_min); + ast_verb(3, "SMS-P2 Date#%02X=%02d/%02d %02d:%02d\n", (unsigned)msg, tm.tm_mday, tm.tm_mon + 1, tm.tm_hour, tm.tm_min); break; case 0x15: /* Calling line (from SMSC) */ if (msgsz >= 20) { msgsz = 20 - 1; } - ast_verb(3, "SMS-P2 Origin#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); + ast_verb(3, "SMS-P2 Origin#%02X=[%.*s]\n", (unsigned)msg, msgsz, &h->imsg[f]); ast_copy_string(h->oa, (char *)(&h->imsg[f]), msgsz + 1); break; case 0x18: /* Destination(from TE/phone) */ if (msgsz >= 20) { msgsz = 20 - 1; } - ast_verb(3, "SMS-P2 Destination#%02X=[%.*s]\n", msg, msgsz, &h->imsg[f]); + ast_verb(3, "SMS-P2 Destination#%02X=[%.*s]\n", (unsigned)msg, msgsz, &h->imsg[f]); ast_copy_string(h->da, (char *)(&h->imsg[f]), msgsz + 1); break; case 0x1C: /* Notify */ - ast_verb(3, "SMS-P2 Notify#%02X=%s\n", msg, sms_hexdump(&h->imsg[f], 3, debug_buf)); + ast_verb(3, "SMS-P2 Notify#%02X=%s\n", (unsigned)msg, sms_hexdump(&h->imsg[f], 3, debug_buf)); break; default: - ast_verb(3, "SMS-P2 Par#%02X [%d]: %s\n", msg, msgsz, sms_hexdump(&h->imsg[f], msgsz, debug_buf)); + ast_verb(3, "SMS-P2 Par#%02X [%d]: %s\n", (unsigned)msg, msgsz, sms_hexdump(&h->imsg[f], msgsz, debug_buf)); break; } f+=msgsz; /* Skip to next */ @@ -1482,7 +1482,7 @@ static void sms_debug (int dir, sms_t *h) int n = (dir == DIR_RX) ? h->ibytep : msg[1] + 2; int q = 0; while (q < n && q < 30) { - sprintf(p, " %02X", msg[q++]); + sprintf(p, " %02X", (unsigned)msg[q++]); p += 3; } if (q < n) { @@ -1892,7 +1892,7 @@ static int sms_exec(struct ast_channel *chan, const char *data) ast_app_parse_options(sms_options, &flags, sms_opts, sms_args.options); } - ast_verb(1, "sms argc %d queue <%s> opts <%s> addr <%s> body <%s>\n", + ast_verb(1, "sms argc %u queue <%s> opts <%s> addr <%s> body <%s>\n", sms_args.argc, S_OR(sms_args.queue, ""), S_OR(sms_args.options, ""), S_OR(sms_args.addr, ""), diff --git a/apps/app_stack.c b/apps/app_stack.c index ba3b97cd1..2f89b3559 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -641,7 +641,7 @@ static int gosub_exec(struct ast_channel *chan, const char *data) frame_set_var(chan, newframe, argname, i < args2.argc ? args2.argval[i] : ""); ast_debug(1, "Setting '%s' to '%s'\n", argname, i < args2.argc ? args2.argval[i] : ""); } - snprintf(argname, sizeof(argname), "%d", args2.argc); + snprintf(argname, sizeof(argname), "%u", args2.argc); frame_set_var(chan, newframe, "ARGC", argname); /* And finally, save our return address */ diff --git a/apps/app_verbose.c b/apps/app_verbose.c index 8d285b02f..c6fc8d17b 100644 --- a/apps/app_verbose.c +++ b/apps/app_verbose.c @@ -78,7 +78,7 @@ static char *app_log = "Log"; static int verbose_exec(struct ast_channel *chan, const char *data) { - int vsize; + unsigned int vsize; char *parse; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(level); diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 7db2a2564..cb85c5be9 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -5071,7 +5071,7 @@ static void make_email_file(FILE *p, } } - fprintf(p, "Message-ID: " ENDL, msgnum + 1, + fprintf(p, "Message-ID: " ENDL, msgnum + 1, (unsigned int) ast_random(), mailbox, (int) getpid(), host); if (imap) { /* additional information needed for IMAP searching */ @@ -5110,7 +5110,7 @@ static void make_email_file(FILE *p, fprintf(p, "MIME-Version: 1.0" ENDL); if (attach_user_voicemail) { /* Something unique. */ - snprintf(bound, sizeof(bound), "----voicemail_%d%s%d%d", msgnum + 1, mailbox, + snprintf(bound, sizeof(bound), "----voicemail_%d%s%d%u", msgnum + 1, mailbox, (int) getpid(), (unsigned int) ast_random()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"" ENDL, bound); @@ -5301,7 +5301,7 @@ static int sendmail(char *srcemail, if (!strcmp(format, "wav49")) format = "WAV"; - ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); + ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %u\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ if ((p = vm_mkftemp(tmp)) == NULL) { @@ -6033,7 +6033,7 @@ static void generate_msg_id(char *dst) * called each time a new msg_id is generated. This should achieve uniqueness, * but only in single system solutions. */ - int unique_counter = ast_atomic_fetchadd_int(&msg_id_incrementor, +1); + unsigned int unique_counter = ast_atomic_fetchadd_int(&msg_id_incrementor, +1); snprintf(dst, MSG_ID_LEN, "%ld-%08x", (long) time(NULL), unique_counter); } @@ -12997,7 +12997,7 @@ static int actual_load_config(int reload, struct ast_config *cfg, struct ast_con const char *val; char *q, *stringp, *tmp; int x; - int tmpadsi[4]; + unsigned int tmpadsi[4]; char secretfn[PATH_MAX] = ""; #ifdef IMAP_STORAGE diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c index 2fd61df47..2f6011056 100644 --- a/apps/confbridge/conf_config_parser.c +++ b/apps/confbridge/conf_config_parser.c @@ -1111,7 +1111,7 @@ static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum con } menu_action->data.dialplan_args.priority = 1; /* 1 by default */ if (!ast_strlen_zero(args.priority) && - (sscanf(args.priority, "%30u", &menu_action->data.dialplan_args.priority) != 1)) { + (sscanf(args.priority, "%30d", &menu_action->data.dialplan_args.priority) != 1)) { /* invalid priority */ ast_free(menu_action); return -1; @@ -1378,9 +1378,9 @@ static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, in ast_cli(a->fd,"Drop_silence: %s\n", u_profile.flags & USER_OPT_DROP_SILENCE ? "enabled" : "disabled"); - ast_cli(a->fd,"Silence Threshold: %dms\n", + ast_cli(a->fd,"Silence Threshold: %ums\n", u_profile.silence_threshold); - ast_cli(a->fd,"Talking Threshold: %dms\n", + ast_cli(a->fd,"Talking Threshold: %ums\n", u_profile.talking_threshold); ast_cli(a->fd,"Denoise: %s\n", u_profile.flags & USER_OPT_DENOISE ? @@ -1504,14 +1504,14 @@ static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, ast_cli(a->fd,"Language: %s\n", b_profile.language); if (b_profile.internal_sample_rate) { - snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate); + snprintf(tmp, sizeof(tmp), "%u", b_profile.internal_sample_rate); } else { ast_copy_string(tmp, "auto", sizeof(tmp)); } ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp); if (b_profile.mix_interval) { - ast_cli(a->fd,"Mixing Interval: %d\n", b_profile.mix_interval); + ast_cli(a->fd,"Mixing Interval: %u\n", b_profile.mix_interval); } else { ast_cli(a->fd,"Mixing Interval: Default 20ms\n"); } @@ -1529,7 +1529,7 @@ static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, b_profile.rec_file); if (b_profile.max_members) { - ast_cli(a->fd,"Max Members: %d\n", b_profile.max_members); + ast_cli(a->fd,"Max Members: %u\n", b_profile.max_members); } else { ast_cli(a->fd,"Max Members: No Limit\n"); } -- cgit v1.2.3