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/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Kevin P. Fleming 17 years ago
parent 9a7c28cd5a
commit 887e28d7aa

@ -237,7 +237,13 @@ endif
ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
ifeq ($(AST_DEVMODE),yes)
ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -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
ifneq ($(findstring BSD,$(OSARCH)),)

@ -1106,7 +1106,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
}
#endif
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
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) {

@ -3208,7 +3208,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",
get_transport_pvt(p),
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?

@ -2478,7 +2478,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);
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 (use_ast_ind == 1){
tmp->tech = &vpb_tech_indicate;

21
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 157820 .
# From configure.ac Revision: 159631 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.
#
@ -975,6 +975,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
GC_CFLAGS
GC_LDFLAGS
AST_DECLARATION_AFTER_STATEMENT
AST_FORTIFY_SOURCE
AST_NO_STRICT_OVERFLOW
AST_SHADOW_WARNINGS
PBX_RTLD_NOLOAD
@ -18327,6 +18328,19 @@ echo "${ECHO_T}no" >&6; }
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 $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
@ -53372,6 +53386,7 @@ PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP!$PBX_PTHREAD_RECURSIVE_MUTEX_INITIALI
GC_CFLAGS!$GC_CFLAGS$ac_delim
GC_LDFLAGS!$GC_LDFLAGS$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_SHADOW_WARNINGS!$AST_SHADOW_WARNINGS$ac_delim
PBX_RTLD_NOLOAD!$PBX_RTLD_NOLOAD$ac_delim
@ -53403,7 +53418,6 @@ PBX_H323!$PBX_H323$ac_delim
PBX_IXJUSER!$PBX_IXJUSER$ac_delim
CONFIG_SDL!$CONFIG_SDL$ac_delim
CONFIG_GTK!$CONFIG_GTK$ac_delim
PKGCONFIG!$PKGCONFIG$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@ -53445,11 +53459,12 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
PKGCONFIG!$PKGCONFIG$ac_delim
CURL_CONFIG!$CURL_CONFIG$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 2; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 3; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

@ -515,6 +515,16 @@ else
fi
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)
if $(${CC} -O2 -fno-strict-overflow -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
AC_MSG_RESULT(yes)

@ -702,7 +702,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state);
* \note By default, new channels are set to the "s" extension
* 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

@ -65,8 +65,7 @@ void ast_backtrace(void);
/*! \brief Reload logger without rotating log files */
int logger_reload(void);
void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
__attribute__ ((format (printf, 5, 6)));
void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
/*! 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.
@ -75,17 +74,15 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent,
Note the abscence of a comma after the VERBOSE_PREFIX_3. This is important.
VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
*/
void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
__attribute__ ((format (printf, 4, 5)));
void __attribute__((format(printf, 4, 5))) __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...);
#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
void __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap);
void __attribute__((format(printf, 4, 0))) __ast_verbose_ap(const char *file, int line, const char *func, const char *fmt, va_list ap);
#define ast_verbose_ap(fmt, ap) __ast_verbose_ap(__FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ap)
void ast_child_verbose(int level, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
void __attribute__((format(printf, 2, 3))) ast_child_verbose(int level, const char *fmt, ...);
int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;

@ -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,
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
@ -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,
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

@ -597,7 +597,7 @@ enum {
* through calling one of the other functions or macros defined in this
* 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);
/*!
@ -638,7 +638,7 @@ int __ast_str_helper(struct ast_str **buf, size_t max_len,
* }
* \endcode
*/
AST_INLINE_API(int ast_str_set_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap),
AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap),
{
return __ast_str_helper(buf, max_len, 0, fmt, ap);
}
@ -649,7 +649,7 @@ AST_INLINE_API(int ast_str_set_va(struct ast_str **buf, size_t max_len, const ch
*
* Same as ast_str_set_va(), but append to the current content.
*/
AST_INLINE_API(int ast_str_append_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap),
AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_append_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap),
{
return __ast_str_helper(buf, max_len, 1, fmt, ap);
}

@ -334,7 +334,7 @@ static void check_goto_on_transfer(struct ast_channel *chan)
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;
for (x = goto_on_transfer; x && *x; x++) {

@ -1298,7 +1298,7 @@ void __ast_verbose(const char *file, int line, const char *func, const char *fmt
/* No new code should use this directly, but we have the ABI for backwards compat */
#undef ast_verbose
void ast_verbose(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void __attribute__((format(printf, 1,2))) ast_verbose(const char *fmt, ...);
void ast_verbose(const char *fmt, ...)
{
va_list ap;

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

@ -510,7 +510,7 @@ static struct ast_xml_node *xmldoc_get_node(const char *type, const char *name,
* \param syntax Output buffer for the concatenated values.
* \param fmt A format string that will be used in a sprintf call.
*/
static __attribute__((format(printf,4,5))) void xmldoc_reverse_helper(int reverse, int *len, char **syntax, const char *fmt, ...)
static void __attribute__((format(printf, 4, 5))) xmldoc_reverse_helper(int reverse, int *len, char **syntax, const char *fmt, ...)
{
int totlen, tmpfmtlen;
char *tmpfmt, tmp;

@ -68,6 +68,7 @@ AST_DEVMODE=@AST_DEVMODE@
AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@
AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@
AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@
AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@
ALSA_INCLUDE=@ALSA_INCLUDE@
ALSA_LIB=@ALSA_LIB@

Loading…
Cancel
Save