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



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@159808 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Kevin P. Fleming 17 years ago
parent a738a1f6e7
commit 50515ed372

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

@ -1035,7 +1035,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) {

@ -770,7 +770,7 @@ static void iax_error_output(const char *data)
ast_log(LOG_WARNING, "%s", data);
}
static void jb_error_output(const char *fmt, ...)
static void __attribute__((format(printf, 1, 2))) jb_error_output(const char *fmt, ...)
{
va_list args;
char buf[1024];
@ -782,7 +782,7 @@ static void jb_error_output(const char *fmt, ...)
ast_log(LOG_ERROR, "%s", buf);
}
static void jb_warning_output(const char *fmt, ...)
static void __attribute__((format(printf, 1, 2))) jb_warning_output(const char *fmt, ...)
{
va_list args;
char buf[1024];
@ -794,7 +794,7 @@ static void jb_warning_output(const char *fmt, ...)
ast_log(LOG_WARNING, "%s", buf);
}
static void jb_debug_output(const char *fmt, ...)
static void __attribute__((format(printf, 1, 2))) jb_debug_output(const char *fmt, ...)
{
va_list args;
char buf[1024];

@ -1813,7 +1813,7 @@ static void build_via(struct sip_pvt *p)
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
ast_string_field_build(p, via, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
ast_inet_ntoa(p->ourip), ourport, p->branch, rport);
ast_inet_ntoa(p->ourip), ourport, (int) p->branch, rport);
}
/*! \brief NAT fix - decide which IP address to use for ASterisk server?
@ -1862,7 +1862,7 @@ static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
/*! \brief Append to SIP dialog history with arg list */
static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
static void __attribute__((format(printf, 2, 0))) append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
{
char buf[80], *c = buf; /* max history length */
struct sip_history *hist;

@ -2495,7 +2495,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: 151241 .
# From configure.ac Revision: 159025 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.4.
#
@ -887,6 +887,7 @@ POW_LIB
GC_CFLAGS
GC_LDFLAGS
AST_DECLARATION_AFTER_STATEMENT
AST_FORTIFY_SOURCE
AST_NO_STRICT_OVERFLOW
PBX_DAHDI_TRANSCODE
GSM_INTERNAL
@ -15383,6 +15384,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
@ -32482,6 +32496,7 @@ POW_LIB!$POW_LIB$ac_delim
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
PBX_DAHDI_TRANSCODE!$PBX_DAHDI_TRANSCODE$ac_delim
GSM_INTERNAL!$GSM_INTERNAL$ac_delim
@ -32504,7 +32519,6 @@ PBX_ZAPTEL_VLDTMF!$PBX_ZAPTEL_VLDTMF$ac_delim
EDITLINE_LIB!$EDITLINE_LIB$ac_delim
PBX_H323!$PBX_H323$ac_delim
PBX_IXJUSER!$PBX_IXJUSER$ac_delim
GTKCONFIG!$GTKCONFIG$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@ -32546,6 +32560,7 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
GTKCONFIG!$GTKCONFIG$ac_delim
PBX_GTK!$PBX_GTK$ac_delim
GTK_INCLUDE!$GTK_INCLUDE$ac_delim
GTK_LIB!$GTK_LIB$ac_delim
@ -32557,7 +32572,7 @@ 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` = 9; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 10; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

@ -356,6 +356,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)

@ -627,7 +627,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state);
by default set to the "default" context and
extension "s"
*/
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 */
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);
@ -1152,8 +1152,7 @@ void ast_set_callerid(struct ast_channel *chan, const char *cidnum, const char *
/*! return a mallocd string with the result of sprintf of the fmt and following args */
char *ast_safe_string_alloc(const char *fmt, ...);
char __attribute__((format(printf, 1, 2))) *ast_safe_string_alloc(const char *fmt, ...);
/*! Start a tone going */

@ -165,7 +165,7 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr
*/
void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
ast_string_field *fields, int num_fields,
int index, const char *format, ...);
int index, const char *format, ...) __attribute__((format(printf, 5, 6)));
/*!
\internal
@ -181,7 +181,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
*/
void __ast_string_field_index_build_va(struct ast_string_field_mgr *mgr,
ast_string_field *fields, int num_fields,
int index, const char *format, va_list a1, va_list a2);
int index, const char *format, va_list a1, va_list a2) __attribute__((format(printf, 5, 0)));
/*!
\brief Declare a string field

@ -204,7 +204,7 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attri
\param fmt printf-style format string
\param ap varargs list of arguments for format
*/
int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap);
int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format(printf, 3, 0)));
/*! Make sure something is true */
/*!

@ -364,7 +364,7 @@ enum {
* writing over it.
*/
int ast_dynamic_str_thread_build_va(struct ast_dynamic_str **buf, size_t max_len,
struct ast_threadstorage *ts, int append, const char *fmt, va_list ap);
struct ast_threadstorage *ts, int append, const char *fmt, va_list ap) __attribute__((format(printf, 5, 0)));
/*!
* \brief Set a thread locally stored dynamic string using variable arguments

@ -488,7 +488,7 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
AST_INLINE_API(
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
int __attribute__((format(printf, 5, 0))) _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
{
int res;

@ -151,7 +151,7 @@ enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats);
/* set jitterbuf conf */
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
typedef void (*jb_output_function_t)(const char *fmt, ...);
typedef void __attribute__((format(printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...);
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
#ifdef __cplusplus

@ -565,7 +565,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, long now,
/* if a hard clamp was requested, use it */
if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) {
jb_dbg("clamping target from %d to %d\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf);
jb_dbg("clamping target from %ld to %ld\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf);
jb->info.target = jb->info.min + jb->info.conf.max_jitterbuf;
}

@ -655,7 +655,7 @@ void close_logger(void)
return;
}
static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args)
static void __attribute__((format(printf, 5, 0))) ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *fmt, va_list args)
{
char buf[BUFSIZ];
char *s;

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

@ -119,7 +119,7 @@ enum agi_result {
AGI_RESULT_HANGUP
};
static int agi_debug_cli(int fd, char *fmt, ...)
static int __attribute__((format(printf, 2, 3))) agi_debug_cli(int fd, char *fmt, ...)
{
char *stuff;
int res = 0;
@ -1815,7 +1815,7 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf)
switch(res) {
case RESULT_SHOWUSAGE:
fdprintf(agi->fd, "520-Invalid command syntax. Proper usage follows:\n");
fdprintf(agi->fd, c->usage);
fdprintf(agi->fd, "%s", c->usage);
fdprintf(agi->fd, "520 End of proper usage.\n");
break;
case AST_PBX_KEEPALIVE:

@ -198,7 +198,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++) {

@ -140,7 +140,7 @@ static void del_chan(char *name)
AST_LIST_TRAVERSE_SAFE_END
}
static void fdprintf(int fd, char *fmt, ...)
static void __attribute__((format(printf, 2, 3))) fdprintf(int fd, char *fmt, ...)
{
char stuff[4096];
va_list ap;
@ -397,7 +397,7 @@ static struct message *wait_for_response(int timeout)
return NULL;
}
static int manager_action(char *action, char *fmt, ...)
static int __attribute__((format(printf, 2, 3))) manager_action(char *action, char *fmt, ...)
{
struct ast_mansession *s;
char tmp[4096];
@ -459,7 +459,7 @@ static int hide_doing(void)
static void try_status(void)
{
struct message *m;
manager_action("Status", "");
manager_action("Status", "%s", "");
m = wait_for_response(10000);
if (!m) {
show_message("Status Failed", "Timeout waiting for response");

@ -968,7 +968,7 @@ int workloop( FILE *theinfile, FILE *theoutfile,
return TRUE; /* Input file done with, no errors. */
}
int chat( const char *format, ...)
int __attribute__((format(printf, 1, 2))) chat( const char *format, ...)
{
va_list ap;
int result = 0;
@ -983,7 +983,7 @@ int chat( const char *format, ...)
}
int inform( const char *format, ...)
int __attribute__((format(printf, 1, 2))) inform( const char *format, ...)
{
va_list ap;
int result = 0;
@ -997,7 +997,7 @@ int inform( const char *format, ...)
return result;
}
int error( const char *format, ...)
int __attribute__((format(printf, 1, 2))) error( const char *format, ...)
{
va_list ap;
int result;
@ -1008,7 +1008,7 @@ int error( const char *format, ...)
return result;
}
void fatalerror( const char *format, ...)
void __attribute__((format(printf, 1, 2))) fatalerror( const char *format, ...)
{
va_list ap;
@ -1024,7 +1024,7 @@ void fatalperror( const char *string)
myexit( 1);
}
int say( const char *format, ...)
int __attribute__((format(printf, 1, 2))) say( const char *format, ...)
{
va_list ap;
int result;

Loading…
Cancel
Save