Prepare for merge. Improved consistency and style.
authorDavid Antler <david.a.antler@intel.com>
Tue, 28 Jun 2016 21:50:16 +0000 (14:50 -0700)
committerDavid Antler <david.a.antler@intel.com>
Fri, 1 Jul 2016 21:18:59 +0000 (21:18 +0000)
* Reformat Windows SConscript to use spaces and add TODO
* Add TODO about most critical warnings to re-enable
* Fix unassigned declarations, use designated initializer when possible
* Fix various spacing and doxygen issues
* Improve consistency of macro definitions in platform_features.h
* Include failure codes on assert conditions for win_sleep.c

Change-Id: I0e88cf2a3fa0ed6e2f8822a6ce0b606a9070af64
Signed-off-by: David Antler <david.a.antler@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9041
Reviewed-by: Daniel Jay Ferguson <daniel.j.ferguson@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
31 files changed:
build_common/windows/SConscript
extlibs/timer/timer.c
resource/c_common/oic_time/src/oic_time.c
resource/c_common/platform_features.h
resource/c_common/windows/include/getopt.h
resource/c_common/windows/include/pthread_create.h
resource/c_common/windows/include/vs12_snprintf.h
resource/c_common/windows/include/win_sleep.h
resource/c_common/windows/src/getopt.c
resource/c_common/windows/src/snprintf.c
resource/c_common/windows/src/win_sleep.c
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/src/ip_adapter/windows/caipnwmonitor.c
resource/csdk/routing/src/routingutility.c
resource/csdk/security/include/internal/srmresourcestrings.h
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/src/directpairing.c
resource/csdk/security/src/iotvticalendar.c
resource/csdk/security/src/strptime.c
resource/csdk/stack/src/oicgroup.c
resource/examples/lightserver.cpp
resource/examples/presenceserver.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/simpleserver.cpp
resource/examples/simpleserverHQ.cpp
resource/examples/threadingsample.cpp
resource/include/OCApi.h
resource/include/OCRepresentation.h
resource/src/InProcClientWrapper.cpp
resource/src/OCRepresentation.cpp
service/resource-directory/src/rd_server.c

index bf57dee..39e7fd2 100644 (file)
@@ -6,37 +6,40 @@ import os.path
 
 # Set common flags
 if env['CC'] == 'cl':
-       # C4244 conversion from one type to another type results in a possible loss of data.
-       # C4267 conversion from size_t to a smaller type.
-       # C4355 'this' used in base member initializer list.
-       # C4800 forcing value to bool 'true' or 'false'.
-       # C4996 deprecated declaration.
-       # C4820 added padding to the end of a struct.
-       # C4514 unreferenced inline function has been removed
-       # C4365 signed/unsigned mismatch
-       # C4503 decorated name length exceeded, name was truncated
-       env.AppendUnique(CXXFLAGS=['/wd4244', '/wd4267', '/wd4355', '/wd4800', '/wd4996', '/wd4820', '/wd4514', '/wd4365', '/wd4503'])
-       env.AppendUnique(CCFLAGS=['/EHsc'])
 
-       vs_version = env['MSVC_VERSION']
+    # TODO: re-enable warnings, especially: 4244, 4267, 4365
+    env.AppendUnique(CXXFLAGS=[
+        '/wd4244',   # C4244 conversion from one type to another type results in a possible loss of data.
+        '/wd4267',   # C4267 conversion from size_t to a smaller type.
+        '/wd4355',   # C4355 'this' used in base member initializer list.
+        '/wd4800',   # C4800 forcing value to bool 'true' or 'false'.
+        '/wd4996',   # C4996 deprecated declaration.
+        '/wd4820',   # C4820 added padding to the end of a struct.
+        '/wd4514',   # C4514 unreferenced inline function has been removed
+        '/wd4365',   # C4365 signed/unsigned mismatch
+        '/wd4503'])  # C4503 decorated name length exceeded, name was truncated
 
-       # Enable special exports for unit test purposes
-       if env.get('TEST') == '1':
-               env.AppendUnique(CPPDEFINES = ['ENABLE_TEST_EXPORTS'])
-       # Set release/debug flags
-       if env.get('RELEASE'):
-               env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
-               env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-       elif env.get('TARGET_ARCH') in ['x86', 'x86_64'] or "14.0" in vs_version:
-               env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/ZI', '/RTC1', '/Gm'])
-               env.AppendUnique(LINKFLAGS = ['/debug'])
-       else:
-               env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/Zi', '/RTC1', '/Gm'])
-               env.AppendUnique(LINKFLAGS = ['/debug'])
-       env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-       env.AppendUnique(PATH = os.environ['PATH'])
+    env.AppendUnique(CCFLAGS=['/EHsc'])
+
+    vs_version = env['MSVC_VERSION']
+
+    # Enable special exports for unit test purposes
+    if env.get('TEST') == '1':
+        env.AppendUnique(CPPDEFINES = ['ENABLE_TEST_EXPORTS'])
+    # Set release/debug flags
+    if env.get('RELEASE'):
+        env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
+        env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+    elif env.get('TARGET_ARCH') in ['x86', 'x86_64'] or "14.0" in vs_version:
+        env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/ZI', '/RTC1', '/Gm'])
+        env.AppendUnique(LINKFLAGS = ['/debug'])
+    else:
+        env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/Zi', '/RTC1', '/Gm'])
+        env.AppendUnique(LINKFLAGS = ['/debug'])
+    env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+    env.AppendUnique(PATH = os.environ['PATH'])
 
 elif env['CC'] == 'gcc':
-       print "\nError: gcc not supported on Windows.  Use Visual Studio!\n"
-       Exit(1);
+    print "\nError: gcc not supported on Windows.  Use Visual Studio!\n"
+    Exit(1);
 
index 88deb05..3dda84b 100755 (executable)
@@ -266,9 +266,7 @@ void *loop(void *threadid)
 
 int initThread()
 {
-    int res;
-
-    res = pthread_create(&thread_id, NULL, loop, NULL);
+    int res = pthread_create(&thread_id, NULL, loop, NULL);
 
     if (res)
     {
index 4a07ceb..0cf2388 100644 (file)
@@ -54,15 +54,14 @@ uint64_t OICGetCurrentTime(OICTimePrecision precision)
     currentTime = (TIME_IN_MS == precision) ? millis() : micros();
 #elif defined(_WIN32)
     FILETIME fileTime;
-    ULARGE_INTEGER time;
 
     GetSystemTimePreciseAsFileTime(&fileTime);
 
     // fileTime should now be a QWORD hundred-nanoseconds time since 1601
 
     // MSDN recommends using ULARGE_INTEGER as an intermediate representation for math.
-    time.LowPart = fileTime.dwLowDateTime;
-    time.HighPart = fileTime.dwHighDateTime;
+    ULARGE_INTEGER time = { .LowPart  = fileTime.dwLowDateTime,
+                            .HighPart = fileTime.dwHighDateTime };
 
     currentTime =
     (TIME_IN_MS == precision)
index 680f367..4335e49 100644 (file)
 
 
 #if (__cplusplus >=201103L) || defined(__GXX_EXPERIMENTAL_CXX0X__)
-    #define SUPPORTS_DEFAULT_CTOR
+#  define SUPPORTS_DEFAULT_CTOR
 #endif
 
 #if (__STDC_VERSION__ >= 201112L)
-    #include <assert.h>
-    #define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
+#  include <assert.h>
+#  define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
 #elif defined(_WIN32)
-    #if defined(__msys_nt__) && !defined(__cplusplus)
-        #define static_assert _Static_assert
-    #endif
-    #define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
+#  if defined(__msys_nt__) && !defined(__cplusplus)
+#    define static_assert _Static_assert
+#  endif
+#  define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
 #else
-    #define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
+#  define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
 #endif
 
 #ifndef INLINE_API
index 8e11854..afa578e 100644 (file)
@@ -1,7 +1,7 @@
 /** @todo: Add Microsoft license information */
 
-#ifndef __GETOPT_H__
-#define __GETOPT_H__
+#ifndef GETOPT_H__
+#define GETOPT_H__
 
 #ifdef __cplusplus
 extern "C" {
index 80677ad..de8cf46 100644 (file)
@@ -1,7 +1,7 @@
 /** @todo: Add Microsoft license information */
 
-#ifndef __PTHREAD_CREATE_H__
-#define __PTHREAD_CREATE_H__
+#ifndef PTHREAD_CREATE_H__
+#define PTHREAD_CREATE_H__
 #ifndef WIN_PTHREADS_H
 
 #ifdef __cplusplus
index 37f1d3f..6416332 100644 (file)
 *
 ******************************************************************/
 
-#ifndef __VS12_SNPRINTF_H__
-#define __VS12_SNPRINTF_H__
+#ifndef VS12_SNPRINTF_H__
+#define VS12_SNPRINTF_H__
+
+#include <stdlib.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <stdlib.h>
-
 int vs12_snprintf(char *buffer, size_t count, const char *format, ...);
 
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
index 8cd1479..e03eaa5 100644 (file)
@@ -17,8 +17,8 @@
 *
 ******************************************************************/
 
-#ifndef __WIN_SLEEP_H__
-#define __WIN_SLEEP_H__
+#ifndef WIN_SLEEP_H__
+#define WIN_SLEEP_H__
 
 #include <time.h>
 
index d27ae09..abc4184 100644 (file)
@@ -3,10 +3,6 @@
 #include "getopt.h"
 #include <windows.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 char* optarg = NULL;
 int optind = 1;
 
@@ -20,12 +16,15 @@ int getopt(int argc, char *const argv[], const char *optstring)
     int opt = argv[optind][1];
     const char *p = strchr(optstring, opt);
 
-    if (p == NULL) {
+    if (p == NULL)
+    {
         return '?';
     }
-    if (p[1] == ':') {
+    if (p[1] == ':')
+    {
         optind++;
-        if (optind >= argc) {
+        if (optind >= argc)
+        {
             return '?';
         }
         optarg = argv[optind];
@@ -34,7 +33,3 @@ int getopt(int argc, char *const argv[], const char *optstring)
     return opt;
 }
 
-#ifdef __cplusplus
-}
-#endif
-
index 01e4f16..c9c7de5 100644 (file)
 
 int vs12_snprintf(char *buffer, size_t count, const char *format, ...)
 {
-    int length;
     va_list args;
 
     va_start(args, format);
 
-    length = _vsnprintf(buffer, count, format, args);
+    int length = _vsnprintf(buffer, count, format, args);
 
     va_end(args);
 
index f8f72f3..43d7194 100644 (file)
 
 #include <assert.h>
 #include <windows.h>
+#include <errno.h>
 #include "win_sleep.h"
 
+#include "logger.h"
+#define TAG  "WIN_SLEEP"
+
 #define NS_PER_MS  (1000000)
 #define US_PER_MS  (1000)
 
+#define ASSERT_AND_FAIL(EXPRESSION) {    \
+    assert((EXPRESSION));                \
+    if (!(EXPRESSION))                   \
+    {                                    \
+        errno = EINVAL;                  \
+        return -1;                       \
+    }                                    \
+}
+
 int usleep(unsigned int usec)
 {
     assert((usec % US_PER_MS) == 0); // granularity check
-    Sleep(usec / US_PER_MS);
+    Sleep((usec + US_PER_MS - 1) / US_PER_MS);
     return 0;
 }
 
 int nanosleep(const struct timespec *req, struct timespec *rem)
 {
-    assert(req != NULL);
-    assert(rem == NULL);
-    assert(req->tv_sec == 0);
+    if (req == NULL)
+    {
+        OIC_LOG(DEBUG, TAG, "nanosleep: req param should not be null");
+    }
+    ASSERT_AND_FAIL(req != NULL);
+    ASSERT_AND_FAIL(rem == NULL);
+    ASSERT_AND_FAIL(req->tv_sec == 0);
     assert((req->tv_nsec % NS_PER_MS) == 0); // granularity check
 
-    Sleep(req->tv_nsec / NS_PER_MS);
+    Sleep((req->tv_nsec + NS_PER_MS - 1) / NS_PER_MS);
 
     return 0;
 }
index d10d7d1..130c3da 100644 (file)
@@ -133,7 +133,7 @@ typedef char *CAURI_t;
  */
 typedef char *CAToken_t;
 
-/**
+/*
  * Socket types and error definitions
  */
 #ifdef HAVE_WINSOCK2_H
@@ -146,14 +146,16 @@ typedef HANDLE CASocketFd_t;
 typedef int    CASocketFd_t;
 #endif
 
-/** The following flags are the same as the equivalent OIC values in
+/*
+ * The following flags are the same as the equivalent OIC values in
  * octypes.h, allowing direct copying with slight fixup.
  * The CA layer should used the OC types when build allows that.
  */
 #ifdef RA_ADAPTER
 #define MAX_ADDR_STR_SIZE_CA (256)
 #else
-/** Max Address could be "coap+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx"
+/*
+ * Max Address could be "coap+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx"
  * Which is 64, +1 for null terminator => 65
  * OCDevAddr (defined in OCTypes.h) must be the same
  * as CAEndpoint_t (defined here)
index a6b2e38..7d3088f 100644 (file)
@@ -35,7 +35,8 @@
 
 #define TAG "IP_MONITOR"
 
-/** @todo Implement network interface monitoring in case the IP changes.
+/**
+ * @todo Implement network interface monitoring in case the IP changes.
  * Not critical for win32 bring-up.
  */
 CAResult_t CAIPStartNetworkMonitor()
@@ -43,7 +44,8 @@ CAResult_t CAIPStartNetworkMonitor()
     return CA_STATUS_OK;
 }
 
-/** @todo Implement network interface monitoring in case the IP changes.
+/**
+ * @todo Implement network interface monitoring in case the IP changes.
  * Not critical for win32 bring-up.
  */
 CAResult_t CAIPStopNetworkMonitor()
@@ -51,18 +53,20 @@ CAResult_t CAIPStopNetworkMonitor()
     return CA_STATUS_OK;
 }
 
-/** @todo Implement network interface monitoring.
- *  Not used in win32, but caipserver currently requires this function
- *  be defined. not critical.
+/**
+ * @todo Implement network interface monitoring.
+ * Not used in win32, but caipserver currently requires this function
+ * be defined. not critical.
  */
 int CAGetPollingInterval(int interval)
 {
     return interval;
 }
 
-/** @todo Implement network interface monitoring.
- *  Not used in win32, but caipserver currently requires this function
- *  be defined. not critical.
+/**
+ * @todo Implement network interface monitoring.
+ * Not used in win32, but caipserver currently requires this function
+ * be defined. not critical.
  */
 CAInterface_t *CAFindInterfaceChange()
 {
@@ -70,7 +74,8 @@ CAInterface_t *CAFindInterfaceChange()
     return foundNewInterface;
 }
 
-/** @todo Implement network interface monitoring.
+/**
+ * @todo Implement network interface monitoring.
  * Not critical for win32 bring-up.
  */
 void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
index 394401a..d9b8816 100644 (file)
@@ -320,11 +320,8 @@ OCStackResult RMCreateRouteOption(const RMRouteOption_t *optValue, CAHeaderOptio
     OIC_LOG_V(DEBUG, RM_TAG, "createoption dlen %u slen [%u]", dLen, sLen);
 
     unsigned int totalLength = 0;
-#if defined(_MSC_VER)
-    char *tempData = NULL;
-#else
-    void *tempData = NULL;
-#endif
+    uint8_t *tempData = NULL;
+
     if (0 == dLen && 0 == sLen)
     {
         OIC_LOG(DEBUG, RM_TAG, "Source and destination is not present");
index ca185d6..3ba9e62 100644 (file)
 #ifndef IOTVT_SRM_RSRC_STRINGS_H
 #define IOTVT_SRM_RSRC_STRINGS_H
 
+#include "securevirtualresourcetypes.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "securevirtualresourcetypes.h"
-
 extern const char * SVR_DB_FILE_NAME;
 extern const char * SVR_DB_DAT_FILE_NAME;
 extern const char * OIC_MI_DEF;
index 6a7f165..618a36b 100644 (file)
@@ -345,13 +345,11 @@ exit:
 OCStackResult PMTimeout(unsigned short waittime, bool waitForStackResponse)
 {
     OCStackResult res = OC_STACK_OK;
-    uint64_t startTime;
-    uint64_t currTime;
 
-    startTime = OICGetCurrentTime(TIME_IN_MS);
+    uint64_t startTime = OICGetCurrentTime(TIME_IN_MS);
     while (OC_STACK_OK == res)
     {
-        currTime = OICGetCurrentTime(TIME_IN_MS);
+        uint64_t currTime = OICGetCurrentTime(TIME_IN_MS);
 
         long elapsed = (long)((currTime - startTime) / MS_PER_SEC);
         if (elapsed > waittime)
index daf1d65..9670e67 100644 (file)
@@ -982,7 +982,7 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime)
 \r
     int clock_res = -1;\r
 #if defined(_MSC_VER)\r
-    time_t startTime;\r
+    time_t startTime = NULL;\r
     clock_res = (time(&startTime) == -1);\r
 #else\r
     struct timespec startTime = {.tv_sec=0, .tv_nsec=0};\r
@@ -1003,7 +1003,7 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime)
     while (1)\r
     {\r
 #if defined(_MSC_VER)\r
-        time_t currTime;\r
+        time_t currTime = NULL;\r
         clock_res = (time(&currTime) == -1);\r
 #else\r
         struct timespec currTime  = {.tv_sec=0, .tv_nsec=0};\r
index e31f3e8..dc16f4b 100644 (file)
@@ -38,16 +38,6 @@ static const char UNTIL[] = "UNTIL";
 static const char BYDAY[] = "BYDAY";
 static const char DAILY[] = "DAILY";
 
-/**
- * Parses periodStr and populate struct IotvtICalPeriod_t
- *
- * @param periodStr string to be parsed.
- * @param period    IotvtICalPeriod_t struct to be populated.
- *
- * @return  IOTVTICAL_INVALID_PARAMETER -- if parameter are invalid
- *          IOTVTICAL_INVALID_PERIOD    -- if period string has invalid format
- *          IOTVTICAL_INVALID_SUCCESS   -- if no error while parsing
- */
 IotvtICalResult_t ParsePeriod(const char *periodStr, IotvtICalPeriod_t *period)
 {
     if ((NULL == periodStr) || (NULL == period))
index 5e2e7e2..fd1b9bb 100644 (file)
@@ -24,8 +24,14 @@ bool is_leap_year(int yy)
 
 char * strptime(const char *buf, const char *fmt, struct tm *tm)
 {
-    char c;
     int temp = 0;
+    char c = '\0';
+
+    //check params
+    if ((fmt == NULL) || (tm == NULL))
+    {
+        return NULL;
+    }
 
     //initialize the tm struct values
     memset(tm, 0, sizeof(struct tm));
index fa67c28..558f683 100755 (executable)
@@ -79,7 +79,7 @@
 
 #elif defined(HAVE_WINDOWS_H)
 
- #include <Windows.h>
+ #include <windows.h>
  CRITICAL_SECTION lock;
  #define MUTEX_LOCK(ARG_NAME)   { EnterCriticalSection(ARG_NAME); }
  #define MUTEX_UNLOCK(ARG_NAME) { LeaveCriticalSection(ARG_NAME); }
index 2fd5bb3..6368e93 100644 (file)
@@ -24,7 +24,9 @@
 /// (properties and methods) and host this resource on the server.
 ///
 
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <functional>
 
 #include <pthread.h>
index eaeb83c..5bb8b06 100644 (file)
@@ -34,7 +34,7 @@
 #include "OCApi.h"
 
 #ifdef HAVE_WINDOWS_H
-#include <Windows.h>
+#include <windows.h>
 #endif
 #include "platform_features.h"
 
index 17f04a1..bb6283d 100644 (file)
 #include "OCPlatform.h"
 #include "OCApi.h"
 
-#if defined(__msys_nt__)
-#include <Windows.h>
-#define sleep(x) Sleep(1000*x)
+#if defined(HAVE_WINDOWS_H)
+#include <windows.h>
 #endif
+#include "platform_features.h"
 
 using namespace OC;
 
index 752fc99..13981cb 100644 (file)
@@ -381,8 +381,8 @@ OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
             }
 
 #if defined(_WIN32)
-            DWORD threadId;
-            HANDLE threadHandle;
+            DWORD threadId = 0;
+            HANDLE threadHandle = INVALID_HANDLE_VALUE;
 #else
             pthread_t threadId;
 #endif
index a0ac6e7..607b45f 100644 (file)
@@ -33,7 +33,7 @@
 #include "OCApi.h"
 
 #ifdef HAVE_WINDOWS_H
-#include <Windows.h>
+#include <windows.h>
 #endif
 #include "platform_features.h"
 
index 320cb06..1eaaeba 100644 (file)
@@ -35,7 +35,7 @@
 #include "OCApi.h"
 
 #ifdef HAVE_WINDOWS_H
-#include <Windows.h>
+#include <windows.h>
 #endif
 #include "platform_features.h"
 
index 3a3c658..d2ac74a 100644 (file)
@@ -29,9 +29,6 @@
 #include <iterator>
 #if defined(_MSC_VER)
 #include <functional>
-//Squelch "decorated name length exceeded, name was truncated"
-// This compensates for templates full of templates
-#pragma warning(disable : 4503)
 #endif
 
 #include "octypes.h"
index 65760e7..c0b1c08 100644 (file)
 #ifndef OC_REPRESENTATION_H_
 #define OC_REPRESENTATION_H_
 
-#define GCC_VERSION (__GNUC__ * 10000 \
-                   + __GNUC_MINOR__ * 100 \
-                   + __GNUC_PATCHLEVEL__)
-
 #include <string>
 #include <sstream>
 #include <vector>
@@ -324,7 +320,7 @@ namespace OC
                     // Enable-if required to prevent conversions to alternate types.  This prevents
                     // ambigious conversions in the case where conversions can include a number of
                     // types, such as the string constructor.
-#if (defined(_MSC_VER) ) || (defined(__GNUC__) && (GCC_VERSION <= 50000))
+#if (defined(_MSC_VER) ) || (defined(__GNUC__) && (__GNUC__ <= 5))
                     template<typename T, typename std::enable_if<
                      std::is_same<T, int>::value ||
                      std::is_same<T, double>::value ||
index f2c4047..958d44d 100644 (file)
@@ -253,7 +253,7 @@ namespace OC
         ClientCallbackContext::ListenContext* context =
             new ClientCallbackContext::ListenContext(callback, shared_from_this());
         OCCallbackData cbdata;
-        cbdata.context = (void*)context;
+        cbdata.context = static_cast<void*>(context),
         cbdata.cb      = listenCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::ListenContext*)c;};
 
@@ -366,7 +366,7 @@ namespace OC
             new ClientCallbackContext::DeviceListenContext(callback, shared_from_this());
         OCCallbackData cbdata;
 
-        cbdata.context = (void*)context;
+        cbdata.context = static_cast<void*>(context),
         cbdata.cb      = listenDeviceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::DeviceListenContext*)c;};
 
@@ -457,7 +457,7 @@ namespace OC
         ClientCallbackContext::GetContext* ctx =
             new ClientCallbackContext::GetContext(callback);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = getResourceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::GetContext*)c;};
 
@@ -525,9 +525,9 @@ namespace OC
     {
         if (!uri.empty())
         {
-            if(uri.back() == '/')
+            if (uri.back() == '/')
             {
-                uri.resize(uri.size()-1);
+                uri.resize(uri.size() - 1);
             }
         }
 
@@ -537,14 +537,14 @@ namespace OC
             paramsList << '?';
         }
 
-        for(auto& param : queryParams)
+        for (auto& param : queryParams)
         {
             paramsList << param.first <<'='<<param.second<<';';
         }
 
         std::string queryString = paramsList.str();
 
-        if(queryString.empty())
+        if (queryString.empty())
         {
             return uri;
         }
@@ -584,7 +584,7 @@ namespace OC
         OCStackResult result;
         ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = setResourceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::SetContext*)c;};
 
@@ -630,7 +630,7 @@ namespace OC
         OCStackResult result;
         ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = setResourceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::SetContext*)c;};
 
@@ -695,7 +695,7 @@ namespace OC
         ClientCallbackContext::DeleteContext* ctx =
             new ClientCallbackContext::DeleteContext(callback);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = deleteResourceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::DeleteContext*)c;};
 
@@ -773,7 +773,7 @@ namespace OC
         ClientCallbackContext::ObserveContext* ctx =
             new ClientCallbackContext::ObserveContext(callback);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = observeResourceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::ObserveContext*)c;};
 
@@ -879,7 +879,7 @@ namespace OC
         ClientCallbackContext::SubscribePresenceContext* ctx =
             new ClientCallbackContext::SubscribePresenceContext(presenceHandler);
         OCCallbackData cbdata;
-        cbdata.context = (void*)ctx;
+        cbdata.context = static_cast<void*>(ctx),
         cbdata.cb      = subscribePresenceCallback;
         cbdata.cd      = [](void* c){delete (ClientCallbackContext::SubscribePresenceContext*)c;};
 
index 7cefa7c..8818821 100644 (file)
@@ -424,11 +424,11 @@ namespace OC
                     break;
                 case AttributeType::String:
                     OCRepPayloadSetPropString(root, val.attrname().c_str(),
-                            (static_cast<std::string>(val)).c_str());
+                            static_cast<std::string>(val).c_str());
                     break;
                 case AttributeType::OCRepresentation:
                     OCRepPayloadSetPropObjectAsOwner(root, val.attrname().c_str(),
-                            (static_cast<OCRepresentation>(val)).getPayload());
+                            static_cast<OCRepresentation>(val).getPayload());
                     break;
                 case AttributeType::Vector:
                     getPayloadArray(root, val);
index 3c4c922..11252d2 100644 (file)
@@ -122,13 +122,8 @@ static OCEntityHandlerResult handlePublishRequest(const OCEntityHandlerRequest *
  * This internal method is the entity handler for RD resources and
  * will handle REST request (GET/PUT/POST/DEL) for them.
  */
-#ifdef _MSC_VER
 static OCEntityHandlerResult rdEntityHandler(OCEntityHandlerFlag flag,
-        OCEntityHandlerRequest *ehRequest, void *callbackParameter)
-#else
-static OCEntityHandlerResult rdEntityHandler(OCEntityHandlerFlag flag,
-        OCEntityHandlerRequest *ehRequest, __attribute__((unused)) void *callbackParameter)
-#endif
+        OCEntityHandlerRequest *ehRequest, OC_ANNOTATE_UNUSED void *callbackParameter)
 {
     OCEntityHandlerResult ehRet = OC_EH_ERROR;