Compiler option cleanup and -Wextra fixes

This commit is contained in:
Matthias Schiffer 2014-03-17 17:50:57 +01:00
parent 56a8a7465c
commit dd87d59f47
7 changed files with 24 additions and 21 deletions

View file

@ -3,4 +3,4 @@ include_directories(${GMRF_SOURCE_DIR}/include)
add_library(mmss_protocol STATIC add_library(mmss_protocol STATIC
mmss_protocol.c 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)

View file

@ -1,4 +1,5 @@
include_directories(${GMRF_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 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) 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) 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} ${BISON_mmss_config_parse_OUTPUTS}
) )
target_link_libraries(mmss dl) 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")

View file

@ -44,6 +44,8 @@
%{ %{
/* register is deprecated in C++11 */ /* register is deprecated in C++11 */
#define register #define register
#pragma GCC diagnostic ignored "-Wunused-parameter"
%} %}
%s NEEDSPACE %s NEEDSPACE
@ -121,7 +123,7 @@ days { TOKEN(TOK_DAYS); }
<STRING>\\. { yylloc->last_column+=2; yymore(); } <STRING>\\. { yylloc->last_column+=2; yymore(); }
<STRING>\\\n { yylloc->last_line++; yylloc->last_column = 0; yymore(); } <STRING>\\\n { yylloc->last_line++; yylloc->last_column = 0; yymore(); }
<STRING>\" { <STRING>\" {
int i, esc = 0; size_t i, esc = 0;
for (i = 0; i < yyleng; i++) { for (i = 0; i < yyleng; i++) {
if (yytext[i] == '\\') { if (yytext[i] == '\\') {

View file

@ -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); int ret = std::vsnprintf(buffer, size, format, ap);
va_end(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) { 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); std::exit(1);
while (true) { while (true) {
if (now() > 10000000) if (now() > 5*3600*1000)
break; break;
int timeout = event_queue.timeout(); int timeout = event_queue.timeout();

View file

@ -31,7 +31,7 @@
namespace MMSS { namespace MMSS {
void packet_t::handle(context_t *mmss) { void packet_t::handle(context_t *mmss UNUSED) {
auto iface = dest.lock(); auto iface = dest.lock();
if (!iface) if (!iface)
return; return;
@ -39,7 +39,7 @@ void packet_t::handle(context_t *mmss) {
iface->get_node()->handle_packet(iface, &source_addr, data.get(), len); 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(); auto node_ptr = node.lock();
if (!node_ptr) if (!node_ptr)
return; return;

View file

@ -34,25 +34,25 @@ using namespace MMSS;
extern "C" { 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()); 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(); 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(); 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); static_cast<iface_t*>(iface)->send(data, len, dest);
return true; 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); static_cast<iface_t*>(iface)->send_bc(data, len);
return true; return true;
@ -86,19 +86,19 @@ void gmrf_logf(gmrf_t *gmrf, int priority, const char *format, ...) {
va_end(ap); 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) {
} }
} }

View file

@ -26,16 +26,16 @@
#pragma once #pragma once
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
extern "C" { extern "C" {
#include <gmrf/gmrf.h> #include <gmrf/gmrf.h>
} }
#define UNUSED __attribute__((unused))
struct gmrf {}; struct gmrf {};
struct gmrf_iface {}; struct gmrf_iface {};