diff --git a/CMakeLists.txt b/CMakeLists.txt index d40c6ae..6c619df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,15 @@ cmake_minimum_required(VERSION 3.3) project(can-utils LANGUAGES C) +include (CheckSymbolExists) include (GNUInstallDirs) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") +check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE) +if(_GNU_SOURCE) add_definitions(-D_GNU_SOURCE) endif() diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c index e3bee9f..9129844 100644 --- a/can-calc-bit-timing.c +++ b/can-calc-bit-timing.c @@ -444,7 +444,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, unsigned int spt_nominal; /* nominal sample point */ unsigned int best_tseg = 0; /* current best value for tseg */ unsigned int best_brp = 0; /* current best value for brp */ - unsigned int brp, tsegall, tseg, tseg1, tseg2; + unsigned int brp, tsegall, tseg, tseg1 = 0, tseg2 = 0; u64 v64; /* Use CiA recommended sample points */ diff --git a/j1939cat.c b/j1939cat.c index a37c5ba..5ae0c0b 100644 --- a/j1939cat.c +++ b/j1939cat.c @@ -645,7 +645,7 @@ static int j1939cat_parse_args(struct j1939cat_priv *priv, int argc, char *argv[ int main(int argc, char *argv[]) { struct j1939cat_priv *priv; - int ret; + int ret = 0; priv = malloc(sizeof(*priv)); if (!priv) @@ -679,6 +679,6 @@ int main(int argc, char *argv[]) close(priv->infile); close(priv->outfile); close(priv->sock); + return ret; } - diff --git a/slcanpty.c b/slcanpty.c index fc72dfe..d233c0d 100644 --- a/slcanpty.c +++ b/slcanpty.c @@ -24,17 +24,18 @@ * */ +#include +#include #include #include -#include #include -#include -#include #include +#include #include -#include #include +#include +#include #include #include