Skip to content

Commit 3f7d2c4

Browse files
authored
Merge pull request #78 from mapbox/better-default-warnings
Enable more default warnings
2 parents 4b7371a + db54c32 commit 3f7d2c4

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

binding.gyp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
'system_includes': [
1010
"-isystem <(module_root_dir)/<!(node -e \"require('nan')\")",
1111
"-isystem <(module_root_dir)/mason_packages/.link/include/"
12+
],
13+
# Flags we pass to the compiler to ensure the compiler
14+
# warns us about potentially buggy or dangerous code
15+
'compiler_checks': [
16+
'-Wall',
17+
'-Wextra',
18+
'-Wconversion',
19+
'-pedantic-errors',
20+
'-Wconversion',
21+
'-Wshadow',
22+
'-Wfloat-equal',
23+
'-Wuninitialized',
24+
'-Wunreachable-code',
25+
'-Wold-style-cast',
26+
'-Wno-error=unused-variable'
1227
]
1328
},
1429
# `targets` is a list of targets for gyp to run.
@@ -64,15 +79,17 @@
6479
}
6580
}]
6681
],
67-
'cflags': [
68-
'<@(system_includes)'
82+
'cflags_cc': [
83+
'<@(system_includes)',
84+
'<@(compiler_checks)'
6985
],
7086
'xcode_settings': {
7187
'OTHER_LDFLAGS':[
7288
'-Wl,-bind_at_load'
7389
],
7490
'OTHER_CPLUSPLUSFLAGS': [
75-
'<@(system_includes)'
91+
'<@(system_includes)',
92+
'<@(compiler_checks)'
7693
],
7794
'GCC_ENABLE_CPP_RTTI': 'YES',
7895
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',

src/object_async/hello_async.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NAN_METHOD(HelloObjectAsync::New) {
6767
* Also, providing the length allows the std::string constructor to avoid calculating the length internally
6868
* and should be faster since it skips an operation.
6969
*/
70-
std::string name(*utf8_value, len);
70+
std::string name(*utf8_value, static_cast<std::size_t>(len));
7171

7272
/**
7373
* This line is where HelloObjectAsync takes ownership of "name" with the use of move semantics.
@@ -154,8 +154,8 @@ struct AsyncHelloWorker : Nan::AsyncWorker // NOLINT to disable cppcoreguideline
154154
AsyncHelloWorker& operator=(AsyncHelloWorker const&) = delete;
155155

156156
AsyncHelloWorker(bool louder, const std::string* name,
157-
Nan::Callback* callback)
158-
: Base(callback), result_{""}, louder_{louder}, name_{name} {}
157+
Nan::Callback* cb)
158+
: Base(cb), result_{""}, louder_{louder}, name_{name} {}
159159

160160
// The Execute() function is getting called when the worker starts to run.
161161
// - You only have access to member variables stored in this worker.

src/object_sync/hello.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ NAN_METHOD(HelloObject::New) {
5353
* Also, providing the length allows the std::string constructor to avoid calculating the length internally
5454
* and should be faster since it skips an operation.
5555
*/
56-
std::string name(*utf8_value, len);
56+
std::string name(*utf8_value, static_cast<std::size_t>(len));
5757

5858
/**
5959
* This line is where HelloObjectAsync takes ownership of "name" with the use of move semantics.

src/standalone_async/hello_async.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ std::string do_expensive_work(bool louder) {
7171
struct AsyncHelloWorker : Nan::AsyncWorker {
7272
using Base = Nan::AsyncWorker;
7373

74-
AsyncHelloWorker(bool louder, Nan::Callback* callback)
75-
: Base(callback), result_{""}, louder_{louder} {}
74+
AsyncHelloWorker(bool louder, Nan::Callback* cb)
75+
: Base(cb), result_{""}, louder_{louder} {}
7676

7777
// The Execute() function is getting called when the worker starts to run.
7878
// - You only have access to member variables stored in this worker.

0 commit comments

Comments
 (0)