From: Tilghman Lesher Date: Thu, 7 Jan 2010 21:17:43 +0000 (+0000) Subject: Merged revisions 209400 via svnmerge from X-Git-Tag: 1.6.2.1-rc1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bc3fe1baac6ea5483209b02be5b8af1bd58cab2;p=thirdparty%2Fasterisk.git Merged revisions 209400 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r209400 | kpfleming | 2009-07-28 08:49:46 -0500 (Tue, 28 Jul 2009) | 3 lines Define side-effect-safe MIN and MAX macros and remove duplicate definitions from various files. (closes issue #16251) Reported by: asgaroth ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@238499 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 161093e857..0765308c9c 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -591,9 +591,6 @@ static struct ast_channel *alsa_request(const char *type, int fmt, void *data, i static char *autoanswer_complete(const char *line, const char *word, int pos, int state) { -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif switch (state) { case 0: if (!ast_strlen_zero(word) && !strncasecmp(word, "on", MIN(strlen(word), 2))) diff --git a/channels/chan_console.c b/channels/chan_console.c index a1376822b0..9e7ed3cf52 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -101,13 +101,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") */ #define TEXT_SIZE 256 -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - /*! \brief Dance, Kirby, Dance! @{ */ #define V_BEGIN " --- <(\"<) --- " #define V_END " --- (>\")> ---\n" diff --git a/channels/chan_oss.c b/channels/chan_oss.c index a7e41899a9..5fa0a50a19 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -229,13 +229,6 @@ END_CONFIG #define DEV_DSP "/dev/dsp" #endif -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - static char *config = "oss.conf"; /* default config file */ static int oss_debug; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index d5dccaa648..d9478d8deb 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -481,10 +481,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #define TRUE 1 #endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - /* Arguments for find_peer */ #define FINDUSERS (1 << 0) #define FINDPEERS (1 << 1) diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c index 9e5adb223b..f7b2066ce2 100644 --- a/channels/chan_usbradio.c +++ b/channels/chan_usbradio.c @@ -351,13 +351,6 @@ END_CONFIG #define DEV_DSP "/dev/dsp" #endif -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - static const char *config = "usbradio.conf"; /* default config file */ #define config1 "usbradio_tune_%s.conf" /* tune config file */ diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index fcbbdbd394..91de914b5c 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -220,6 +220,11 @@ void ast_sha1_hash(char *output, char *input); int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks); +#undef MIN +#define MIN(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a > __b) ? __b : __a);}) +#undef MAX +#define MAX(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); ((__a < __b) ? __b : __a);}) + /*! * \brief Encode data in base64 * \param dst the destination buffer diff --git a/main/poll.c b/main/poll.c index bb93125a6b..62e681dca8 100644 --- a/main/poll.c +++ b/main/poll.c @@ -83,14 +83,6 @@ #ifdef AST_POLL_COMPAT -/*---------------------------------------------------------------------------*\ - Macros -\*---------------------------------------------------------------------------*/ - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - /*---------------------------------------------------------------------------*\ Private Functions \*---------------------------------------------------------------------------*/