[Olsr-dev] [PATCH v1 2/2] all: fixes resulting from building with clang

Ferry Huberts (spam-protected)
Wed Dec 9 11:15:12 CET 2015


From: Ferry Huberts <(spam-protected)>

Used clang 3.7.0-1 on Fedora 23

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 gui/linux-gtk/src/ipc.c          | 2 +-
 lib/mdns/src/NetworkInterfaces.c | 2 +-
 lib/p2pd/src/NetworkInterfaces.c | 2 +-
 lib/pud/nmealib/src/random.h     | 3 ++-
 src/main.c                       | 2 ++
 src/mpr.c                        | 2 +-
 src/net_olsr.c                   | 2 +-
 7 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gui/linux-gtk/src/ipc.c b/gui/linux-gtk/src/ipc.c
index 85ec6e1..f8d0935 100644
--- a/gui/linux-gtk/src/ipc.c
+++ b/gui/linux-gtk/src/ipc.c
@@ -604,7 +604,7 @@ gui_itoa(int i, char *buf)
 {
   char tmp[10];
 
-  if (snprintf(buf, sizeof(tmp), "%hd", i)) {
+  if (snprintf(buf, sizeof(tmp), "%hd", (short)i)) {
     /* This shitty string needs to be converted to UTF-8 */
     snprintf(tmp, sizeof(tmp), "%s", g_locale_to_utf8(buf, -1, NULL, NULL, NULL));
     strcpy(buf, tmp);
diff --git a/lib/mdns/src/NetworkInterfaces.c b/lib/mdns/src/NetworkInterfaces.c
index 8874d59..c037003 100644
--- a/lib/mdns/src/NetworkInterfaces.c
+++ b/lib/mdns/src/NetworkInterfaces.c
@@ -467,7 +467,7 @@ CreateInterface(const char *ifName, struct interface_olsr *olsrIntf)
 
   /* Create socket for capturing and sending of multicast packets on
    * non-OLSR interfaces, and on OLSR-interfaces if configured. */
-  if ((olsrIntf == NULL)) {
+  if (!olsrIntf) {
     capturingSkfd = CreateCaptureSocket(ifName);
     electionSkfd = CreateRouterElectionSocket(ifName);
     helloSkfd = CreateHelloSocket(ifName);
diff --git a/lib/p2pd/src/NetworkInterfaces.c b/lib/p2pd/src/NetworkInterfaces.c
index e5af653..8a015d0 100644
--- a/lib/p2pd/src/NetworkInterfaces.c
+++ b/lib/p2pd/src/NetworkInterfaces.c
@@ -193,7 +193,7 @@ CreateInterface(const char *ifName, struct interface_olsr *olsrIntf)
 
   /* Create socket for capturing and sending of multicast packets on
    * non-OLSR interfaces, and on OLSR-interfaces if configured. */
-  if ((olsrIntf == NULL)) {
+  if (!olsrIntf) {
     capturingSkfd = CreateCaptureSocket(ifName);
     if (capturingSkfd < 0) {
       free(newIf);
diff --git a/lib/pud/nmealib/src/random.h b/lib/pud/nmealib/src/random.h
index f7e9759..769a1f0 100644
--- a/lib/pud/nmealib/src/random.h
+++ b/lib/pud/nmealib/src/random.h
@@ -6,13 +6,14 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <time.h>
+#include <math.h>
 
 #define NMEA_RANDOM_MAX INT32_MAX
 
 static inline long int nmea_random(const double min, const double max) {
   int32_t value;
   int randomFile;
-  double range = abs(max - min);
+  double range = fabs(max - min);
 
 #ifdef _WIN32
   value = random();
diff --git a/src/main.c b/src/main.c
index bd26b7d..3093b0e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,6 +96,7 @@ struct olsr_cookie_info *def_timer_ci = NULL;
  *
  *@param signo the signal that triggered this callback
  */
+__attribute__ ((noreturn))
 static void olsr_reconfigure(int signo __attribute__ ((unused))) {
 #ifndef _WIN32
   int errNr = errno;
@@ -157,6 +158,7 @@ static void olsr_shutdown_messages(void) {
  *
  * @param signo the signal that triggered this call
  */
+__attribute__ ((noreturn))
 #ifdef _WIN32
 int __stdcall
 SignalHandler(unsigned long signo)
diff --git a/src/mpr.c b/src/mpr.c
index a81cd45..018f9c2 100644
--- a/src/mpr.c
+++ b/src/mpr.c
@@ -177,7 +177,7 @@ olsr_chosen_mpr(struct neighbor_entry *one_hop_neighbor, uint16_t * two_hop_cove
 
     while (the_one_hop_list != &second_hop_entries->neighbor_2->neighbor_2_nblist) {
 
-      if ((the_one_hop_list->neighbor->status == SYM)) {
+      if (the_one_hop_list->neighbor->status == SYM) {
         if (second_hop_entries->neighbor_2->mpr_covered_count >= olsr_cnf->mpr_coverage) {
           the_one_hop_list->neighbor->neighbor_2_nocov--;
         }
diff --git a/src/net_olsr.c b/src/net_olsr.c
index 4db54b1..37cb970 100644
--- a/src/net_olsr.c
+++ b/src/net_olsr.c
@@ -442,7 +442,7 @@ olsr_validate_address(const union olsr_ip_addr *adr)
       OLSR_PRINTF(1, "Validation of address %s failed!\n", olsr_ip_to_string(&buf, adr));
       return false;
     }
-    if (deny_entry == (struct deny_address_entry *)&olsr_cnf->main_addr)
+    if (&deny_entry->addr == &olsr_cnf->main_addr)
       break;
   }
   return true;
-- 
2.5.0




More information about the Olsr-dev mailing list