IOT-1583: Adding /W4 and /WX to timer build.
authorPawel Winogrodzki <pawelwi@microsoft.com>
Wed, 15 Feb 2017 03:22:57 +0000 (19:22 -0800)
committerMike Fenelon <mike.fenelon@microsoft.com>
Wed, 8 Mar 2017 20:24:45 +0000 (20:24 +0000)
Making sure any version changes of timer don't introduce
level 4 warnings.

I'm also changing the return value of StartRetransmit() inside
ca_adapter_net_ssl.c, since it's being used as a timer callback,
which doesn't return any values. Nowhere in the code was the returned
value of that function read.

Change-Id: Ic401ae27c5af46b05a21868dfa0c020ee6429f20
Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17513
Reviewed-by: Alex Kelley <alexke@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Mike Fenelon <mike.fenelon@microsoft.com>
extlibs/timer/SConscript
extlibs/timer/timer.c
extlibs/timer/timer.h
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c

index 21c406e..27182b2 100644 (file)
@@ -22,10 +22,14 @@ Import('env')
 
 timer_env = env.Clone()
 
+target_os = timer_env.get('TARGET_OS')
+
 # Required for arduino builds to have access to Timer.h.
-if timer_env.get('TARGET_OS') == 'arduino':
+if target_os == 'arduino':
     timer_env.Replace(CC = env.get('CXX'))
     timer_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+elif target_os == 'windows':
+    timer_env.AppendUnique(CCFLAGS = ['/W4', '/WX'])
 
 libtimer = timer_env.StaticLibrary('timer', ['timer.c'], OBJPREFIX='libtimer_')
 timer_env.InstallTarget(libtimer, 'timer');
index 08b9a6e..acc784b 100755 (executable)
@@ -62,7 +62,7 @@ struct timelist_t
     int timeout_state;
     time_t timeout_seconds;
     time_t timeout_time;
-    void (*cb)();
+    TimerCallback cb;
 } timeout_list[TIMEOUTS];
 
 /*
@@ -108,7 +108,7 @@ long int getRelativeSecondsOfDayofweek(int ia, int ib)
     return (((long int)((ib - ia))) * SECS_PER_DAY);
 }
 
-long int getRelativeIntervalOfWeek(struct tm* tp)
+time_t getRelativeIntervalOfWeek(struct tm* tp)
 {
     time_t current_time;
     struct tm* current, *midnight;
@@ -148,7 +148,7 @@ long int getRelativeIntervalOfWeek(struct tm* tp)
     return delayed_time;
 }
 
-long int getSecondsFromAbsTime(struct tm* tp)
+time_t getSecondsFromAbsTime(struct tm* tp)
 {
    time_t current_time;
    time_t delayed_time = 0;
@@ -161,7 +161,7 @@ long int getSecondsFromAbsTime(struct tm* tp)
    return delayed_time;
 }
 
-time_t registerTimer(const time_t seconds, int *id, void *cb)
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb)
 {
     time_t now, then;
     time_t next;
@@ -255,13 +255,11 @@ void checkTimeout()
 void *loop(void *threadid)
 {
     (void)threadid;
-    while (1)
+    for (;;)
     {
         sleep(SECOND);
         checkTimeout();
     }
-
-    return NULL ;
 }
 
 int initThread()
@@ -287,7 +285,7 @@ time_t timeToSecondsFromNow(tmElements_t *t_then)
     return (time_t) (then - t);
 }
 
-time_t registerTimer(const time_t seconds, int *id,  void (*cb)())
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb)
 {
     time_t t, then;
     time_t next;
index ffa304c..4f51a1e 100644 (file)
@@ -46,24 +46,26 @@ extern "C"
 #define SECS_YR_2000  (946684800L)
 #endif
 
+typedef void(*TimerCallback)();
+
 time_t timespec_diff(const time_t after, const time_t before);
 void timespec_add(time_t * to, const time_t seconds);
 void checkTimeout();
 
 #ifndef WITH_ARDUINO
 long int getSeconds(struct tm* tp);
-long int getRelativeIntervalOfWeek(struct tm* tp);
-long int getSecondsFromAbsTime(struct tm* tp);
+time_t getRelativeIntervalOfWeek(struct tm* tp);
+time_t getSecondsFromAbsTime(struct tm* tp);
 
 int initThread();
 void *loop(void *threadid);
-time_t registerTimer(const time_t seconds, int *id, void *cb);
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb);
 void unregisterTimer(int id);
 
 #else
 
 time_t timeToSecondsFromNow(tmElements_t *t);
-time_t registerTimer(const time_t seconds, int *id,  void (*cb)());
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb);
 void unregisterTimer(int id);
 
 
index 0cd3bdd..ece2431 100755 (executable)
@@ -1560,7 +1560,7 @@ static int InitConfig(mbedtls_ssl_config * conf, int transport, int mode)
 /**
  * Starts DTLS retransmission.
  */
-static int StartRetransmit()
+static void StartRetransmit()
 {
     size_t listIndex = 0;
     size_t listLength = 0;
@@ -1571,7 +1571,7 @@ static int StartRetransmit()
     {
         OIC_LOG(ERROR, NET_SSL_TAG, "Context is NULL. Stop retransmission");
         oc_mutex_unlock(g_sslContextMutex);
-        return -1;
+        return;
     }
 
     if (g_caSslContext->timerId != -1)
@@ -1594,7 +1594,7 @@ static int StartRetransmit()
             if (MBEDTLS_ERR_SSL_CONN_EOF != ret)
             {
                 //start new timer
-                registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, (void *) StartRetransmit);
+                registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, StartRetransmit);
                 //unlock & return
                 if (!checkSslOperation(tep,
                                        ret,
@@ -1602,15 +1602,14 @@ static int StartRetransmit()
                                        MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE))
                 {
                     oc_mutex_unlock(g_sslContextMutex);
-                    return CA_STATUS_FAILED;
+                    return;
                 }
             }
         }
     }
     //start new timer
-    registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, (void *) StartRetransmit);
+    registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, StartRetransmit);
     oc_mutex_unlock(g_sslContextMutex);
-    return 0;
 }
 #endif