Merged revisions 159818 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r159818 | kpfleming | 2008-11-29 11:57:39 -0600 (Sat, 29 Nov 2008) | 18 lines
  
  incorporates r159808 from branches/1.4:
  ------------------------------------------------------------------------
  r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines
  
  update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors
  
  since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them
  
  format attributes in a consistent way
  
  
  ------------------------------------------------------------------------
  
  in addition:
  
  move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@159855 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Kevin P. Fleming 17 years ago
parent f798f236fb
commit 2eb5c30a3a

@ -228,7 +228,13 @@ endif
ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
ifeq ($(AST_DEVMODE),yes) ifeq ($(AST_DEVMODE),yes)
ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2 ASTCFLAGS+=-Werror
ASTCFLAGS+=-Wunused
ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
ASTCFLAGS+=-Wundef
ASTCFLAGS+=-Wmissing-format-attribute
ASTCFLAGS+=-Wformat=2
endif endif
ifneq ($(findstring BSD,$(OSARCH)),) ifneq ($(findstring BSD,$(OSARCH)),)

@ -1012,7 +1012,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
} }
#endif #endif
if (p->pending) if (p->pending)
tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/P%s-%d", p->agent, ast_random() & 0xffff); tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/P%s-%d", p->agent, (int) ast_random() & 0xffff);
else else
tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/%s", p->agent); tmp = ast_channel_alloc(0, state, 0, 0, "", p->chan ? p->chan->exten:"", p->chan ? p->chan->context:"", 0, "Agent/%s", p->agent);
if (!tmp) { if (!tmp) {

@ -2630,7 +2630,7 @@ static void build_via(struct sip_pvt *p)
ast_string_field_build(p, via, "SIP/2.0/%s %s:%d;branch=z9hG4bK%08x%s", ast_string_field_build(p, via, "SIP/2.0/%s %s:%d;branch=z9hG4bK%08x%s",
get_transport_pvt(p), get_transport_pvt(p),
ast_inet_ntoa(p->ourip.sin_addr), ast_inet_ntoa(p->ourip.sin_addr),
ntohs(p->ourip.sin_port), p->branch, rport); ntohs(p->ourip.sin_port), (int) p->branch, rport);
} }
/*! \brief NAT fix - decide which IP address to use for Asterisk server? /*! \brief NAT fix - decide which IP address to use for Asterisk server?

@ -2486,7 +2486,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
} }
ast_verb(4, "%s: New call for context [%s]\n", me->dev, context); ast_verb(4, "%s: New call for context [%s]\n", me->dev, context);
tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, 0, me->dev); tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, 0, "%s", me->dev);
if (tmp) { if (tmp) {
if (use_ast_ind == 1){ if (use_ast_ind == 1){
tmp->tech = &vpb_tech_indicate; tmp->tech = &vpb_tech_indicate;

@ -1347,7 +1347,7 @@ static void enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, ch
i = 0; i = 0;
while(i < user_len) while(i < user_len)
{ {
if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", user[i]); if (MISDN_IE_DEBG) sprintf(debug+(i*3), " %02x", user[i]);
i++; i++;
} }
@ -1393,7 +1393,7 @@ static void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, ch
i = 0; i = 0;
while(i < *user_len) while(i < *user_len)
{ {
if (MISDN_IE_DEBG) printf(debug+(i*3), " %02x", user[i]); if (MISDN_IE_DEBG) sprintf(debug+(i*3), " %02x", user[i]);
i++; i++;
} }
debug[i*3] = '\0'; debug[i*3] = '\0';

@ -885,12 +885,14 @@ static int _parse (union misdn_cfg_pt *dest, const char *value, enum misdn_cfg_t
break; break;
case MISDN_CTYPE_INT: case MISDN_CTYPE_INT:
{ {
char *pat; int res;
if (strchr(value,'x'))
pat="%x"; if (strchr(value,'x')) {
else res = sscanf(value, "%x", &tmp);
pat="%d"; } else {
if (sscanf(value, pat, &tmp)) { res = sscanf(value, "%d", &tmp);
}
if (res) {
dest->num = ast_malloc(sizeof(int)); dest->num = ast_malloc(sizeof(int));
memcpy(dest->num, &tmp, sizeof(int)); memcpy(dest->num, &tmp, sizeof(int));
} else } else

27
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.ac Revision: 153745 . # From configure.ac Revision: 157601 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6. # Generated by GNU Autoconf 2.61 for asterisk 1.6.
# #
@ -954,6 +954,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
GC_CFLAGS GC_CFLAGS
GC_LDFLAGS GC_LDFLAGS
AST_DECLARATION_AFTER_STATEMENT AST_DECLARATION_AFTER_STATEMENT
AST_FORTIFY_SOURCE
AST_NO_STRICT_OVERFLOW AST_NO_STRICT_OVERFLOW
PBX_RTLD_NOLOAD PBX_RTLD_NOLOAD
PBX_IP_MTU_DISCOVER PBX_IP_MTU_DISCOVER
@ -12883,11 +12884,13 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
#include <sys/types.h> /* for off_t */
#include <stdio.h> #include <stdio.h>
int int
main () main ()
{ {
return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); int (*fp) (FILE *, off_t, int) = fseeko;
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
; ;
return 0; return 0;
} }
@ -12927,11 +12930,13 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */ /* end confdefs.h. */
#define _LARGEFILE_SOURCE 1 #define _LARGEFILE_SOURCE 1
#include <sys/types.h> /* for off_t */
#include <stdio.h> #include <stdio.h>
int int
main () main ()
{ {
return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0); int (*fp) (FILE *, off_t, int) = fseeko;
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
; ;
return 0; return 0;
} }
@ -17184,6 +17189,19 @@ echo "${ECHO_T}no" >&6; }
fi fi
{ echo "$as_me:$LINENO: checking for _FORTIFY_SOURCE support" >&5
echo $ECHO_N "checking for _FORTIFY_SOURCE support... $ECHO_C" >&6; }
if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
AST_FORTIFY_SOURCE=
fi
{ echo "$as_me:$LINENO: checking for -fno-strict-overflow" >&5 { echo "$as_me:$LINENO: checking for -fno-strict-overflow" >&5
echo $ECHO_N "checking for -fno-strict-overflow... $ECHO_C" >&6; } echo $ECHO_N "checking for -fno-strict-overflow... $ECHO_C" >&6; }
if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
@ -50367,6 +50385,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP!$PBX_PTHREAD_RECURSIVE_MUTEX_INITIALI
GC_CFLAGS!$GC_CFLAGS$ac_delim GC_CFLAGS!$GC_CFLAGS$ac_delim
GC_LDFLAGS!$GC_LDFLAGS$ac_delim GC_LDFLAGS!$GC_LDFLAGS$ac_delim
AST_DECLARATION_AFTER_STATEMENT!$AST_DECLARATION_AFTER_STATEMENT$ac_delim AST_DECLARATION_AFTER_STATEMENT!$AST_DECLARATION_AFTER_STATEMENT$ac_delim
AST_FORTIFY_SOURCE!$AST_FORTIFY_SOURCE$ac_delim
AST_NO_STRICT_OVERFLOW!$AST_NO_STRICT_OVERFLOW$ac_delim AST_NO_STRICT_OVERFLOW!$AST_NO_STRICT_OVERFLOW$ac_delim
PBX_RTLD_NOLOAD!$PBX_RTLD_NOLOAD$ac_delim PBX_RTLD_NOLOAD!$PBX_RTLD_NOLOAD$ac_delim
PBX_IP_MTU_DISCOVER!$PBX_IP_MTU_DISCOVER$ac_delim PBX_IP_MTU_DISCOVER!$PBX_IP_MTU_DISCOVER$ac_delim
@ -50397,7 +50416,7 @@ CURL_CONFIG!$CURL_CONFIG$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF _ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 72; then if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 73; then
break break
elif $ac_last_try; then elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

@ -492,6 +492,16 @@ else
fi fi
AC_SUBST(AST_DECLARATION_AFTER_STATEMENT) AC_SUBST(AST_DECLARATION_AFTER_STATEMENT)
AC_MSG_CHECKING(for _FORTIFY_SOURCE support)
if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
AC_MSG_RESULT(yes)
AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2
else
AC_MSG_RESULT(no)
AST_FORTIFY_SOURCE=
fi
AC_SUBST(AST_FORTIFY_SOURCE)
AC_MSG_CHECKING(for -fno-strict-overflow) AC_MSG_CHECKING(for -fno-strict-overflow)
if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)

@ -18,3 +18,5 @@ MENUSELECT_DESCRIPTION=Dialplan Functions
all: _all all: _all
include $(ASTTOPDIR)/Makefile.moddir_rules include $(ASTTOPDIR)/Makefile.moddir_rules
func_strings.o: ASTCFLAGS+=-Wno-format-nonliteral

@ -727,7 +727,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state);
* \note By default, new channels are set to the "s" extension * \note By default, new channels are set to the "s" extension
* and "default" context. * and "default" context.
*/ */
struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...); struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...) __attribute__((format(printf, 9, 10)));
/*! /*!
* \brief Queue an outgoing frame * \brief Queue an outgoing frame

@ -65,8 +65,7 @@ void ast_backtrace(void);
/*! \brief Reload logger without rotating log files */ /*! \brief Reload logger without rotating log files */
int logger_reload(void); int logger_reload(void);
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...) void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
__attribute__ ((format (printf, 5, 6)));
/*! Send a verbose message (based on verbose level) /*! Send a verbose message (based on verbose level)
\brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set. \brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.

@ -183,7 +183,7 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr
*/ */
void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, ...); const ast_string_field *ptr, const char *format, ...) __attribute((format(printf, 4, 5)));
/*! /*!
\internal \internal
@ -198,7 +198,7 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
*/ */
void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, va_list a1, va_list a2); const ast_string_field *ptr, const char *format, va_list a1, va_list a2) __attribute((format(printf, 4, 0)));
/*! /*!
\brief Declare a string field \brief Declare a string field

@ -630,7 +630,7 @@ enum {
* through calling one of the other functions or macros defined in this * through calling one of the other functions or macros defined in this
* file. * file.
*/ */
int __ast_str_helper(struct ast_str **buf, size_t max_len, int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap); int append, const char *fmt, va_list ap);
/*! /*!

@ -140,7 +140,7 @@ ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
http.o: ASTCFLAGS+=$(GMIME_INCLUDE) http.o: ASTCFLAGS+=$(GMIME_INCLUDE)
endif endif
stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) stdtime/localtime.o: ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral
AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS)) AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS))
AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep))) AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep)))

@ -231,7 +231,7 @@ static void check_goto_on_transfer(struct ast_channel *chan)
goto_on_transfer = ast_strdupa(val); goto_on_transfer = ast_strdupa(val);
if (!(xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, chan->name))) if (!(xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "%s", chan->name)))
return; return;
for (x = goto_on_transfer; x && *x; x++) { for (x = goto_on_transfer; x && *x; x++) {

@ -1430,7 +1430,6 @@ int __ast_string_field_ptr_grow(struct ast_string_field_mgr *mgr, size_t needed,
return 0; return 0;
} }
__attribute((format (printf, 4, 0)))
void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2) const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2)
@ -1462,7 +1461,6 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
mgr->used += needed; mgr->used += needed;
} }
__attribute((format (printf, 4, 5)))
void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, ...) const ast_string_field *ptr, const char *format, ...)
@ -1554,7 +1552,6 @@ int ast_get_time_t(const char *src, time_t *dst, time_t _default, int *consumed)
* ast_str_append_va(...) * ast_str_append_va(...)
*/ */
__attribute__((format (printf, 4, 0)))
int __ast_str_helper(struct ast_str **buf, size_t max_len, int __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap) int append, const char *fmt, va_list ap)
{ {

@ -66,6 +66,7 @@ AST_DEVMODE=@AST_DEVMODE@
AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@
AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@ AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@
AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@
ASOUND_INCLUDE=@ALSA_INCLUDE@ ASOUND_INCLUDE=@ALSA_INCLUDE@
ASOUND_LIB=@ALSA_LIB@ ASOUND_LIB=@ALSA_LIB@

@ -77,7 +77,6 @@
#include "asterisk.h" #include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <sqlite.h> #include <sqlite.h>
#include "asterisk/logger.h" #include "asterisk/logger.h"
@ -524,46 +523,46 @@ static char *sql_create_cdr_table =
");"; ");";
/*! SQL query format to insert a CDR entry. */ /*! SQL query format to insert a CDR entry. */
static char *sql_add_cdr_entry = #define sql_add_cdr_entry \
"INSERT INTO '%q' (" "INSERT INTO '%q' (" \
" clid," " clid," \
" src," " src," \
" dst," " dst," \
" dcontext," " dcontext," \
" channel," " channel," \
" dstchannel," " dstchannel," \
" lastapp," " lastapp," \
" lastdata," " lastdata," \
" start," " start," \
" answer," " answer," \
" end," " end," \
" duration," " duration," \
" billsec," " billsec," \
" disposition," " disposition," \
" amaflags," " amaflags," \
" accountcode," " accountcode," \
" uniqueid," " uniqueid," \
" userfield" " userfield" \
") VALUES (" ") VALUES (" \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" datetime(%d,'unixepoch','localtime')," " datetime(%d,'unixepoch','localtime')," \
" datetime(%d,'unixepoch','localtime')," " datetime(%d,'unixepoch','localtime')," \
" datetime(%d,'unixepoch','localtime')," " datetime(%d,'unixepoch','localtime')," \
" '%ld'," " '%ld'," \
" '%ld'," " '%ld'," \
" '%ld'," " '%ld'," \
" '%ld'," " '%ld'," \
" '%q'," " '%q'," \
" '%q'," " '%q'," \
" '%q'" " '%q'" \
");"; ");"
/*! /*!
* SQL query format to fetch the static configuration of a file. * SQL query format to fetch the static configuration of a file.
@ -571,11 +570,11 @@ static char *sql_add_cdr_entry =
* *
* \see add_cfg_entry() * \see add_cfg_entry()
*/ */
static char *sql_get_config_table = #define sql_get_config_table \
"SELECT *" "SELECT *" \
" FROM '%q'" " FROM '%q'" \
" WHERE filename = '%q' AND commented = 0" " WHERE filename = '%q' AND commented = 0" \
" ORDER BY cat_metric ASC, var_metric ASC;"; " ORDER BY cat_metric ASC, var_metric ASC;"
static int set_var(char **var, const char *name, const char *value) static int set_var(char **var, const char *name, const char *value)
{ {

Loading…
Cancel
Save