Applied coding rule 99/100099/1
authorkmook <kmook.choi@samsung.com>
Fri, 25 Nov 2016 06:34:36 +0000 (15:34 +0900)
committerkmook <kmook.choi@samsung.com>
Fri, 25 Nov 2016 06:34:36 +0000 (15:34 +0900)
Change-Id: I5064e6589328b03fca1a546b49de42a6735ff647
Signed-off-by: kmook <kmook.choi@samsung.com>
12 files changed:
msf_tizen_client/include/Debug.h
msf_tizen_client/src/Application.cpp
msf_tizen_client/src/Channel.cpp
msf_tizen_client/src/Clients.cpp
msf_tizen_client/src/MSFDSearchProvider.cpp
msf_tizen_client/src/Result.cpp
msf_tizen_client/src/Search.cpp
msf_tizen_client/src/SearchProvider.cpp
msf_tizen_client/src/Service.cpp
msf_tizen_client/src/URIparser.cpp
msf_tizen_client/src/mDNSSearchProvider.cpp
msf_tizen_client/test/main.cpp

index caa70db..4496283 100755 (executable)
@@ -21,8 +21,8 @@
 #include <dlog.h>
 #undef LOG_TAG
 #define LOG_TAG "MSF_API"
-#define MSF_DBG(format, args...) SLOGD(format, ##args)
-#define MSF_ERR(format, args...) SLOGE(format, ##args)
+#define MSF_DBG(format, args...) (SLOGD(format, ##args))
+#define MSF_ERR(format, args...) (SLOGE(format, ##args))
 #endif
 
 #ifdef LINUX
@@ -31,4 +31,3 @@
 #endif
 
 #endif
-
index db3a545..e304ad4 100755 (executable)
@@ -171,8 +171,9 @@ void Application::getinfo(Result_Base *result1)
        result = result1;
        int ret = curl_application_calling(uri);
        if (ret == -1) {
-               if (result1 != NULL)
+               if (result1 != NULL) {
                        result1->onError(Error::create("Failed to get info"));
+               }
        }
 }
 
@@ -180,8 +181,9 @@ void Application::start()
 {
        Clients *clientstemp = Channel::getclients();
 
-       if (clientstemp->getHost() == NULL)
+       if (clientstemp->getHost() == NULL) {
                waitForOnReady = true;
+       }
 
        map<string, string> params = getparams();
 
@@ -330,8 +332,9 @@ size_t Application::createdata(char* buf, size_t size, size_t nmemb, void* up)
 
 size_t Application::read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
 {
-       if (ptr != NULL)
+       if (ptr != NULL) {
                static_cast<Application*>(stream)->curl_install_data.append(static_cast<const char*>(ptr), size*nmemb);
+       }
 
        return size*nmemb;
 }
@@ -365,10 +368,11 @@ int Application::curl_application_calling(string uri)
                curl_install_data.clear();
                curl_easy_cleanup(curl);
 
-               if (res != CURLE_OK)
+               if (res != CURLE_OK) {
                        return -1;
-               else
+               } else {
                        return 0;
+               }
        }
 
        return -1;
@@ -447,10 +451,11 @@ int Application::curl_install(string uri)
                curl_global_cleanup();
        }
 
-       if (res != CURLE_OK)
+       if (res != CURLE_OK) {
                return -1;
-       else
+       } else {
                return 0;
+       }
 }
 
 void Application::setonInstallListener(OnInstallListener * listener)
index 5c54858..eb02d2c 100755 (executable)
@@ -116,8 +116,9 @@ Channel::Channel(Service *service1, string uri1) {
 
 Channel *Channel::create(Service *service, string uri) {
        MSF_DBG("Channel::create()");
-       if ((service == NULL) || uri.length() <= 0)
+       if ((service == NULL) || uri.length() <= 0) {
                return NULL;
+       }
        Channel *channel = new Channel(service, uri);
        return channel;
 }
@@ -230,10 +231,12 @@ void Channel::foreach_json_object(JsonObject *object, const gchar *name,
                                        err.append(p->errMsg);
                                        err.append(" code:");
                                        err.append(to_string(p->errcode));
-                                       if (temp1)
+                                       if (temp1) {
                                                temp1->onError(Error::create(err));
-                                       if (p->onErrorListener)
+                                       }
+                                       if (p->onErrorListener) {
                                                p->onErrorListener->onError();
+                                       }
                                }
                        }
                }
@@ -380,22 +383,23 @@ void Channel::json_parse(const char *in) {
 }
 
 Clients *Channel::getclients() {
-       if (clients->size())
+       if (clients->size()) {
                return clients;
-       else
+       } else {
                return NULL;
+       }
 }
 
 void Channel::setConnectionTimeout(long timeout) {
-       if (timeout < 0)
+       if (timeout < 0) {
                return;
-       else if (timeout == 0)
+       } else if (timeout == 0) {
                connectionHandler->stopPing();
-       else
-       {
+       } else {
                connectionHandler->setPingTimeout(timeout);
-               if (isWebSocketOpen())
+               if (isWebSocketOpen()) {
                        connectionHandler->startPing(this);
+               }
        }
 }
 
@@ -466,8 +470,9 @@ void Channel::doApplicationCallback(Result_Base *result1) {
                stringstream ss;
                ss << code;
                string str = ss.str();
-               if (result1 != NULL)
+               if (result1 != NULL) {
                        result1->onError(Error::create(str));
+               }
        } else {
                if (resultobj != NULL) {
                        //      string json=json_object_to_json_string(resultobj);
@@ -496,16 +501,19 @@ void Channel::handleError(string UID, Error err) {
                if (temp.first != NULL) {
                        if (temp.second == Result_Client) {
                                Result_Base *temp1 = (Result_Base *)(temp.first);
-                               if (temp1)
+                               if (temp1) {
                                        temp1->onError(err);
+                               }
                        } else if (temp.second == Result_bool) {
                                Result_Base *temp1 = (Result_Base *)(temp.first);
-                               if (temp1)
+                               if (temp1) {
                                        temp1->onError(err);
+                               }
                        }
 
-                       if (onErrorListener)
+                       if (onErrorListener) {
                                onErrorListener->onError();
+                       }
                }
        }
 }
@@ -594,10 +602,11 @@ bool Channel::connect(map<string, string> attributes, Result_Base *result1) {
        int status = pthread_create(&connect_thread, NULL, pt_startConnect,
                                                                (void *)pt_user_data);
 
-       if (status)
+       if (status) {
                return true;
-       else
+       } else {
                return false;
+       }
 }
 
 void Channel::disconnect() {
@@ -611,11 +620,13 @@ void Channel::disconnect(Result_Base *result1) {
        registerCallback(randID, (void *)result1, Result_Client);
        string message = "";
 
-       if (!isWebSocketOpen())
+       if (!isWebSocketOpen()) {
                message = "Already Disconnected";
+       }
 
-       if (disconnecting)
+       if (disconnecting) {
                message = "Already Disconnecting";
+       }
 
        if (message != "") {
                handleError(UID, Error::create(message));
@@ -625,8 +636,9 @@ void Channel::disconnect(Result_Base *result1) {
                getcallback(randID);
 
                while (1) {
-                       if (mirror_lifetime > 0)
+                       if (mirror_lifetime > 0) {
                                mirror_lifetime--;
+                       }
 
                        if (!mirror_lifetime) {
                                break;
@@ -651,23 +663,27 @@ void Channel::handleReadyMessage() {
                onReadyCallbacks.erase(res);
                doApplicationCallback(res);
        }
-       if (onConnectListener)
+       if (onConnectListener) {
                onConnectListener->onConnect(clients->me());
+       }
 
-       if (onReadyListener != NULL)
+       if (onReadyListener != NULL) {
                onReadyListener->onReady();
+       }
 }
 
 void Channel::handleClientConnectMessage() {
        MSF_DBG("handleClientConnectMessage");
 
-       if (client.isHost())
+       if (client.isHost()) {
                connected = true;
+       }
 
        clients->add(client);
 
-       if (onClientConnectListener != NULL)
+       if (onClientConnectListener != NULL) {
                onClientConnectListener->onClientConnect(client);
+       }
 }
 
 void Channel::handleClientDisconnectMessage() {
@@ -697,18 +713,21 @@ void Channel::handleConnect(string UID) {
        temp = Channel::getcallback(UID);
        if (temp.second == Result_Client) {
                Result_Base *temp1 = (Result_Base *)(temp.first);
-               if (temp1)
+               if (temp1) {
                        temp1->onSuccess(clienttemp);
+               }
        } else if (temp.second == Result_bool) {
                Result_Base *temp1 = (Result_Base *)(temp.first);
-               if (temp1)
+               if (temp1) {
                        temp1->onSuccess(true);
+               }
        }
 
        me = clients->me();
 
-       if (onConnectListener)
+       if (onConnectListener) {
                onConnectListener->onConnect(clienttemp);
+       }
        // To start channnel heath check
        if (isWebSocketOpen()) {
                // connectionHandler->startPing(this);
@@ -731,11 +750,13 @@ void Channel::handleSocketClosed() {
        wsi_mirror = NULL;
        connected = false;
        was_closed = true;
-       if ( Context )
+       if (Context) {
                lws_cancel_service(Context);
+       }
 
-       if (disconnecting)
+       if (disconnecting) {
                disconnecting = false;
+       }
        callbacks.clear();
        clients->reset();
 }
@@ -1299,8 +1320,9 @@ void Channel::create_websocket(void *att) {
 
        // loop until socket closed
        while (n >= 0 && !was_closed) {
-               if (was_closed)
+               if (was_closed) {
                        break;
+               }
 
                if (wsi_mirror == NULL) {
                        wsi_mirror = lws_client_connect_via_info(&connect_info);
@@ -1313,8 +1335,9 @@ void Channel::create_websocket(void *att) {
 
                n = lws_service(Context, 0x0FFFFFFF);
 
-               if (n < 0)
+               if (n < 0) {
                        break;
+               }
        }
 
        MSF_DBG("create_websocket destroy context");
@@ -1412,8 +1435,9 @@ void Channel::unsetonClientConnectListener() { onClientConnectListener = NULL; }
 
 void Channel::addOnMessageListener(string event,
                                                                        OnMessageListener *onMessageListener) {
-       if (event.length() == 0 || onMessageListener == NULL)
+       if (event.length() == 0 || onMessageListener == NULL) {
                return;
+       }
 
        if (messageListeners.find(event) == messageListeners.end()) {
                messageListeners.insert({event, list<OnMessageListener *>()});
@@ -1432,8 +1456,9 @@ void Channel::addOnAllMessageListener(OnMessageListener *onMessageListener) {
 void Channel::removeAllMessageListener() { everyMessageListener = NULL; }
 
 void Channel::removeOnMessageListeners(string event) {
-       if (event.length() == 0)
+       if (event.length() == 0) {
                return;
+       }
 
        if (messageListeners.find(event) == messageListeners.end()) {
                return;
@@ -1446,8 +1471,9 @@ void Channel::removeOnMessageListeners(string event) {
 
 void Channel::removeOnMessageListener(string event,
                                                                        OnMessageListener *onMessageListener) {
-       if ((event.length() == 0) || (onMessageListener != NULL))
+       if ((event.length() == 0) || (onMessageListener != NULL)) {
                return;
+       }
 
        if (messageListeners.find(event) == messageListeners.end()) {
                return;
@@ -1598,8 +1624,9 @@ void Channel::handleWsiDestroy()
 {
        if (!isCommunicated) {
                was_closed = true;
-               if ( Context )
+               if (Context) {
                        lws_cancel_service(Context);
+               }
 
                MSF_ERR("wsi destroyed with no communication");
                if (onErrorListener) {
index 10bb482..2c9d077 100755 (executable)
@@ -86,8 +86,9 @@ void Clients::setMyClientId(string clientId)
 void Clients::reset()
 {
        clients.clear();
-       if (host != NULL)
+       if (host != NULL) {
                delete host;
+       }
        host = NULL;
        myClientId = "";
 }
index 1217621..3c75495 100755 (executable)
@@ -238,8 +238,9 @@ void MSFDSearchProvider::sendDiscovery(void* data)
 
 void MSFDSearchProvider::processReceivedMsg(char *buf, int buflen)
 {
-       if (buf == NULL)
+       if (buf == NULL) {
                return;
+       }
 
        if (buflen < 10) {
                return;
index 5a57cc2..30a8436 100644 (file)
@@ -65,36 +65,42 @@ Result_Base::~Result_Base()
 
 void Result_Base::onSuccess(ApplicationInfo arg)
 {
-       if (appinfo_result_cb)
+       if (appinfo_result_cb) {
                appinfo_result_cb(arg, user_data);
+       }
 }
 
 void Result_Base::onSuccess(Client arg)
 {
-       if (client_result_cb)
-       client_result_cb(arg, user_data);
+       if (client_result_cb) {
+               client_result_cb(arg, user_data);
+       }
 }
 
 void Result_Base::onSuccess(Device arg)
 {
-       if (device_result_cb)
-       device_result_cb(arg, user_data);
+       if (device_result_cb) {
+               device_result_cb(arg, user_data);
+       }
 }
 
 void Result_Base::onSuccess(bool arg)
 {
-       if (bool_result_cb)
-       bool_result_cb(arg, user_data);
+       if (bool_result_cb) {
+               bool_result_cb(arg, user_data);
+       }
 }
 
 void Result_Base::onSuccess(Service arg)
 {
-       if (service_result_cb)
-       service_result_cb(arg, user_data);
+       if (service_result_cb) {
+               service_result_cb(arg, user_data);
+       }
 }
 
 void Result_Base::onError(Error er)
 {
-       if (error_result_cb)
+       if (error_result_cb) {
                error_result_cb(er, user_data);
+       }
 }
index b700d3c..ad830ec 100755 (executable)
@@ -181,8 +181,9 @@ bool Search::stop()
                if (search_ref_count == 0) {
                        stopDiscovery();
                } else {
-                       if (searchListener != NULL)
+                       if (searchListener != NULL) {
                                searchListener->onStop();
+                       }
                }
        }
 
@@ -236,12 +237,14 @@ void Search::startDiscovery()
        provider_mdns.start();
 
        ret = pthread_create(&threads[MSFD_THREAD_NUMBER], NULL, pt_startMSFD, NULL);
-       if (ret == -1)
+       if (ret == -1) {
                MSF_DBG("MSFD thread create failed");
+       }
 
        ret = pthread_create(&threads[UPDATE_THREAD_NUMBER], NULL, pt_update_alivemap, NULL);
-       if (ret == -1)
+       if (ret == -1) {
                MSF_DBG("update thread create failed");
+       }
 
        onStart();
 }
@@ -255,8 +258,9 @@ void Search::stopDiscovery()
        stop = provider_msfd.stop();
        pt_update_start = false;
 
-       if (stop)
+       if (stop) {
                onStop();
+       }
 
        pthread_join(threads[MSFD_THREAD_NUMBER], NULL);
 
index 2c4bab5..544814f 100755 (executable)
@@ -24,10 +24,11 @@ map<string, ttl_info> SearchProvider::aliveMap;
 
 ttl_info::ttl_info(long ttl, int service_type):msfd_ttl(0), mdns_ttl(0)
 {
-       if (service_type == MSFD)
+       if (service_type == MSFD) {
                msfd_ttl = ttl;
-       else if (service_type == MDNS)
+       } else if (service_type == MDNS) {
                mdns_ttl = ttl;
+       }
 }
 
 ttl_info::ttl_info():msfd_ttl(0), mdns_ttl(0)
@@ -36,12 +37,13 @@ ttl_info::ttl_info():msfd_ttl(0), mdns_ttl(0)
 
 long ttl_info:: get_ttl(int service_type)
 {
-       if (service_type == MSFD)
+       if (service_type == MSFD) {
                return msfd_ttl;
-       else if (service_type == MDNS)
+       } else if (service_type == MDNS) {
                return mdns_ttl;
-       else
+       } else {
                return -1;
+       }
 }
 
 void ttl_info::update_ttl(long ttl, int service_type)
@@ -59,10 +61,11 @@ bool ttl_info::is_expired()
 
        MSF_DBG("msfd_remain_ttl = %d mdns_remain_ttl = %d", msfd_ttl - now, mdns_ttl - now);
 
-       if (msfd_ttl < now && mdns_ttl < now)
+       if (msfd_ttl < now && mdns_ttl < now) {
                return true;
-       else
+       } else {
                return false;
+       }
 }
 
 SearchProvider::SearchProvider()
@@ -125,10 +128,11 @@ Service SearchProvider::getServiceByIp(string ip)
 
 bool SearchProvider::isSearching()
 {
-       if (this->searching)
+       if (this->searching) {
                return true;
-       else
+       } else {
                return false;
+       }
 }
 
 void SearchProvider::push_in_alivemap(long ttl, string id, int service_type)
@@ -189,8 +193,9 @@ void SearchProvider::reapServices()
 
 std::string SearchProvider::getIP(std::string url)
 {
-       if (url.empty())
+       if (url.empty()) {
                return "";
+       }
 
        std::string::size_type pos1  = 7;
        std::string::size_type pos2  = url.find(":", 6);
index f2a6405..176e767 100755 (executable)
@@ -69,11 +69,13 @@ void Service:: getById(string id, Result_Base *result)
        }
 
        if (service.getId().length() == 0) {
-               if (result != NULL)
+               if (result != NULL) {
                        result->onError(Error::create("Service Not Found"));
+               }
        } else {
-               if (result != NULL)
+               if (result != NULL) {
                        result->onSuccess(service);
+               }
        }
 }
 
@@ -269,8 +271,9 @@ int Service::curl_service_calling(string uri, long timeout, void *dev_result_ptr
         if ((res != CURLE_OK) || (read_data == NULL)) {
             MSF_DBG("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
             createdata_process("", dev_result_ptr);
-            if (read_data)
+            if (read_data) {
                 free(read_data);
+            }
         } else {
             createdata_process(string(read_data), dev_result_ptr);
             free(read_data);
index 3c13e1c..f0db508 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "URIparser.h"
+#include "Debug.h"
 #include <stdio.h>
 #include <cstdlib>
 #include <cstring>
@@ -83,16 +84,18 @@ void URIParse::decodeURI(const std::string& str, std::string& decodedStr, long _
                char c = *it++;
                if (c == '%') {
                        if (it == end) {
-                               if (_flags2 & 0x1)
-                                       printf("ERROR: URI encoding: no hex digit following percent sign.\n");
+                               if (_flags2 & 0x1) {
+                                       MSF_ERR("ERROR: URI encoding: no hex digit following percent sign.\n");
+                               }
                                return;
                        }
 
                        char hi = *it++;
 
                        if (it == end) {
-                               if (_flags2 & 0x1)
-                                       printf("ERROR: URI encoding: two hex digits must follow percent sign.\n");
+                               if (_flags2 & 0x1) {
+                                       MSF_ERR("ERROR: URI encoding: two hex digits must follow percent sign.\n");
+                               }
                                return;
                        }
 
@@ -105,8 +108,9 @@ void URIParse::decodeURI(const std::string& str, std::string& decodedStr, long _
                        } else if (hi >= 'a' && hi <= 'f') {
                                c = hi - 'a' + 10;
                        } else {
-                               if (_flags2 & 0x1)
-                                       printf("ERROR: URI encoding: not a hex digit.\n");
+                               if (_flags2 & 0x1) {
+                                       MSF_ERR("ERROR: URI encoding: not a hex digit.\n");
+                               }
                                return;
                        }
                        c *= 16;
@@ -117,8 +121,9 @@ void URIParse::decodeURI(const std::string& str, std::string& decodedStr, long _
                        } else if (lo >= 'a' && lo <= 'f') {
                                c += lo - 'a' + 10;
                        } else {
-                               if (_flags2 & 0x1)
-                                       printf("ERROR: URI encoding: not a hex digit.\n");
+                               if (_flags2 & 0x1) {
+                                       MSF_ERR("ERROR: URI encoding: not a hex digit.\n");
+                               }
                                return;
                        }
                }
@@ -128,46 +133,52 @@ void URIParse::decodeURI(const std::string& str, std::string& decodedStr, long _
 
 unsigned short URIParse::getWellKnownPortforURI() const
 {
-       if (_URIscheme == "ftp")
+       if (_URIscheme == "ftp") {
                return 21;
-       else if (_URIscheme == "ssh")
+       } else if (_URIscheme == "ssh") {
                return 22;
-       else if (_URIscheme == "telnet")
+       } else if (_URIscheme == "telnet") {
                return 23;
-       else if (_URIscheme == "http")
+       } else if (_URIscheme == "http") {
                return 80;
-       else if (_URIscheme == "nntp")
+       } else if (_URIscheme == "nntp") {
                return 119;
-       else if (_URIscheme == "ldap")
+       } else if (_URIscheme == "ldap") {
                return 389;
-       else if (_URIscheme == "https")
+       } else if (_URIscheme == "https") {
                return 443;
-       else if (_URIscheme == "rtsp")
+       } else if (_URIscheme == "rtsp") {
                return 554;
-       else if (_URIscheme == "sip")
+       } else if (_URIscheme == "sip") {
                return 5060;
-       else if (_URIscheme == "sips")
+       } else if (_URIscheme == "sips") {
                return 5061;
-       else if (_URIscheme == "xmpp")
+       } else if (_URIscheme == "xmpp") {
                return 5222;
-       else
+       } else {
                return 0;
+       }
 }
 
 void URIParse::parseURI(const std::string& uri)
 {
        std::string::const_iterator it  = uri.begin();
        std::string::const_iterator end = uri.end();
-       if (it == end) return;
+       if (it == end) {
+               return;
+       }
        if (*it != '/' && *it != '.' && *it != '?' && *it != '#') {
                std::string scheme;
-               while (it != end && *it != ':' && *it != '?' && *it != '#' && *it != '/') scheme += *it++;
+               while (it != end && *it != ':' && *it != '?' && *it != '#' && *it != '/') {
+                       scheme += *it++;
+               }
                if (it != end && *it == ':') {
                        ++it;
 
                        if (it == end) {
-                               if (_URIflags & 0x1)
-                                       printf("ERROR: URI scheme must be followed by authority or path.\n");
+                               if (_URIflags & 0x1) {
+                                       MSF_ERR("ERROR: URI scheme must be followed by authority or path.\n");
+                               }
                                return;
                        }
                        setURIScheme(scheme);
@@ -211,27 +222,36 @@ void URIParse::URIparseAuthority(std::string::const_iterator& it, const std::str
 
 void URIParse::URIparseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end)
 {
-       if (it == end) return;
+       if (it == end) {
+               return;
+       }
 
        std::string host;
        if (*it == '[') {
                ++it;
-               while (it != end && *it != ']') host += *it++;
+               while (it != end && *it != ']') {
+                       host += *it++;
+               }
 
                if (it == end) {
-                       if (_URIflags & 0x1)
-                               printf("ERROR: unterminated IPv6 address.\n");
+                       if (_URIflags & 0x1) {
+                               MSF_ERR("ERROR: unterminated IPv6 address.\n");
+                       }
                        return;
                }
                ++it;
        } else {
-               while (it != end && *it != ':') host += *it++;
+               while (it != end && *it != ':') {
+                       host += *it++;
+               }
        }
 
        if (it != end && *it == ':') {
                ++it;
                std::string port;
-               while (it != end) port += *it++;
+               while (it != end) {
+                       port += *it++;
+               }
                if (!port.empty()) {
                        int nport = 0;
 
@@ -257,16 +277,21 @@ void URIParse::URIparseHostAndPort(std::string::const_iterator& it, const std::s
 void URIParse::URIparsePath(std::string::const_iterator& it, const std::string::const_iterator& end)
 {
        std::string path;
-       while (it != end && *it != '?' && *it != '#') path += *it++;
+       while (it != end && *it != '?' && *it != '#') {
+               path += *it++;
+       }
        decodeURI(path, _URIpath, _URIflags);
 }
 
 void URIParse::URIparsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end)
 {
-       if (it == end) return;
+       if (it == end) {
+               return;
+       }
 
-       if (*it != '?' && *it != '#')
+       if (*it != '?' && *it != '#') {
                URIparsePath(it, end);
+       }
 
        if (it != end && *it == '?') {
                ++it;
@@ -282,13 +307,17 @@ void URIParse::URIparsePathEtc(std::string::const_iterator& it, const std::strin
 void URIParse::URIparseQuery(std::string::const_iterator& it, const std::string::const_iterator& end)
 {
        _URIquery.clear();
-       while (it != end && *it != '#') _URIquery += *it++;
+       while (it != end && *it != '#') {
+               _URIquery += *it++;
+       }
 }
 
 void URIParse::URIparseFragment(std::string::const_iterator& it, const std::string::const_iterator& end)
 {
        std::string fragment;
-       while (it != end) fragment += *it++;
+       while (it != end) {
+               fragment += *it++;
+       }
        decodeURI(fragment, _URIfragment, _URIflags);
 }
 
@@ -298,8 +327,9 @@ bool URIParse::isIPAddressinURI(const std::string& str)
        const char *ptr = strrchr(str2, (int)'.');
        if (ptr && *ptr == '.') {
                ++ptr;
-               if (strchr("0123456789", *ptr))
+               if (strchr("0123456789", *ptr)) {
                        return 1;
+               }
        }
        return 0;
 }
index ad304b7..7384522 100755 (executable)
@@ -144,48 +144,50 @@ static void dnssd_browse_reply(dnssd_service_state_e service_state, dnssd_servic
        char *type = NULL;
 
        rv = dnssd_service_get_name(remote_service, &name);
-       if (rv == DNSSD_ERROR_NONE && name != NULL)
+       if (rv == DNSSD_ERROR_NONE && name != NULL) {
                MSF_DBG("Service Name  : %s", name);
+       }
 
        MSF_DBG("State         : ");
        switch (service_state) {
-               case DNSSD_SERVICE_STATE_AVAILABLE:
-                       MSF_DBG("Available");
-                       break;
-               case DNSSD_SERVICE_STATE_UNAVAILABLE:
-               {
-                       char *ip_v4_address = NULL;
-                       char *ip_v6_address = NULL;
-
-                       MSF_DBG("Un-Available");
-                       dnssd_service_get_ip(remote_service, &ip_v4_address, &ip_v6_address);
-                       if (ip_v4_address) {
-                               MSF_DBG("-> [%s]", ip_v4_address);
-                               provider->updateAlive(0, ip_v4_address, MDNS);
-                               provider->reapServices();
+       case DNSSD_SERVICE_STATE_AVAILABLE:
+               MSF_DBG("Available");
+               break;
+       case DNSSD_SERVICE_STATE_UNAVAILABLE:
+       {
+               char *ip_v4_address = NULL;
+               char *ip_v6_address = NULL;
 
-                               free(ip_v4_address);
-                               free(ip_v6_address);
-                       }
-                       return;
+               MSF_DBG("Un-Available");
+               dnssd_service_get_ip(remote_service, &ip_v4_address, &ip_v6_address);
+               if (ip_v4_address) {
+                       MSF_DBG("-> [%s]", ip_v4_address);
+                       provider->updateAlive(0, ip_v4_address, MDNS);
+                       provider->reapServices();
+
+                       free(ip_v4_address);
+                       free(ip_v6_address);
                }
-               case DNSSD_SERVICE_STATE_NAME_LOOKUP_FAILED:
-                       MSF_DBG("Lookup failure for service name");
-                       break;
-               case DNSSD_SERVICE_STATE_HOST_NAME_LOOKUP_FAILED:
-                       MSF_DBG("Lookup failure for host name and port number");
-                       break;
-               case DNSSD_SERVICE_STATE_ADDRESS_LOOKUP_FAILED:
-                       MSF_DBG("Lookup failure for IP address");
-                       break;
-               default:
-                       MSF_DBG("Unknown Browse State");
-                       break;
+               return;
+       }
+       case DNSSD_SERVICE_STATE_NAME_LOOKUP_FAILED:
+               MSF_DBG("Lookup failure for service name");
+               break;
+       case DNSSD_SERVICE_STATE_HOST_NAME_LOOKUP_FAILED:
+               MSF_DBG("Lookup failure for host name and port number");
+               break;
+       case DNSSD_SERVICE_STATE_ADDRESS_LOOKUP_FAILED:
+               MSF_DBG("Lookup failure for IP address");
+               break;
+       default:
+               MSF_DBG("Unknown Browse State");
+               break;
        }
 
        rv = dnssd_service_get_type(remote_service, &type);
-       if (rv == DNSSD_ERROR_NONE && type != NULL)
+       if (rv == DNSSD_ERROR_NONE && type != NULL) {
                MSF_DBG("Service Type  : %s", type);
+       }
 
        if (service_state == DNSSD_SERVICE_STATE_AVAILABLE) {
                char *ip_v4_address = NULL;
@@ -196,10 +198,12 @@ static void dnssd_browse_reply(dnssd_service_state_e service_state, dnssd_servic
 
                rv = dnssd_service_get_ip(remote_service, &ip_v4_address, &ip_v6_address);
                if (rv  == DNSSD_ERROR_NONE) {
-                       if (ip_v4_address)
+                       if (ip_v4_address) {
                                MSF_DBG("IPv4 Address  : %s", ip_v4_address);
-                       if (ip_v6_address)
+                       }
+                       if (ip_v6_address) {
                                MSF_DBG("IPv6 Address  : %s", ip_v6_address);
+                       }
                }
 
                rv = dnssd_service_get_port(remote_service, &port);
@@ -228,8 +232,9 @@ static void dnssd_browse_reply(dnssd_service_state_e service_state, dnssd_servic
 
 void mDNSSearchProvider::start()
 {
-       if (!service_cb)
+       if (!service_cb) {
                service_cb = new MDNSServiceCallback(this);
+       }
 
        if (g_service != 0) {
                dnssd_stop_browsing_service(g_service);
index 636d08a..20adc8f 100755 (executable)
@@ -692,8 +692,9 @@ int test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                return true;
        }
 
-       if (rv >= 1)
+       if (rv >= 1) {
                printf("\nOperation Succeeded!\n");
+       }
 
        return TRUE;
 }