aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-29 16:58:29 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-29 16:58:29 +0000
commit81fa0b3582ba4f23dd3f6bfa576fdd7ac531a127 (patch)
tree2abe23f0b4942edf470a41b1a8cef51a073fc887
parente27acaa5de2958e98e05ddb82231231b73882945 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@159808 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--Makefile9
-rw-r--r--channels/chan_agent.c2
-rw-r--r--channels/chan_iax2.c6
-rw-r--r--channels/chan_misdn.c2
-rw-r--r--channels/chan_sip.c6
-rw-r--r--channels/chan_vpb.cc2
-rwxr-xr-xconfigure21
-rw-r--r--configure.ac18
-rw-r--r--include/asterisk/channel.h5
-rw-r--r--include/asterisk/cli.h2
-rw-r--r--include/asterisk/devicestate.h2
-rw-r--r--include/asterisk/dundi.h16
-rw-r--r--include/asterisk/linkedlists.h8
-rw-r--r--include/asterisk/lock.h8
-rw-r--r--include/asterisk/logger.h6
-rw-r--r--include/asterisk/manager.h4
-rw-r--r--include/asterisk/module.h8
-rw-r--r--include/asterisk/res_odbc.h2
-rw-r--r--include/asterisk/stringfields.h4
-rw-r--r--include/asterisk/strings.h4
-rw-r--r--include/asterisk/threadstorage.h10
-rw-r--r--include/asterisk/utils.h4
-rw-r--r--include/jitterbuf.h4
-rw-r--r--main/ast_expr2.c2
-rw-r--r--main/dns.c2
-rw-r--r--main/enum.c2
-rw-r--r--main/jitterbuf.c2
-rw-r--r--main/logger.c2
-rw-r--r--main/srv.c2
-rw-r--r--makeopts.in1
-rw-r--r--res/res_agi.c4
-rw-r--r--res/res_features.c2
-rw-r--r--utils/astman.c6
-rw-r--r--utils/check_expr.c2
-rw-r--r--utils/frame.c10
35 files changed, 111 insertions, 79 deletions
diff --git a/Makefile b/Makefile
index 16b69e607..185e58f88 100644
--- a/Makefile
+++ b/Makefile
@@ -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)),)
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 0e266fa5d..c15137bba 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -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) {
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 4d9165cac..f0c6cfe23 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -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];
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 9ea54bac1..9acbde1c7 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -291,7 +291,7 @@ static pthread_t misdn_tasks_thread;
static int *misdn_ports;
static void chan_misdn_log(int level, int port, char *tmpl, ...)
- __attribute__ ((format (printf, 3, 4)));
+ __attribute__((format(printf, 3, 4)));
static struct ast_channel *misdn_new(struct chan_list *cl, int state, char *exten, char *callerid, int format, int port, int c);
static void send_digit_to_chan(struct chan_list *cl, char digit );
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 0afe2d596..0eb2336d1 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -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?
@@ -1859,10 +1859,10 @@ static enum sip_result ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *
#define append_history(p, event, fmt , args... ) append_history_full(p, "%-15s " fmt, event, ## args)
static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
+ __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;
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index 359a4ddf0..56467a6ce 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -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;
diff --git a/configure b/configure
index 9490cde37..fc40eb4ab 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/configure.ac b/configure.ac
index 01b2c4058..44fff243e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -351,18 +351,28 @@ if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/nu
AC_MSG_RESULT(yes)
AST_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
else
- AC_MSG_RESULT(no)
- AST_DECLARATION_AFTER_STATEMENT=
+ AC_MSG_RESULT(no)
+ AST_DECLARATION_AFTER_STATEMENT=
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)
AST_NO_STRICT_OVERFLOW=-fno-strict-overflow
else
- AC_MSG_RESULT(no)
- AST_NO_STRICT_OVERFLOW=
+ AC_MSG_RESULT(no)
+ AST_NO_STRICT_OVERFLOW=
fi
AC_SUBST(AST_NO_STRICT_OVERFLOW)
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index ea4dac2bc..a550101ea 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -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 */
diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h
index 9a7b53a36..13d6fdd84 100644
--- a/include/asterisk/cli.h
+++ b/include/asterisk/cli.h
@@ -32,7 +32,7 @@ extern "C" {
#include "asterisk/linkedlists.h"
void ast_cli(int fd, char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
+ __attribute__((format(printf, 2, 3)));
#define RESULT_SUCCESS 0
#define RESULT_SHOWUSAGE 1
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h
index ed9022fbd..561bd2cb4 100644
--- a/include/asterisk/devicestate.h
+++ b/include/asterisk/devicestate.h
@@ -83,7 +83,7 @@ int ast_device_state(const char *device);
* Returns 0 on success, -1 on failure
*/
int ast_device_state_changed(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
+ __attribute__((format(printf, 1, 2)));
/*! \brief Tells Asterisk the State for Device is changed
diff --git a/include/asterisk/dundi.h b/include/asterisk/dundi.h
index 9290536d6..09dcea9ee 100644
--- a/include/asterisk/dundi.h
+++ b/include/asterisk/dundi.h
@@ -31,7 +31,7 @@
/*!\brief A DUNDi Entity ID is essentially a MAC address, brief and unique */
struct _dundi_eid {
unsigned char eid[6];
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
typedef struct _dundi_eid dundi_eid;
@@ -43,13 +43,13 @@ struct dundi_hdr {
unsigned char cmdresp; /*!< Command / Response */
unsigned char cmdflags; /*!< Command / Response specific flags*/
unsigned char ies[0];
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
struct dundi_ie_hdr {
unsigned char ie;
unsigned char len;
unsigned char iedata[0];
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
#define DUNDI_FLAG_RETRANS (1 << 16) /*!< Applies to dtrans */
#define DUNDI_FLAG_RESERVED (1 << 16) /*!< Applies to strans */
@@ -78,7 +78,7 @@ struct dundi_ie_hdr {
struct dundi_encblock { /*!< AES-128 encrypted block */
unsigned char iv[16]; /*!< Initialization vector of random data */
unsigned char encdata[0]; /*!< Encrypted / compressed data */
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
struct dundi_answer {
dundi_eid eid; /*!< Original source of answer */
@@ -86,12 +86,12 @@ struct dundi_answer {
unsigned short flags; /*!< Flags relating to answer */
unsigned short weight; /*!< Weight of answers */
unsigned char data[0]; /*!< Protocol specific URI */
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
struct dundi_hint {
unsigned short flags; /*!< Flags relating to answer */
unsigned char data[0]; /*!< For data for hint */
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
#define DUNDI_CAUSE_SUCCESS 0 /*!< Success */
#define DUNDI_CAUSE_GENERAL 1 /*!< General unspecified failure */
@@ -105,14 +105,14 @@ struct dundi_hint {
struct dundi_cause {
unsigned char causecode; /*!< Numerical cause (DUNDI_CAUSE_*) */
char desc[0]; /*!< Textual description */
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
struct dundi_peer_status {
unsigned int flags;
unsigned short netlag;
unsigned short querylag;
dundi_eid peereid;
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
#define DUNDI_PEER_PRIMARY (1 << 0)
#define DUNDI_PEER_SECONDARY (1 << 1)
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index a8d90ecbe..e7511fd8a 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -242,11 +242,11 @@ struct name { \
struct type *last; \
ast_mutex_t lock; \
} name; \
-static void __attribute__ ((constructor)) init_##name(void) \
+static void __attribute__((constructor)) init_##name(void) \
{ \
AST_LIST_HEAD_INIT(&name); \
} \
-static void __attribute__ ((destructor)) fini_##name(void) \
+static void __attribute__((destructor)) fini_##name(void) \
{ \
AST_LIST_HEAD_DESTROY(&name); \
} \
@@ -284,11 +284,11 @@ struct name { \
struct type *last; \
ast_rwlock_t lock; \
} name; \
-static void __attribute__ ((constructor)) init_##name(void) \
+static void __attribute__((constructor)) init_##name(void) \
{ \
AST_RWLIST_HEAD_INIT(&name); \
} \
-static void __attribute__ ((destructor)) fini_##name(void) \
+static void __attribute__((destructor)) fini_##name(void) \
{ \
AST_RWLIST_HEAD_DESTROY(&name); \
} \
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 3e684f838..bcf802451 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -799,14 +799,14 @@ static inline int ast_cond_timedwait(ast_cond_t *cond, ast_mutex_t *t, const str
destructors to destroy mutexes and create it on the fly. */
#define __AST_MUTEX_DEFINE(scope, mutex, init_val, track) \
scope ast_mutex_t mutex = init_val; \
-static void __attribute__ ((constructor)) init_##mutex(void) \
+static void __attribute__((constructor)) init_##mutex(void) \
{ \
if (track) \
ast_mutex_init(&mutex); \
else \
ast_mutex_init_notracking(&mutex); \
} \
-static void __attribute__ ((destructor)) fini_##mutex(void) \
+static void __attribute__((destructor)) fini_##mutex(void) \
{ \
ast_mutex_destroy(&mutex); \
}
@@ -1113,11 +1113,11 @@ static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock)
#ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER
#define __AST_RWLOCK_DEFINE(scope, rwlock) \
scope ast_rwlock_t rwlock; \
-static void __attribute__ ((constructor)) init_##rwlock(void) \
+static void __attribute__((constructor)) init_##rwlock(void) \
{ \
ast_rwlock_init(&rwlock); \
} \
-static void __attribute__ ((destructor)) fini_##rwlock(void) \
+static void __attribute__((destructor)) fini_##rwlock(void) \
{ \
ast_rwlock_destroy(&rwlock); \
}
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 58bf1804b..af0bb3c01 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -60,7 +60,7 @@ extern "C" {
\param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
*/
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
- __attribute__ ((format (printf, 5, 6)));
+ __attribute__((format(printf, 5, 6)));
void ast_backtrace(void);
@@ -68,7 +68,7 @@ void ast_backtrace(void);
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)));
+ __attribute__((format(printf, 5, 6)));
/*! 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.
@@ -78,7 +78,7 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent,
VERBOSE_PREFIX_1 through VERBOSE_PREFIX_3 are defined.
*/
void ast_verbose(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
+ __attribute__((format(printf, 1, 2)));
int ast_register_verbose(void (*verboser)(const char *string));
int ast_unregister_verbose(void (*verboser)(const char *string));
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index cc4e971c9..34ae43235 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -126,7 +126,7 @@ int astman_verify_session_writepermissions(uint32_t ident, int perm);
\param event Event name
\param contents Contents of event
*/
-int __attribute__ ((format (printf, 3,4))) manager_event(int category, const char *event, const char *contents, ...);
+int __attribute__((format(printf, 3,4))) manager_event(int category, const char *event, const char *contents, ...);
/*! Get header from mananger transaction */
const char *astman_get_header(const struct message *m, char *var);
@@ -139,7 +139,7 @@ void astman_send_error(struct mansession *s, const struct message *m, char *erro
void astman_send_response(struct mansession *s, const struct message *m, char *resp, char *msg);
void astman_send_ack(struct mansession *s, const struct message *m, char *msg);
-void __attribute__ ((format (printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
+void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, const char *fmt, ...);
/*! Called by Asterisk initialization */
int init_manager(void);
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index 4c1e40b1d..27eae4abe 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -237,11 +237,11 @@ void ast_module_unref(struct ast_module *);
flags_to_set | AST_MODFLAG_BUILDSUM, \
AST_BUILDOPT_SUM, \
}; \
- static void __attribute__ ((constructor)) __reg_module(void) \
+ static void __attribute__((constructor)) __reg_module(void) \
{ \
ast_module_register(&__mod_info); \
} \
- static void __attribute__ ((destructor)) __unreg_module(void) \
+ static void __attribute__((destructor)) __unreg_module(void) \
{ \
ast_module_unregister(&__mod_info); \
} \
@@ -268,11 +268,11 @@ const static __attribute__((unused)) struct ast_module_info *ast_module_info;
.buildopt_sum = AST_BUILDOPT_SUM, \
fields \
}; \
- static void __attribute__ ((constructor)) __reg_module(void) \
+ static void __attribute__((constructor)) __reg_module(void) \
{ \
ast_module_register(&__mod_info); \
} \
- static void __attribute__ ((destructor)) __unreg_module(void) \
+ static void __attribute__((destructor)) __unreg_module(void) \
{ \
ast_module_unregister(&__mod_info); \
} \
diff --git a/include/asterisk/res_odbc.h b/include/asterisk/res_odbc.h
index 4d023c066..4fbe007c4 100644
--- a/include/asterisk/res_odbc.h
+++ b/include/asterisk/res_odbc.h
@@ -61,7 +61,7 @@ struct odbc_obj {
* This function really only ever worked with MySQL, where the statement handle is
* not prepared on the server. If you are not using MySQL, you should avoid it.
*/
-int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__ ((deprecated));
+int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__((deprecated));
/*! \brief Retrieves a connected ODBC object
* \param name The name of the ODBC class for which a connection is needed.
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index d8d257f95..97e65532d 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -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
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index 70517a4d6..a7e2fa4ba 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -190,7 +190,7 @@ void ast_copy_string(char *dst, const char *src, size_t size),
\param fmt printf-style format string
\return 0 on success, non-zero on failure.
*/
-int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
+int ast_build_string(char **buffer, size_t *space, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
/*!
\brief Build a string in a buffer, designed to be called repeatedly
@@ -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 */
/*!
diff --git a/include/asterisk/threadstorage.h b/include/asterisk/threadstorage.h
index 59bd8cd72..2934a320b 100644
--- a/include/asterisk/threadstorage.h
+++ b/include/asterisk/threadstorage.h
@@ -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
@@ -406,7 +406,7 @@ int ast_dynamic_str_thread_build_va(struct ast_dynamic_str **buf, size_t max_len
* \endcode
*/
AST_INLINE_API(
-int __attribute__ ((format (printf, 4, 5))) ast_dynamic_str_thread_set(
+int __attribute__((format(printf, 4, 5))) ast_dynamic_str_thread_set(
struct ast_dynamic_str **buf, size_t max_len,
struct ast_threadstorage *ts, const char *fmt, ...),
{
@@ -429,7 +429,7 @@ int __attribute__ ((format (printf, 4, 5))) ast_dynamic_str_thread_set(
* the string, this function appends to the current value.
*/
AST_INLINE_API(
-int __attribute__ ((format (printf, 4, 5))) ast_dynamic_str_thread_append(
+int __attribute__((format(printf, 4, 5))) ast_dynamic_str_thread_append(
struct ast_dynamic_str **buf, size_t max_len,
struct ast_threadstorage *ts, const char *fmt, ...),
{
@@ -457,7 +457,7 @@ int __attribute__ ((format (printf, 4, 5))) ast_dynamic_str_thread_append(
* family of functions.
*/
AST_INLINE_API(
-int __attribute__ ((format (printf, 3, 4))) ast_dynamic_str_set(
+int __attribute__((format(printf, 3, 4))) ast_dynamic_str_set(
struct ast_dynamic_str **buf, size_t max_len,
const char *fmt, ...),
{
@@ -480,7 +480,7 @@ int __attribute__ ((format (printf, 3, 4))) ast_dynamic_str_set(
* of setting a new value.
*/
AST_INLINE_API(
-int __attribute__ ((format (printf, 3, 4))) ast_dynamic_str_append(
+int __attribute__((format(printf, 3, 4))) ast_dynamic_str_append(
struct ast_dynamic_str **buf, size_t max_len,
const char *fmt, ...),
{
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 4e4d9d5ee..7b7378530 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -474,7 +474,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi
#define ast_asprintf(ret, fmt, ...) \
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
-int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...) __attribute__ ((format (printf, 5, 6)));
+int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
/*!
* \brief A wrapper for vasprintf()
@@ -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;
diff --git a/include/jitterbuf.h b/include/jitterbuf.h
index dac903e83..45ec06f2d 100644
--- a/include/jitterbuf.h
+++ b/include/jitterbuf.h
@@ -151,8 +151,8 @@ 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, ...);
-void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
+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
}
diff --git a/main/ast_expr2.c b/main/ast_expr2.c
index 9133e76ea..66a680b56 100644
--- a/main/ast_expr2.c
+++ b/main/ast_expr2.c
@@ -179,7 +179,7 @@ enum valtype {
} ;
#ifdef STANDALONE
-void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
+void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6)));
#endif
struct val {
diff --git a/main/dns.c b/main/dns.c
index d57e6227a..dc0d3c818 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -148,7 +148,7 @@ struct dn_answer {
unsigned short class;
unsigned int ttl;
unsigned short size;
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
static int skip_name(unsigned char *s, int len)
{
diff --git a/main/enum.c b/main/enum.c
index aece8e572..3fa0bb977 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -92,7 +92,7 @@ AST_MUTEX_DEFINE_STATIC(enumlock);
struct naptr {
unsigned short order;
unsigned short pref;
-} __attribute__ ((__packed__));
+} __attribute__((__packed__));
/*! \brief Parse NAPTR record information elements */
static unsigned int parse_ie(char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen)
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index 2b081704a..849cffab5 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -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;
}
diff --git a/main/logger.c b/main/logger.c
index 8f6ebaf80..0d1ef4b71 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -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;
diff --git a/main/srv.c b/main/srv.c
index 97ad43cff..cf99ef3ec 100644
--- a/main/srv.c
+++ b/main/srv.c
@@ -77,7 +77,7 @@ static int parse_srv(unsigned char *answer, int len, unsigned char *msg, struct
unsigned short priority;
unsigned short weight;
unsigned short port;
- } __attribute__ ((__packed__)) *srv = (struct srv *) answer;
+ } __attribute__((__packed__)) *srv = (struct srv *) answer;
int res = 0;
char repl[256] = "";
diff --git a/makeopts.in b/makeopts.in
index eb54b59e3..790ba6e86 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -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@
diff --git a/res/res_agi.c b/res/res_agi.c
index a2ff4ef3e..1119a2d61 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -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:
diff --git a/res/res_features.c b/res/res_features.c
index ad165b036..d3aeeee01 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -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++) {
diff --git a/utils/astman.c b/utils/astman.c
index 757421725..ae2444ae7 100644
--- a/utils/astman.c
+++ b/utils/astman.c
@@ -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");
diff --git a/utils/check_expr.c b/utils/check_expr.c
index df1765db1..d3dcc5d19 100644
--- a/utils/check_expr.c
+++ b/utils/check_expr.c
@@ -41,7 +41,7 @@ struct varz *global_varlist;
/* Our own version of ast_log, since the expr parser uses it. */
-void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
+void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf,5,6)));
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
{
diff --git a/utils/frame.c b/utils/frame.c
index 52f2d498e..bdc65e12f 100644
--- a/utils/frame.c
+++ b/utils/frame.c
@@ -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;