Skip to content

Commit 4300192

Browse files
committed
fix: use more strict compiler flags
1 parent ba39e40 commit 4300192

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ cc_library(
1717
name = "ncrypto",
1818
srcs = glob(["src/*.cpp"]),
1919
hdrs = glob(["include/*.h", "include/ncrypto/*.h"]),
20+
copts = [
21+
"-Werror",
22+
"-Wextra",
23+
"-Wno-unused-parameter",
24+
"-Wimplicit-fallthrough",
25+
"-Wno-deprecated-declarations", # OpenSSL 3.0 deprecates many APIs we intentionally use
26+
],
2027
includes = ["include"],
2128
local_defines = {
2229
"NCRYPTO_BSSL_LIBDECREPIT_MISSING": select(

include/ncrypto/aead.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Aead final {
1919

2020
public:
2121
Aead() = default;
22-
Aead(const AeadInfo* info, const EVP_AEAD* aead) : info_(info), aead_(aead) {}
22+
Aead(const AeadInfo* info, const EVP_AEAD* aead) : aead_(aead), info_(info) {}
2323
Aead(const Aead&) = default;
2424
Aead& operator=(const Aead&) = default;
2525
NCRYPTO_DISALLOW_MOVE(Aead)

src/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
add_library(ncrypto ncrypto.cpp engine.cpp aead.cpp)
2+
3+
# Enable strict warning flags for ncrypto sources only
4+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
5+
target_compile_options(ncrypto PRIVATE
6+
-Werror
7+
-Wextra
8+
-Wno-unused-parameter
9+
-Wimplicit-fallthrough
10+
-Wno-deprecated-declarations # OpenSSL 3.0 deprecates many APIs we intentionally use
11+
)
12+
elseif(MSVC)
13+
target_compile_options(ncrypto PRIVATE
14+
/WX # Treat warnings as errors
15+
/W3 # Warning level 3 (production quality)
16+
/wd4100 # Unreferenced formal parameter (like -Wno-unused-parameter)
17+
/wd4267 # Conversion from 'size_t' to smaller type
18+
/wd4244 # Conversion, possible loss of data
19+
)
20+
endif()
21+
222
if (NCRYPTO_SHARED_LIBS)
323
target_link_libraries(ncrypto PUBLIC OpenSSL::SSL OpenSSL::Crypto)
424
else()

0 commit comments

Comments
 (0)