merge rizzo's patch to make compiler warnings stop the build, and fix a bunch of...
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 22 Feb 2006 22:53:49 +0000 (22:53 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 22 Feb 2006 22:53:49 +0000 (22:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10805 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
apps/app_sms.c
channels/Makefile
channels/chan_sip.c
codecs/gsm/Makefile
funcs/func_enum.c
include/asterisk/sha1.h
res/res_features.c
res/res_osp.c
say.c

index b9819b4..27529e0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -233,6 +233,10 @@ endif
 INCLUDE+=-Iinclude -I../include
 ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
 ASTCFLAGS+=$(OPTIMIZE)
+ASTCFLAGS+= -Werror -Wunused
+ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
+ASTCFLAGS+= -Wno-pointer-sign
+endif
 ASTOBJ=-o asterisk
 
 ifeq ($(findstring BSD,$(OSARCH)),BSD)
index eeb20b4..d9b85bf 100644 (file)
@@ -693,7 +693,7 @@ static void sms_readfile (sms_t * h, char *fn)
                }
                while (fgets (line, sizeof (line), s))
                {                                                                /* process line in file */
-                       char *p;
+                       unsigned char *p;
                        for (p = line; *p && *p != '\n' && *p != '\r'; p++);
                        *p = 0;                                  /* strip eoln */
                        p = line;
@@ -713,7 +713,7 @@ static void sms_readfile (sms_t * h, char *fn)
                                {                                                /* parse message (UTF-8) */
                                        unsigned char o = 0;
                                        while (*p && o < SMSLEN)
-                                               h->ud[o++] = utf8decode((unsigned char **)&p);
+                                               h->ud[o++] = utf8decode(&p);
                                        h->udl = o;
                                        if (*p)
                                                ast_log (LOG_WARNING, "UD too long in %s\n", fn);
index 6613a49..8ebcfc5 100644 (file)
@@ -222,7 +222,7 @@ chan_nbs.so: chan_nbs.o
        $(CC) $(SOLINK) -o $@ $< -lnbs
 
 chan_vpb.o: chan_vpb.c
-       $(CXX) -c $(CFLAGS) -o $@ chan_vpb.c
+       $(CXX) -c $(CFLAGS:-Werror=) -o $@ chan_vpb.c
 
 chan_vpb.so: chan_vpb.o
         $(CXX) $(SOLINK) -o $@ $< -lvpb -lpthread -lm -ldl
index d1229e7..bf11e57 100644 (file)
@@ -12097,7 +12097,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
        int obproxyfound=0;
        int found=0;
        int format=0;           /* Ama flags */
-       time_t regseconds;
+       time_t regseconds = 0;
        char *varname = NULL, *varval = NULL;
        struct ast_variable *tmpvar = NULL;
        struct ast_flags peerflags = {(0)};
index 3f283a1..8c0cf99 100644 (file)
@@ -364,7 +364,7 @@ TOAST_INSTALL_TARGETS =     \
 # Default rules
 
 .c.o:
-               $(CC) $(CFLAGS) $?
+               $(CC) $(CFLAGS:-Werror=) $?
                @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
 
 # Target rules
index 51eb61e..806118a 100644 (file)
@@ -88,7 +88,7 @@ static int function_enum(struct ast_channel *chan, char *cmd, char *data,
                args.options = "1";
 
        /* strip any '-' signs from number */
-       for (p = args.number, s = p; *s; *s++) {
+       for (s = p = args.number; *s; s++) {
                if (*s != '-')
                        *p++ = *s;
        }
index 5bf4d5b..fa8e215 100644 (file)
@@ -32,7 +32,6 @@
  *    name              meaning
  *  uint32_t         unsigned 32 bit integer
  *  uint8_t          unsigned 8 bit integer (i.e., unsigned char)
- *  int_least16_t    integer of >= 16 bits
  *
  */
 
@@ -60,7 +59,7 @@ typedef struct SHA1Context
     uint32_t Length_High;           /* Message length in bits      */
 
                                /* Index into message block array   */
-    int_least16_t Message_Block_Index;
+    uint32_t Message_Block_Index;      /* 8 bits actually suffice */
     uint8_t Message_Block[64];      /* 512-bit message blocks      */
 
     int Computed;               /* Is the digest computed?         */
index 1c4421c..b702991 100644 (file)
@@ -483,7 +483,7 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
                        len = strlen(touch_monitor) + 50;
                        args = alloca(len);
                        touch_filename = alloca(len);
-                       snprintf(touch_filename, len, "auto-%ld-%s", time(NULL), touch_monitor);
+                       snprintf(touch_filename, len, "auto-%ld-%s", (long)time(NULL), touch_monitor);
                        snprintf(args, len, "%s|%s|m", (touch_format) ? touch_format : "wav", touch_filename);
                } else {
                        caller_chan_id = ast_strdupa(caller_chan->cid.cid_num ? caller_chan->cid.cid_num : caller_chan->name);
@@ -491,7 +491,7 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
                        len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
                        args = alloca(len);
                        touch_filename = alloca(len);
-                       snprintf(touch_filename, len, "auto-%ld-%s-%s", time(NULL), caller_chan_id, callee_chan_id);
+                       snprintf(touch_filename, len, "auto-%ld-%s-%s", (long)time(NULL), caller_chan_id, callee_chan_id);
                        snprintf(args, len, "%s|%s|m", (touch_format) ? touch_format : "wav", touch_filename);
                }
 
index 339096a..65b6a57 100644 (file)
@@ -568,7 +568,7 @@ int ast_osp_lookup(struct ast_channel *chan, char *provider, char *extension, ch
        char destination[2048]="";
        char token[2000];
        char tmp[256]="", *l, *n;
-       char *devinfo = NULL;
+       const char *devinfo = NULL;
 
        result->handle = -1;
        result->numresults = 0;
diff --git a/say.c b/say.c
index cbbe589..ff881c7 100644 (file)
--- a/say.c
+++ b/say.c
@@ -3114,13 +3114,14 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -3150,13 +3151,14 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -3336,13 +3338,14 @@ int ast_say_date_with_format_da(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -3362,13 +3365,14 @@ int ast_say_date_with_format_da(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -3534,13 +3538,14 @@ int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -3560,10 +3565,11 @@ int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
                                        beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
@@ -3742,14 +3748,15 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
                                        char todo = format[offset]; /* The letter to format*/
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                if (todo == 'Q') {
@@ -3902,13 +3909,14 @@ int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -3928,13 +3936,14 @@ int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -4126,13 +4135,14 @@ int ast_say_date_with_format_fr(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -4152,13 +4162,14 @@ int ast_say_date_with_format_fr(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -4332,15 +4343,16 @@ int ast_say_date_with_format_it(struct ast_channel *chan, time_t time, const cha
                                 * language to say the date, with changes in what you say, depending
                                 * upon how recent the date is. XXX */
                                {
-                               struct timeval now;
+                                       struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
        
-                               gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       gettimeofday(&now,NULL);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -4357,13 +4369,14 @@ int ast_say_date_with_format_it(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
        
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -4562,13 +4575,14 @@ int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -4585,13 +4599,14 @@ int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -4777,13 +4792,14 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -4803,13 +4819,14 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -5053,13 +5070,14 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                                res = wait_file(chan,ints, "digits/today",lang);
@@ -5079,13 +5097,14 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha
                                {
                                        struct timeval now;
                                        struct tm tmnow;
-                                       time_t beg_today;
+                                       time_t beg_today, tt;
 
                                        gettimeofday(&now,NULL);
-                                       ast_localtime(&now.tv_sec,&tmnow,timezone);
+                                       tt = now.tv_sec;
+                                       ast_localtime(&tt,&tmnow,timezone);
                                        /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                        /* In any case, it saves not having to do ast_mktime() */
-                                       beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                                       beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                        if (beg_today < time) {
                                                /* Today */
                                        } else if ((beg_today - 86400) < time) {
@@ -6092,13 +6111,14 @@ static int ast_say_date_with_format_gr(struct ast_channel *chan, time_t time, co
                        {
                                struct timeval now;
                                struct tm tmnow;
-                               time_t beg_today;
+                               time_t beg_today, tt;
                                
                                gettimeofday(&now,NULL);
-                               ast_localtime(&now.tv_sec,&tmnow,timezone);
+                               tt = now.tv_sec;
+                               ast_localtime(&tt,&tmnow,timezone);
                                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                /* In any case, it saves not having to do ast_mktime() */
-                               beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                               beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                if (beg_today < time) {
                                        /* Today */
                                        res = wait_file(chan,ints, "digits/today",lang);
@@ -6118,13 +6138,14 @@ static int ast_say_date_with_format_gr(struct ast_channel *chan, time_t time, co
                        {
                                struct timeval now;
                                struct tm tmnow;
-                               time_t beg_today;
+                               time_t beg_today, tt;
                                
                                gettimeofday(&now,NULL);
-                               ast_localtime(&now.tv_sec,&tmnow,timezone);
+                               tt = now.tv_sec;
+                               ast_localtime(&tt,&tmnow,timezone);
                                /* This might be slightly off, if we transcend a leap second, but never more off than 1 second */
                                /* In any case, it saves not having to do ast_mktime() */
-                               beg_today = now.tv_sec - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
+                               beg_today = tt - (tmnow.tm_hour * 3600) - (tmnow.tm_min * 60) - (tmnow.tm_sec);
                                if (beg_today < time) {
                                        /* Today */
                                } else if ((beg_today - 86400) < time) {