summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-03-17 17:50:57 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-03-17 17:50:57 +0100
commitdd87d59f475dae07e3acea8df3852dc9a6a12fce (patch)
tree96ec6cf9f7f28e13bcaf99e86c7e467152474b8b
parent56a8a7465ce8a02148a0e6b1bae4d3d7062c78fa (diff)
downloadgmrf-dd87d59f475dae07e3acea8df3852dc9a6a12fce.tar
gmrf-dd87d59f475dae07e3acea8df3852dc9a6a12fce.zip
Compiler option cleanup and -Wextra fixes
-rw-r--r--mmss-protocol/CMakeLists.txt2
-rw-r--r--mmss/CMakeLists.txt3
-rw-r--r--mmss/config.l4
-rw-r--r--mmss/context.cpp4
-rw-r--r--mmss/event.cpp4
-rw-r--r--mmss/gmrf.cpp20
-rw-r--r--mmss/types.hpp8
7 files changed, 24 insertions, 21 deletions
diff --git a/mmss-protocol/CMakeLists.txt b/mmss-protocol/CMakeLists.txt
index dd670f3..69caf64 100644
--- a/mmss-protocol/CMakeLists.txt
+++ b/mmss-protocol/CMakeLists.txt
@@ -3,4 +3,4 @@ include_directories(${GMRF_SOURCE_DIR}/include)
add_library(mmss_protocol STATIC
mmss_protocol.c
)
-set_target_properties(mmss_protocol PROPERTIES POSITION_INDEPENDENT_CODE 1)
+set_target_properties(mmss_protocol PROPERTIES COMPILE_FLAGS "-std=c99 -Wall" POSITION_INDEPENDENT_CODE 1)
diff --git a/mmss/CMakeLists.txt b/mmss/CMakeLists.txt
index 7e942f5..c71b9b1 100644
--- a/mmss/CMakeLists.txt
+++ b/mmss/CMakeLists.txt
@@ -1,4 +1,5 @@
include_directories(${GMRF_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+set_directory_properties(PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
FLEX_TARGET(mmss_config_lex config.l ${CMAKE_CURRENT_BINARY_DIR}/config.ll.cpp)
BISON_TARGET(mmss_config_parse config.y ${CMAKE_CURRENT_BINARY_DIR}/config.yy.cpp)
@@ -16,4 +17,4 @@ add_executable(mmss
${BISON_mmss_config_parse_OUTPUTS}
)
target_link_libraries(mmss dl)
-set_target_properties(mmss PROPERTIES COMPILE_FLAGS -std=c++11)
+set_target_properties(mmss PROPERTIES COMPILE_FLAGS "-std=c++11 -Wall")
diff --git a/mmss/config.l b/mmss/config.l
index 10c1a9d..d81ba20 100644
--- a/mmss/config.l
+++ b/mmss/config.l
@@ -44,6 +44,8 @@
%{
/* register is deprecated in C++11 */
#define register
+
+ #pragma GCC diagnostic ignored "-Wunused-parameter"
%}
%s NEEDSPACE
@@ -121,7 +123,7 @@ days { TOKEN(TOK_DAYS); }
<STRING>\\. { yylloc->last_column+=2; yymore(); }
<STRING>\\\n { yylloc->last_line++; yylloc->last_column = 0; yymore(); }
<STRING>\" {
- int i, esc = 0;
+ size_t i, esc = 0;
for (i = 0; i < yyleng; i++) {
if (yytext[i] == '\\') {
diff --git a/mmss/context.cpp b/mmss/context.cpp
index a6a24e7..b4d001d 100644
--- a/mmss/context.cpp
+++ b/mmss/context.cpp
@@ -42,7 +42,7 @@ static inline int snprintf_safe(char *buffer, size_t size, const char *format, .
int ret = std::vsnprintf(buffer, size, format, ap);
va_end(ap);
- return ret < 0 ? 0 : ret > size ? size : ret;
+ return ret < 0 ? 0 : (size_t)ret > size ? size : ret;
}
static inline const char* get_log_prefix(int log_level) {
@@ -99,7 +99,7 @@ void context_t::run(int argc, char *argv[]) {
std::exit(1);
while (true) {
- if (now() > 10000000)
+ if (now() > 5*3600*1000)
break;
int timeout = event_queue.timeout();
diff --git a/mmss/event.cpp b/mmss/event.cpp
index 3e32605..94aefac 100644
--- a/mmss/event.cpp
+++ b/mmss/event.cpp
@@ -31,7 +31,7 @@
namespace MMSS {
-void packet_t::handle(context_t *mmss) {
+void packet_t::handle(context_t *mmss UNUSED) {
auto iface = dest.lock();
if (!iface)
return;
@@ -39,7 +39,7 @@ void packet_t::handle(context_t *mmss) {
iface->get_node()->handle_packet(iface, &source_addr, data.get(), len);
}
-void scheduled_t::handle(context_t *mmss) {
+void scheduled_t::handle(context_t *mmss UNUSED) {
auto node_ptr = node.lock();
if (!node_ptr)
return;
diff --git a/mmss/gmrf.cpp b/mmss/gmrf.cpp
index 9db3c43..c7b2fbc 100644
--- a/mmss/gmrf.cpp
+++ b/mmss/gmrf.cpp
@@ -34,25 +34,25 @@ using namespace MMSS;
extern "C" {
-gmrf_addr_t gmrf_iface_get_addr(gmrf_t *gmrf, gmrf_iface_t *iface) {
+gmrf_addr_t gmrf_iface_get_addr(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface) {
return *(static_cast<iface_t*>(iface)->get_address());
}
-const char* gmrf_iface_get_name(gmrf_t *gmrf, gmrf_iface_t *iface) {
+const char* gmrf_iface_get_name(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface) {
return static_cast<iface_t*>(iface)->get_name().c_str();
}
-size_t gmrf_iface_get_mtu(gmrf_t *gmrf, gmrf_iface_t *iface) {
+size_t gmrf_iface_get_mtu(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface) {
return static_cast<iface_t*>(iface)->get_network()->get_mtu();
}
-bool gmrf_iface_send(gmrf_t *gmrf, gmrf_iface_t *iface, const void *data, size_t len, const gmrf_addr_t *dest) {
+bool gmrf_iface_send(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface, const void *data, size_t len, const gmrf_addr_t *dest) {
static_cast<iface_t*>(iface)->send(data, len, dest);
return true;
}
-bool gmrf_iface_send_bc(gmrf_t *gmrf, gmrf_iface_t *iface, const void *data, size_t len) {
+bool gmrf_iface_send_bc(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface, const void *data, size_t len) {
static_cast<iface_t*>(iface)->send_bc(data, len);
return true;
@@ -86,19 +86,19 @@ void gmrf_logf(gmrf_t *gmrf, int priority, const char *format, ...) {
va_end(ap);
}
-void gmrf_debug_init(gmrf_t *gmrf, const uint8_t *node_id, size_t len) {
+void gmrf_debug_init(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
}
-void gmrf_debug_neigh(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) {
+void gmrf_debug_neigh(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) {
}
-void gmrf_debug_neigh_lost(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr) {
+void gmrf_debug_neigh_lost(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED) {
}
-void gmrf_debug_route(gmrf_t *gmrf, const uint8_t *node_id, size_t len, gmrf_iface_t *iface, const gmrf_addr_t *addr, int metric) {
+void gmrf_debug_route(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, int metric UNUSED) {
}
-void gmrf_debug_route_lost(gmrf_t *gmrf, const uint8_t *node_id, size_t len) {
+void gmrf_debug_route_lost(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) {
}
}
diff --git a/mmss/types.hpp b/mmss/types.hpp
index 668e2c2..bf95437 100644
--- a/mmss/types.hpp
+++ b/mmss/types.hpp
@@ -26,16 +26,16 @@
#pragma once
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
extern "C" {
#include <gmrf/gmrf.h>
}
+
+#define UNUSED __attribute__((unused))
+
+
struct gmrf {};
struct gmrf_iface {};