Skip to content

Commit 59ca6b5

Browse files
author
Jason Mobarak
authored
open source publish 87b9931..5c3e738 (#231)
1 parent 87b9931 commit 59ca6b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2760
-9770
lines changed

.clang-tidy

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1-
# See: http://releases.llvm.org/6.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
1+
# See: http://clang.llvm.org/extra/clang-tidy/
2+
# clang-tidy-4.0 src/pvt_engine/*.cc -- -std=c++14 -Irefactor/common/ -Irefactor/common/libswiftnav -Iinclude/ -Iinclude/libswiftnav/ -isystem -third_party/ -isystem./libfec/include/ -Ithird_party/Optional -isystem./third_party/json/src/ -isystem./third_party/eigen/
3+
#
4+
# TODO (mookerji: Disabled are clang-analyzer-alpha.*, since these seem to check
5+
# non-project code. Fix when resolved in LLVM.
6+
#
7+
# TODO (nsirola: Disabled a bunch of checks on updating to clang-4.0, to be
8+
# re-enabled and checked individually:
9+
# -modernize-deprecated-headers (new in 3.9)
10+
# -modernize-use-default-member-init (new in 4.0)
11+
# -modernize-redundant-void-arg (since 3.8, for some reason did not warn before)
12+
# -modernize-use-using (new in 3.9)
13+
# -modernize-use-equals-delete (new in 4.0)
14+
# -modernize-use-equals-default (new in 4.0)
15+
# -modernize-use-bool-literals (new in 3.9)
16+
# -modernize-use-auto (extended in 4.0)
17+
# -modernize-use-emplace (new in 3.9)
18+
# -cppcoreguidelines-special-member-functions (new in 4.0)
19+
# -cppcoreguidelines-pro-type-member-init (new in 3.9)
20+
# -readability-avoid-const-params-in-decls (new in 3.9)
21+
# -readability-non-const-parameter (new in 4.0)
22+
# -readability-redundant-member-init (new in 4.0)
23+
# -readability-redundant-declaration (new in 4.0)
24+
# -cert-err34-c (new in 3.9)
25+
# -cert-err58-cpp (since 3.8, for some reason did not warn before)
26+
# -performance-unnecessary-value-param (new in 3.9)
27+
# -google-runtime-references (new in 4.0)
28+
# -clang-analyzer-optin.cplusplus.VirtualCall (new in 4.0)
29+
# -clang-analyzer-core.CallAndMessage (not mentioned in release notes)
30+
# -clang-analyzer-core.UndefinedBinaryOperatorResult (not mentioned in release notes)
31+
# -clang-analyzer-core.uninitialized.Assign (not mentioned in release notes)
32+
#
33+
# TODO jbangelo: Disabled several more check on updating to clang-6.0, really should re-enable and fix
34+
# -cppcoreguidelines-owning-memory
35+
# -cert-dcl21-cpp
36+
# -modernize-return-braced-init-list
37+
38+
Checks: "-*,cert-*,google-*,misc-*,readability-*,clang-analyzer-*,modernize-*,performance-*,-clang-analyzer-alpha*,cppcoreguidelines-*,cert-*,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-modernize-pass-by-value,-modernize-deprecated-headers,-modernize-use-default-member-init,-modernize-redundant-void-arg,-modernize-use-using,-modernize-use-equals-delete,-modernize-use-equals-default,-modernize-use-bool-literals,-modernize-use-auto,-modernize-use-emplace,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-pro-type-member-init,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-readability-redundant-member-init,-readability-redundant-declaration,-cert-err34-c,-cert-err58-cpp,-performance-unnecessary-value-param,-google-runtime-references,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.CallAndMessage,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-core.uninitialized.Assign,-cppcoreguidelines-owning-memory,-clang-analyzer-core.uninitialized.UndefReturn,-cert-dcl21-cpp,-modernize-return-braced-init-list,-cert-dcl03-c,-misc-static-assert"
39+
HeaderFilterRegex: '.*'
40+
AnalyzeTemporaryDtors: true
41+
...
242

3-
Checks: "*,
4-
-cert-dcl03-c,-misc-static-assert,-hicpp-static-assert,
5-
-hicpp-signed-bitwise,
6-
-bugprone-integer-division,
7-
-llvm-header-guard"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
build
1+
build*
22
include/swiftnav/config.h
3-
/fixes.yaml
3+
*.swp
44

55
# IDE files
66
.vscode/

CMakeLists.txt

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ include(GNUInstallDirs)
1010
include(CCache)
1111
include(SwiftCmakeOptions)
1212
include(TestTargets)
13+
include(LanguageStandards)
14+
include(CompileOptions)
1315

1416
set(disable_tests FALSE)
15-
if(MSVC)
17+
if(WIN32)
1618
message(STATUS "MSVC detected, skipping unit tests")
1719
set(disable_tests TRUE)
1820
endif()
@@ -91,41 +93,30 @@ set(SRCS
9193
src/troposphere.c)
9294

9395
add_library(swiftnav ${HDRS} ${SRCS})
96+
swift_set_language_standards(swiftnav)
97+
swift_set_compile_options(swiftnav REMOVE -Wconversion -Wstack-protector)
98+
9499
target_code_coverage(swiftnav AUTO ALL)
95100
target_include_directories(swiftnav PUBLIC ${PROJECT_SOURCE_DIR}/include)
96101
target_include_directories(swiftnav PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
97102
if(LIBSWIFTNAV_ENABLE_STDERR_LOGGING)
98103
target_compile_definitions(swiftnav PRIVATE "LIBSWIFTNAV_ENABLE_STDERR_LOGGING")
99104
endif()
100-
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/swiftnav)
101-
install(TARGETS swiftnav DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
102105

103-
set_property(TARGET swiftnav PROPERTY C_STANDARD 99)
106+
target_compile_options(swiftnav PRIVATE "-UNDEBUG")
107+
108+
target_code_coverage(swiftnav AUTO ALL)
109+
target_include_directories(swiftnav PUBLIC ${PROJECT_SOURCE_DIR}/include)
110+
target_include_directories(swiftnav PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
104111

105112
if (MSVC)
106113
else ()
107-
target_link_libraries(swiftnav PRIVATE m)
108-
target_compile_options(swiftnav PRIVATE "-Werror")
109-
target_compile_options(swiftnav PRIVATE "-Wmissing-prototypes")
110-
target_compile_options(swiftnav PRIVATE "-Wimplicit")
111-
target_compile_options(swiftnav PRIVATE "-Wshadow")
112-
target_compile_options(swiftnav PRIVATE "-Wswitch-default")
113-
target_compile_options(swiftnav PRIVATE "-Wswitch-enum")
114-
target_compile_options(swiftnav PRIVATE "-Wundef")
115-
target_compile_options(swiftnav PRIVATE "-Wuninitialized")
116-
target_compile_options(swiftnav PRIVATE "-Wpointer-arith")
117-
target_compile_options(swiftnav PRIVATE "-Wstrict-prototypes")
118-
target_compile_options(swiftnav PRIVATE "-Wcast-align")
119-
target_compile_options(swiftnav PRIVATE "-Wformat=2")
120-
target_compile_options(swiftnav PRIVATE "-Wimplicit-function-declaration")
121-
target_compile_options(swiftnav PRIVATE "-Wredundant-decls")
122-
target_compile_options(swiftnav PRIVATE "-Wformat-security")
123-
# require at least gcc 5.0
124-
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0)
125-
target_compile_options(swiftnav PRIVATE "-Wfloat-conversion")
126-
endif()
114+
target_link_libraries(swiftnav PRIVATE m)
127115
endif()
128116

117+
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/swiftnav)
118+
install(TARGETS swiftnav DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
119+
129120
# unit tests
130121
if(libswiftnav_BUILD_TESTS OR libswiftnav_BUILD_TEST_LIBS)
131122
add_subdirectory(tests)

include/swiftnav/bits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
* \return 32-bit signed integer with 2-complement of \a n_bits in \a arg
3737
*/
3838
#define BITS_SIGN_EXTEND_32(n_bits, arg) \
39-
((struct { s32 bits : n_bits; }){.bits = (arg)}.bits)
39+
((struct { s32 bits : (n_bits); }){.bits = (arg)}.bits)
4040
/**
4141
* Sign extension macro for 64-bit integers.
4242
*
@@ -46,7 +46,7 @@ extern "C" {
4646
* \return 64-bit signed integer with 2-complement of \a n_bits in \a arg
4747
*/
4848
#define BITS_SIGN_EXTEND_64(n_bits, arg) \
49-
((struct { s64 bits : n_bits; }){.bits = (arg)}.bits)
49+
((struct { s64 bits : (n_bits); }){.bits = (arg)}.bits)
5050

5151
u8 parity(u32 x);
5252
u16 bytes_interleave(const u8 x, const u8 y);

include/swiftnav/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extern "C" {
7474
#define CLAMP_DIFF(a, b) (MAX((a), (b)) - (b))
7575
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
7676
#define ARRAY_SIZE2(a) (sizeof(a) / sizeof((a)[0][0]))
77-
#define SIGN(a) ((a >= 0) ? +1 : -1)
77+
#define SIGN(a) (((a) >= 0) ? +1 : -1)
7878

7979
/* See http://c-faq.com/cpp/multistmt.html for
8080
* and explaination of the do {} while(0)

include/swiftnav/ephemeris.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
extern "C" {
2323
#endif
2424

25-
#define INVALID_GPS_URA_INDEX -1
25+
#define INVALID_GPS_URA_INDEX (-1)
2626
#define MAX_ALLOWED_GPS_URA_IDX 15
27-
#define INVALID_URA_VALUE -1.0f
27+
#define INVALID_URA_VALUE (-1.0f)
2828
#define INVALID_GAL_SISA_INDEX 0xFF
2929
#define URA_VALID(x) ((x) >= 0)
3030

include/swiftnav/float_equality.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef SWIFTNAV_FLOAT_EQUALITY_H
2+
#define SWIFTNAV_FLOAT_EQUALITY_H
3+
4+
#include <math.h>
5+
#include <stdbool.h>
6+
7+
#include <swiftnav/constants.h>
8+
9+
static inline bool double_equal(double a, double b) {
10+
return fabs(a - b) < FLOAT_EQUALITY_EPS;
11+
}
12+
13+
static inline bool float_equal(float a, float b) {
14+
return double_equal((double)a, (double)b);
15+
}
16+
17+
#endif

include/swiftnav/geoid_model.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
/*------------------------------------------------------------------------------
2-
* Reproduced from https://github.com/swift-nav/RTKLIB/blob/master/src/geoid.c
3-
* according to the RTKLib licence
1+
/*
2+
* Copyright (C) 2020 Swift Navigation Inc.
3+
* Contact: Swift Navigation <dev@swiftnav.com>
44
*
5-
* Copyright (C) 2007-2013 by T.TAKASU, All rights reserved.
6-
*-----------------------------------------------------------------------------*/
5+
* This source is subject to the license found in the file 'LICENSE' which must
6+
* be distributed together with this source. All other rights reserved.
7+
*
8+
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
9+
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
10+
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
712

813
#ifndef GEOID_MODEL_H
914
#define GEOID_MODEL_H
@@ -14,17 +19,8 @@
1419
extern "C" {
1520
#endif /* __cplusplus */
1621

17-
#define MIN_LON 0
18-
#define MAX_LON 360
19-
#define MIN_LAT (-90)
20-
#define MAX_LAT 90
21-
22-
#define LAT_GRID_SPACING_DEG 1
23-
#define LON_GRID_SPACING_DEG 1
24-
25-
extern const float GEOID[(MAX_LON - MIN_LON) / LON_GRID_SPACING_DEG + 1]
26-
[(MAX_LAT - MIN_LAT) / LAT_GRID_SPACING_DEG + 1];
27-
22+
// range for lat_rad is (-M_PI_2, M_PI_2)
23+
// range for lon_rad is (-2 * M_PI, 2 * M_PI)
2824
float get_geoid_offset(double lat_rad, double lon_rad);
2925

3026
#ifdef __cplusplus

include/swiftnav/gnss_time.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ extern "C" {
110110
#define MJD_JAN_6_1980 44244
111111

112112
/** Modified Julian days of 1601-01-01 */
113-
#define MJD_JAN_1_1601 -94187
113+
#define MJD_JAN_1_1601 (-94187)
114114

115-
#define WN_UNKNOWN -1
116-
#define TOW_UNKNOWN -1
115+
#define WN_UNKNOWN (-1)
116+
#define TOW_UNKNOWN (-1)
117117

118118
/** GLONASS minimum day number */
119119
#define GLO_NT_0_FLOOR 1

0 commit comments

Comments
 (0)