rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit ac1e83faf1e5bf266988b4417f80c5836c415325
parent 108d9664ded8fa42df1110484ba50e33936dd797
Author: vaplv <vaplv@free.fr>
Date:   Tue, 18 Dec 2018 14:31:32 +0100

Merge branch 'release_0.7.1'

Diffstat:
MREADME.md | 6++++++
Mcmake/CMakeLists.txt | 9+++++++--
Msrc/hash_table.h | 2+-
Msrc/rsys.h | 10++++++++++
Asrc/test_misc.c | 37+++++++++++++++++++++++++++++++++++++
5 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -17,6 +17,12 @@ project can be now edited, built, tested and installed as any CMake project. ## Release notes +### Version 0.7.1 + +- Add the FALLTHROUGH macro that disables compilation warning on switch + statement fallthrough. +- Fix a possible wrong return code in the set routine of the hash tables. + ### Version 0.7 - Add the `res_to_cstr` function that returns a string describing the submitted diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -17,6 +17,10 @@ cmake_minimum_required(VERSION 3.0) project(rsys C) enable_testing() +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + set(RSYS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) option(NO_TEST "Disable the test" OFF) @@ -35,7 +39,7 @@ include(rcmake) ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 7) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(RSYS_FILES_SRC @@ -217,8 +221,9 @@ if(NOT NO_TEST) new_test(test_library rsys) new_test(test_list rsys) new_test(test_logger rsys) - new_test(test_mem_allocator rsys) new_test(test_math ${MATH_LIB}) + new_test(test_mem_allocator rsys) + new_test(test_misc) new_test(test_quaternion rsys) new_test(test_ref) new_test(test_signal rsys) diff --git a/src/hash_table.h b/src/hash_table.h @@ -446,7 +446,7 @@ HTABLE_FUNC__(set) } } } - return RES_OK; + return res; } /* Return the number of erased elements, i.e. 0 or 1 */ diff --git a/src/rsys.h b/src/rsys.h @@ -402,5 +402,15 @@ typedef int res_T; #define END_DECLS #endif +#ifdef COMPILER_GCC + #if __GNUC__ >= 7 + #define FALLTHROUGH __attribute__ ((fallthrough)) + #else + #define FALLTHROUGH (void)0 + #endif +#else + #define FALLTHROUGH (void)0 +#endif + #endif /* RSYS_H */ diff --git a/src/test_misc.c b/src/test_misc.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2013-2018 Vincent Forest (vaplv@free.fr) + * + * The RSys library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The RSys library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the RSys library. If not, see <http://www.gnu.org/licenses/>. */ + +#include "rsys.h" + +int +main(int argc, char** argv) +{ + int i = 0; + (void)argv; + +#ifdef COMPILER_GCC + printf("GCC version: %d.%d.%d\n", + __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#endif + + /* Test fallthrough warning */ + switch(argc) { + case 2: ++i; FALLTHROUGH; + case 1: ++i; FALLTHROUGH; + case 0: ++i; break; + default: FATAL("Unreachable code.\n"); + } + return 0; +}