Skip to content

Commit e48d729

Browse files
Fixes for compiler warnings.
The majority were mismatched types and some uninitialized variables. Added flags to suppress some deprecation/security warnings.
1 parent 7c0b3b2 commit e48d729

Some content is hidden

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

64 files changed

+288
-259
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ include(FetchContent)
8282
if(MSVC)
8383
add_definitions(/MP)
8484
add_link_options(/debug:fastlink)
85+
#ignore security warnings and deprecation warnings
86+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
87+
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
8588
endif()
8689

8790
if (WIN32)

obs-studio-client/source/advanced-recording.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ osn::AdvancedRecording::AdvancedRecording(const Napi::CallbackInfo &info) : Napi
7070
{
7171
Napi::Env env = info.Env();
7272
Napi::HandleScope scope(env);
73-
int length = info.Length();
73+
size_t length = info.Length();
7474

7575
if (length <= 0 || !info[0].IsNumber()) {
7676
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -92,7 +92,7 @@ Napi::Value osn::AdvancedRecording::Create(const Napi::CallbackInfo &info)
9292
if (!ValidateResponse(info, response))
9393
return info.Env().Undefined();
9494

95-
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
95+
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
9696

9797
return instance;
9898
}
@@ -243,7 +243,7 @@ Napi::Value osn::AdvancedRecording::GetLegacySettings(const Napi::CallbackInfo &
243243
if (!ValidateResponse(info, response))
244244
return info.Env().Undefined();
245245

246-
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
246+
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
247247

248248
return instance;
249249
}
@@ -278,7 +278,7 @@ Napi::Value osn::AdvancedRecording::GetStreaming(const Napi::CallbackInfo &info)
278278
if (!ValidateResponse(info, response))
279279
return info.Env().Undefined();
280280

281-
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
281+
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
282282
return instance;
283283
}
284284

obs-studio-client/source/advanced-replay-buffer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ osn::AdvancedReplayBuffer::AdvancedReplayBuffer(const Napi::CallbackInfo &info)
6767
{
6868
Napi::Env env = info.Env();
6969
Napi::HandleScope scope(env);
70-
int length = info.Length();
70+
size_t length = info.Length();
7171

7272
if (length <= 0 || !info[0].IsNumber()) {
7373
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -89,7 +89,7 @@ Napi::Value osn::AdvancedReplayBuffer::Create(const Napi::CallbackInfo &info)
8989
if (!ValidateResponse(info, response))
9090
return info.Env().Undefined();
9191

92-
auto instance = osn::AdvancedReplayBuffer::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
92+
auto instance = osn::AdvancedReplayBuffer::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
9393

9494
return instance;
9595
}
@@ -148,7 +148,7 @@ Napi::Value osn::AdvancedReplayBuffer::GetLegacySettings(const Napi::CallbackInf
148148
if (!ValidateResponse(info, response))
149149
return info.Env().Undefined();
150150

151-
auto instance = osn::AdvancedReplayBuffer::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
151+
auto instance = osn::AdvancedReplayBuffer::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
152152

153153
return instance;
154154
}
@@ -183,7 +183,7 @@ Napi::Value osn::AdvancedReplayBuffer::GetStreaming(const Napi::CallbackInfo &in
183183
if (!ValidateResponse(info, response))
184184
return info.Env().Undefined();
185185

186-
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
186+
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
187187
return instance;
188188
}
189189

@@ -214,7 +214,7 @@ Napi::Value osn::AdvancedReplayBuffer::GetRecording(const Napi::CallbackInfo &in
214214
if (!ValidateResponse(info, response))
215215
return info.Env().Undefined();
216216

217-
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
217+
auto instance = osn::AdvancedRecording::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
218218
return instance;
219219
}
220220

obs-studio-client/source/advanced-streaming.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ osn::AdvancedStreaming::AdvancedStreaming(const Napi::CallbackInfo &info) : Napi
6363
{
6464
Napi::Env env = info.Env();
6565
Napi::HandleScope scope(env);
66-
int length = info.Length();
66+
size_t length = info.Length();
6767

6868
if (length <= 0 || !info[0].IsNumber()) {
6969
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -85,7 +85,7 @@ Napi::Value osn::AdvancedStreaming::Create(const Napi::CallbackInfo &info)
8585
if (!ValidateResponse(info, response))
8686
return info.Env().Undefined();
8787

88-
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
88+
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
8989

9090
return instance;
9191
}
@@ -236,7 +236,7 @@ Napi::Value osn::AdvancedStreaming::GetLegacySettings(const Napi::CallbackInfo &
236236
if (!ValidateResponse(info, response))
237237
return info.Env().Undefined();
238238

239-
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
239+
auto instance = osn::AdvancedStreaming::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
240240

241241
return instance;
242242
}

obs-studio-client/source/audio-encoder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ osn::AudioEncoder::AudioEncoder(const Napi::CallbackInfo &info) : Napi::ObjectWr
4343
{
4444
Napi::Env env = info.Env();
4545
Napi::HandleScope scope(env);
46-
int length = info.Length();
46+
size_t length = info.Length();
47+
this->uid = 0;
4748

4849
if (length <= 0 || !info[0].IsNumber()) {
4950
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -64,7 +65,7 @@ Napi::Value osn::AudioEncoder::Create(const Napi::CallbackInfo &info)
6465
if (!ValidateResponse(info, response))
6566
return info.Env().Undefined();
6667

67-
auto instance = osn::AudioEncoder::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
68+
auto instance = osn::AudioEncoder::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
6869

6970
return instance;
7071
}

obs-studio-client/source/audio-track.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ osn::AudioTrack::AudioTrack(const Napi::CallbackInfo &info) : Napi::ObjectWrap<o
4646
{
4747
Napi::Env env = info.Env();
4848
Napi::HandleScope scope(env);
49-
int length = info.Length();
49+
size_t length = info.Length();
50+
this->uid = 0;
5051

5152
if (length <= 0 || !info[0].IsNumber()) {
5253
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -69,7 +70,7 @@ Napi::Value osn::AudioTrack::Create(const Napi::CallbackInfo &info)
6970
if (!ValidateResponse(info, response))
7071
return info.Env().Undefined();
7172

72-
auto instance = osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
73+
auto instance = osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
7374

7475
return instance;
7576
}
@@ -92,7 +93,7 @@ Napi::Value osn::AudioTrack::GetAudioTracks(const Napi::CallbackInfo &info)
9293
if (uid == UINT64_MAX)
9394
tracks.Set(i - 2, info.Env().Undefined());
9495
else
95-
tracks.Set(i - 2, osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), uid)}));
96+
tracks.Set(i - 2, osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(uid))}));
9697
}
9798

9899
return tracks;
@@ -130,7 +131,7 @@ Napi::Value osn::AudioTrack::GetAtIndex(const Napi::CallbackInfo &info)
130131
if (!ValidateResponse(info, response))
131132
return info.Env().Undefined();
132133

133-
auto instance = osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
134+
auto instance = osn::AudioTrack::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
134135

135136
return instance;
136137
}

obs-studio-client/source/cache-manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "properties.hpp"
2121

2222
struct SceneInfo {
23-
uint64_t id;
23+
uint64_t id = 0;
2424
std::vector<std::pair<int64_t, uint64_t>> items;
2525
bool itemsOrderCached = false;
2626
std::string name;

obs-studio-client/source/callback-manager.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include "osn-error.hpp"
2222
#include "utility-v8.hpp"
2323

24+
#pragma warning(push, 0)
2425
#include <node.h>
26+
#pragma warning(pop)
2527
#include <sstream>
2628
#include <string>
2729
#include "shared.hpp"
@@ -114,7 +116,7 @@ void globalCallback::worker()
114116
obj.Set("width", Napi::Number::New(env, data->items[i]->width));
115117
obj.Set("height", Napi::Number::New(env, data->items[i]->height));
116118
obj.Set("flags", Napi::Number::New(env, data->items[i]->flags));
117-
result.Set(i, obj);
119+
result.Set(static_cast<uint32_t>(i), obj);
118120
}
119121
jsCallback.Call({result});
120122
} catch (...) {
@@ -135,21 +137,21 @@ void globalCallback::worker()
135137
Napi::Array input_peak = Napi::Array::New(env);
136138

137139
for (size_t j = 0; j < item->magnitude.size(); j++) {
138-
magnitude.Set(j, Napi::Number::New(env, item->magnitude[j]));
140+
magnitude.Set(static_cast<uint32_t>(j), Napi::Number::New(env, item->magnitude[j]));
139141
}
140142
for (size_t j = 0; j < item->peak.size(); j++) {
141-
peak.Set(j, Napi::Number::New(env, item->peak[j]));
143+
peak.Set(static_cast<uint32_t>(j), Napi::Number::New(env, item->peak[j]));
142144
}
143145
for (size_t j = 0; j < item->input_peak.size(); j++) {
144-
input_peak.Set(j, Napi::Number::New(env, item->input_peak[j]));
146+
input_peak.Set(static_cast<uint32_t>(j), Napi::Number::New(env, item->input_peak[j]));
145147
}
146148

147149
obj.Set("sourceName", Napi::String::New(env, item->source_name));
148150
obj.Set("magnitude", magnitude);
149151
obj.Set("peak", peak);
150152
obj.Set("inputPeak", input_peak);
151153

152-
result.Set(i, obj);
154+
result.Set(static_cast<uint32_t>(i), obj);
153155
}
154156

155157
jsCallback.Call({result});
@@ -191,7 +193,7 @@ void globalCallback::worker()
191193
uint32_t index = 1;
192194

193195
SourceSizeInfoData *data = new SourceSizeInfoData{{}};
194-
for (int i = 2; i < (response[1].value_union.ui32 * 4) + 2; i++) {
196+
for (uint32_t i = 2; i < (response[1].value_union.ui32 * 4) + 2; i++) {
195197
SourceSizeInfo *item = new SourceSizeInfo;
196198

197199
item->name = response[i++].value_str;
@@ -230,7 +232,7 @@ void globalCallback::worker()
230232
item->input_peak[ch] = response[index + ch * 3 + 2].value_union.fp32;
231233
}
232234

233-
index += (3 * channels);
235+
index += static_cast<uint32_t>((3 * channels));
234236

235237
volmeterDataArray->items.emplace_back(item);
236238
}

obs-studio-client/source/callback-manager.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
struct SourceSizeInfo {
2626
std::string name;
27-
uint32_t width;
28-
uint32_t height;
29-
uint32_t flags;
27+
uint32_t width = 0;
28+
uint32_t height = 0;
29+
uint32_t flags = 0;
3030
};
3131

3232
struct SourceSizeInfoData {

obs-studio-client/source/delay.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ osn::Delay::Delay(const Napi::CallbackInfo &info) : Napi::ObjectWrap<osn::Delay>
4444
{
4545
Napi::Env env = info.Env();
4646
Napi::HandleScope scope(env);
47-
int length = info.Length();
47+
size_t length = info.Length();
48+
this->uid = 0;
4849

4950
if (length <= 0 || !info[0].IsNumber()) {
5051
Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();
@@ -65,7 +66,7 @@ Napi::Value osn::Delay::Create(const Napi::CallbackInfo &info)
6566
if (!ValidateResponse(info, response))
6667
return info.Env().Undefined();
6768

68-
auto instance = osn::Delay::constructor.New({Napi::Number::New(info.Env(), response[1].value_union.ui64)});
69+
auto instance = osn::Delay::constructor.New({Napi::Number::New(info.Env(), static_cast<double>(response[1].value_union.ui64))});
6970

7071
return instance;
7172
}

0 commit comments

Comments
 (0)