From a3a142aec3efbb1a2047a7b539386edc5eeb3178 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 14 Oct 2019 16:04:16 +0100 Subject: [PATCH] Fixed some compiler warnings --- native/serverconnection/CMakeLists.txt | 3 +++ .../serverconnection/src/audio/AudioInput.cpp | 2 +- .../src/audio/AudioOutput.cpp | 4 ++-- .../src/audio/AudioResampler.cpp | 2 +- .../src/audio/codec/OpusConverter.cpp | 2 +- .../src/audio/codec/OpusConverter.h | 2 +- .../src/audio/filter/FilterThreshold.cpp | 4 ++-- .../src/audio/filter/FilterVad.cpp | 4 ++-- .../src/audio/js/AudioConsumer.h | 2 +- native/serverconnection/src/bindings.cpp | 2 +- .../src/connection/ServerConnection.cpp | 22 +++++++++---------- .../src/connection/audio/AudioSender.h | 2 +- .../src/connection/ft/FileTransferManager.cpp | 6 ++--- native/serverconnection/src/hwuid.cpp | 15 ++++++++----- package.json | 8 +++---- 15 files changed, 44 insertions(+), 36 deletions(-) diff --git a/native/serverconnection/CMakeLists.txt b/native/serverconnection/CMakeLists.txt index 5730d5e..1eb82d3 100644 --- a/native/serverconnection/CMakeLists.txt +++ b/native/serverconnection/CMakeLists.txt @@ -85,7 +85,10 @@ include_directories(${ed25519_INCLUDE_DIR}) find_package(ThreadPool REQUIRED) include_directories(${ThreadPool_INCLUDE_DIR}) if (WIN32) + add_compile_options(/NODEFAULTLIB:ThreadPoolStatic) add_definitions(-DWINDOWS) #Required by ThreadPool + add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Let windows allow strerror + add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING) # For the FMT library endif () find_package(Soxr REQUIRED) diff --git a/native/serverconnection/src/audio/AudioInput.cpp b/native/serverconnection/src/audio/AudioInput.cpp index 0574ecf..3eafe2d 100644 --- a/native/serverconnection/src/audio/AudioInput.cpp +++ b/native/serverconnection/src/audio/AudioInput.cpp @@ -69,7 +69,7 @@ bool AudioInput::open_device(std::string& error, PaDeviceIndex index) { parameters.sampleFormat = paFloat32; parameters.suggestedLatency = this->_current_device->defaultLowOutputLatency; - auto err = Pa_OpenStream(&this->input_stream, ¶meters, nullptr, this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioInput::_audio_callback, this); + auto err = Pa_OpenStream(&this->input_stream, ¶meters, nullptr, (double) this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioInput::_audio_callback, this); if(err != paNoError) { error = "Pa_OpenStream returned " + to_string(err); return false; diff --git a/native/serverconnection/src/audio/AudioOutput.cpp b/native/serverconnection/src/audio/AudioOutput.cpp index 04e4561..7d1d947 100644 --- a/native/serverconnection/src/audio/AudioOutput.cpp +++ b/native/serverconnection/src/audio/AudioOutput.cpp @@ -34,7 +34,7 @@ ssize_t AudioOutputSource::pop_samples(void *buffer, size_t samples) { } sample_count -= sc; - buf->sample_index += sc; + buf->sample_index += (uint16_t) sc; if(buf->sample_index == buf->sample_size) this->sample_buffers.pop_front(); @@ -258,7 +258,7 @@ bool AudioOutput::open_device(std::string& error, PaDeviceIndex index) { output_parameters.sampleFormat = paFloat32; output_parameters.suggestedLatency = this->_current_device->defaultLowOutputLatency; - auto err = Pa_OpenStream(&output_stream, nullptr, &output_parameters, this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioOutput::_audio_callback, this); + auto err = Pa_OpenStream(&output_stream, nullptr, &output_parameters, (double) this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioOutput::_audio_callback, this); if(err != paNoError) { error = "Pa_OpenStream returned " + to_string(err); return false; diff --git a/native/serverconnection/src/audio/AudioResampler.cpp b/native/serverconnection/src/audio/AudioResampler.cpp index 4423734..43cae70 100644 --- a/native/serverconnection/src/audio/AudioResampler.cpp +++ b/native/serverconnection/src/audio/AudioResampler.cpp @@ -9,7 +9,7 @@ using namespace tc::audio; AudioResampler::AudioResampler(size_t irate, size_t orate, size_t channels) : _input_rate(irate), _output_rate(orate), _channels(channels) { if(this->input_rate() != this->output_rate()) { soxr_error_t error; - this->soxr_handle = soxr_create(this->_input_rate, this->_output_rate, (unsigned) this->_channels, &error, nullptr, nullptr, nullptr); + this->soxr_handle = soxr_create((double) this->_input_rate, (double) this->_output_rate, (unsigned) this->_channels, &error, nullptr, nullptr, nullptr); if(!this->soxr_handle) { log_error(category::audio, tr("Failed to create soxr resampler: {}. Input: {}; Output: {}; Channels: {}"), error, this->_input_rate, this->_output_rate, this->_channels); diff --git a/native/serverconnection/src/audio/codec/OpusConverter.cpp b/native/serverconnection/src/audio/codec/OpusConverter.cpp index 4092d3f..2a2ee96 100644 --- a/native/serverconnection/src/audio/codec/OpusConverter.cpp +++ b/native/serverconnection/src/audio/codec/OpusConverter.cpp @@ -81,7 +81,7 @@ ssize_t OpusConverter::decode_lost(std::string &error, size_t packets) { auto buffer = (float*) malloc(this->_frame_size * this->_channels * sizeof(float)); while (packets-- > 0) { - auto result = opus_decode_float(this->decoder, nullptr, 0, buffer, this->_frame_size, false); + auto result = opus_decode_float(this->decoder, nullptr, 0, buffer, (int) this->_frame_size, false); if(result < OPUS_OK) log_warn(category::audio, tr("Opus decode lost resulted in error: {}"), result); } diff --git a/native/serverconnection/src/audio/codec/OpusConverter.h b/native/serverconnection/src/audio/codec/OpusConverter.h index fd970e9..8a9f17c 100644 --- a/native/serverconnection/src/audio/codec/OpusConverter.h +++ b/native/serverconnection/src/audio/codec/OpusConverter.h @@ -21,7 +21,7 @@ namespace tc { void reset_decoder() override; ssize_t encode(std::string & /* error */, const void * /* source */, void * /* target */, size_t /* target size */) override; - ssize_t decode(std::string & /* error */, const void */* source */, size_t /* source size */, void *pVoid1) override; + ssize_t decode(std::string & /* error */, const void * /* source */, size_t /* source size */, void *pVoid1) override; ssize_t decode_lost(std::string &string, size_t /* packets */) override; diff --git a/native/serverconnection/src/audio/filter/FilterThreshold.cpp b/native/serverconnection/src/audio/filter/FilterThreshold.cpp index 46416af..3919188 100644 --- a/native/serverconnection/src/audio/filter/FilterThreshold.cpp +++ b/native/serverconnection/src/audio/filter/FilterThreshold.cpp @@ -46,9 +46,9 @@ bool ThresholdFilter::process(const void *_buffer) { auto percentage = this->analyze(_buffer, channel); if(channel == 0) - value = percentage; + value = (float) percentage; else - value = merge_ab(value, percentage, 100); + value = merge_ab(value, (float) percentage, 100); } auto last_level = this->_current_level; diff --git a/native/serverconnection/src/audio/filter/FilterVad.cpp b/native/serverconnection/src/audio/filter/FilterVad.cpp index 73b0dae..d38c3a8 100644 --- a/native/serverconnection/src/audio/filter/FilterVad.cpp +++ b/native/serverconnection/src/audio/filter/FilterVad.cpp @@ -33,12 +33,12 @@ bool VadFilter::initialize(std::string &error, size_t mode, size_t margin) { return false; } - if(fvad_set_sample_rate(this->_vad_handle, this->_sample_rate) != 0) { + if(fvad_set_sample_rate(this->_vad_handle, (int) this->_sample_rate) != 0) { error = "invalid sample rate. Sample rate must be one of [8000, 16000, 32000 and 48000]"; return false; } - if(fvad_set_mode(this->_vad_handle, mode) != 0) { + if(fvad_set_mode(this->_vad_handle, (int) mode) != 0) { error = "failed to set mode"; return false; } diff --git a/native/serverconnection/src/audio/js/AudioConsumer.h b/native/serverconnection/src/audio/js/AudioConsumer.h index 197e20f..00658e9 100644 --- a/native/serverconnection/src/audio/js/AudioConsumer.h +++ b/native/serverconnection/src/audio/js/AudioConsumer.h @@ -63,7 +63,7 @@ namespace tc { inline std::shared_ptr native_consumer() { return this->_handle; } std::mutex native_read_callback_lock; - std::function native_read_callback; + std::function native_read_callback; private: AudioRecorderWrapper* _recorder; diff --git a/native/serverconnection/src/bindings.cpp b/native/serverconnection/src/bindings.cpp index 43ce921..8370e8f 100644 --- a/native/serverconnection/src/bindings.cpp +++ b/native/serverconnection/src/bindings.cpp @@ -76,7 +76,7 @@ NAN_MODULE_INIT(init) { #ifndef WIN32 logger::info(category::general, tr("Hello World from C. PPID: {}, PID: {}"), getppid(), getpid()); #else - logger::info(category::general, tr("Hello World from C."), getppid(), getpid()); + logger::info(category::general, tr("Hello World from C. PID: {}"), _getpid()); #endif /* diff --git a/native/serverconnection/src/connection/ServerConnection.cpp b/native/serverconnection/src/connection/ServerConnection.cpp index 7acaa93..92d5593 100644 --- a/native/serverconnection/src/connection/ServerConnection.cpp +++ b/native/serverconnection/src/connection/ServerConnection.cpp @@ -126,7 +126,7 @@ void ServerConnection::initialize() { argv[0] = Nan::New(error_id); if(this->callback_connect) - this->callback_connect->Call(1, argv); + Nan::Call(*this->callback_connect, 1, argv); this->callback_connect = nullptr; } }); @@ -138,7 +138,7 @@ void ServerConnection::initialize() { argv[0] = Nan::New(error_id); if(this->callback_disconnect) - this->callback_disconnect->Call(1, argv); + Nan::Call(*this->callback_disconnect, 1, argv); this->callback_disconnect = nullptr; }); @@ -253,7 +253,7 @@ NAN_METHOD(ServerConnection::connect) { if(identity_key->IsString()) { auto& identity = this->protocol_handler->get_identity_key(); auto key = base64::decode(*Nan::Utf8String(identity_key->ToString(Nan::GetCurrentContext()).ToLocalChecked())); - if(ecc_import((u_char*) key.data(), key.length(), &identity) != CRYPT_OK) { + if(ecc_import((u_char*) key.data(), (unsigned long) key.length(), &identity) != CRYPT_OK) { Nan::ThrowError(tr("failed to import identity")); return; } @@ -272,7 +272,7 @@ NAN_METHOD(ServerConnection::connect) { sockaddr_storage remote_address{}; /* resolve address */ { - addrinfo hints{}, *result, *p; + addrinfo hints{}, *result; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -355,7 +355,7 @@ NAN_METHOD(ServerConnection::error_message) { return; } - auto error = this->errors.get_message(info[0]->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0)); + auto error = this->errors.get_message((ErrorHandler::error_id) info[0]->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0)); info.GetReturnValue().Set(Nan::New(error).ToLocalChecked()); } @@ -397,7 +397,7 @@ NAN_METHOD(ServerConnection::send_command) { ts::Command cmd(*Nan::Utf8String(command)); for(size_t index = 0; index < arguments->Length(); index++) { - auto object = arguments->Get(index); + auto object = arguments->Get((uint32_t) index); if(!object->IsObject()) { Nan::ThrowError(Nan::New("invalid parameter (" + to_string(index) + ")").ToLocalChecked()); return; @@ -428,7 +428,7 @@ NAN_METHOD(ServerConnection::send_command) { for(size_t index = 0; index < switches->Length(); index++) { - auto object = switches->Get(index); + auto object = switches->Get((uint32_t) index); if(!object->IsString()) { Nan::ThrowError(Nan::New("invalid switch (" + to_string(index) + ")").ToLocalChecked()); return; @@ -595,7 +595,7 @@ void ServerConnection::_execute_callback_commands() { v8::Local arguments[3]; arguments[0] = Nan::New(next_command->command()).ToLocalChecked(); - auto parameters = Nan::New(next_command->bulkCount()); + auto parameters = Nan::New((int) next_command->bulkCount()); for(size_t index = 0; index < next_command->bulkCount(); index++) { auto object = Nan::New(); auto& bulk = next_command->operator[](index); @@ -603,15 +603,15 @@ void ServerConnection::_execute_callback_commands() { for(const auto& key : bulk.keys()) Nan::Set(object, Nan::New(key).ToLocalChecked(), Nan::New(bulk[key].string()).ToLocalChecked()); - parameters->Set(index, object); + parameters->Set((uint32_t) index, object); } arguments[1] = parameters; - auto switched = Nan::New(next_command->parms().size()); + auto switched = Nan::New((int) next_command->parms().size()); for(size_t index = 0; index < next_command->parms().size(); index++) { auto& key = next_command->parms()[index]; - parameters->Set(index, Nan::New(key).ToLocalChecked()); + parameters->Set((uint32_t) index, Nan::New(key).ToLocalChecked()); } arguments[2] = switched; diff --git a/native/serverconnection/src/connection/audio/AudioSender.h b/native/serverconnection/src/connection/audio/AudioSender.h index eddf538..75e1391 100644 --- a/native/serverconnection/src/connection/audio/AudioSender.h +++ b/native/serverconnection/src/connection/audio/AudioSender.h @@ -11,7 +11,7 @@ namespace tc { } class AudioResampler; - struct AudioOutputSource; + class AudioOutputSource; } namespace connection { diff --git a/native/serverconnection/src/connection/ft/FileTransferManager.cpp b/native/serverconnection/src/connection/ft/FileTransferManager.cpp index bd0e138..319ba09 100644 --- a/native/serverconnection/src/connection/ft/FileTransferManager.cpp +++ b/native/serverconnection/src/connection/ft/FileTransferManager.cpp @@ -39,7 +39,7 @@ bool Transfer::initialize(std::string &error) { /* resolve address */ { - addrinfo hints{}, *result, *p; + addrinfo hints{}, *result; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -63,7 +63,7 @@ bool Transfer::initialize(std::string &error) { } log_info(category::file_transfer, tr("Setting remote port to {}"), this->_options->remote_port); - this->_socket = ::socket(this->remote_address.ss_family, SOCK_STREAM | SOCK_NONBLOCK, 0); + this->_socket = (int) ::socket(this->remote_address.ss_family, SOCK_STREAM | SOCK_NONBLOCK, 0); if(this->_socket < 0) { this->finalize(); error = tr("failed to spawn socket"); @@ -225,7 +225,7 @@ void Transfer::callback_read(short flags) { int64_t buffer_length = 1024; char buffer[1024]; - buffer_length = recv(this->_socket, buffer, buffer_length, MSG_DONTWAIT); + buffer_length = recv(this->_socket, buffer, (int) buffer_length, MSG_DONTWAIT); if(buffer_length < 0) { #ifdef WIN32 auto error = WSAGetLastError(); diff --git a/native/serverconnection/src/hwuid.cpp b/native/serverconnection/src/hwuid.cpp index 462089f..e413956 100644 --- a/native/serverconnection/src/hwuid.cpp +++ b/native/serverconnection/src/hwuid.cpp @@ -104,9 +104,14 @@ using namespace std; //https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf int get_uuid(uint8_t* uuid) { +#ifdef WIN32 + typedef DWORD api_size_t; +#else + typedef size_t api_size_t; +#endif unique_ptr smbios_data{ nullptr, ::free }; - size_t smbios_size = 0; - size_t bytes_written = 0; + api_size_t smbios_size = 0; + api_size_t bytes_written = 0; // Query size of SMBIOS data. smbios_size = GetSystemFirmwareTable('RSMB', 0, nullptr, 0); @@ -141,7 +146,7 @@ int get_uuid(uint8_t* uuid) { } ptr = ptr + header->length; // point to struct end - while (0 != (*ptr | *(ptr + 1)) && *ptr < (uint8_t) &*smbios_data + smbios_data->length) + while (0 != (*ptr | *(ptr + 1)) && ptr + 1 < (uint8_t*) &*smbios_data + smbios_data->length) ptr++; // skip string area ptr += 2; @@ -181,7 +186,7 @@ inline bool generate_uuid(std::string& result, uint32_t& check_sum) { { crc32_state state; crc32_init(&state); - crc32_update(&state, (u_char*) result.data(), result.length()); + crc32_update(&state, (uint8_t*) result.data(), (unsigned long) result.length()); crc32_finish(&state, &check_sum, sizeof(check_sum)); } @@ -192,7 +197,7 @@ inline bool generate_uuid(std::string& result, uint32_t& check_sum) { inline bool check_uuid(std::string& uuid, uint32_t check_sum) { crc32_state state; crc32_init(&state); - crc32_update(&state, (uint8_t*) uuid.data(), uuid.length()); + crc32_update(&state, (uint8_t*) uuid.data(), (unsigned long) uuid.length()); uint32_t result; crc32_finish(&state, &result, sizeof(result)); diff --git a/package.json b/package.json index e26c5e8..e2257f4 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@types/electron-packager": "8.7.2", "@types/fs-extra": "^8.0.0", "@types/jquery": "^3.3.31", - "@types/request": "^2.48.2", + "@types/request": "^2.48.3", "@types/request-promise": "^4.1.44", "@types/tar-stream": "^1.6.1", "asar": "^2.0.1", @@ -36,8 +36,8 @@ "electron-packager": "8.7.2", "nodemon": "^1.19.2", "platform-dependent-modules": "0.0.14", - "sass": "^1.22.10", - "typescript": "^3.6.2" + "sass": "^1.22.12", + "typescript": "^3.6.3" }, "dependencies": { "@types/minimist": "^1.2.0", @@ -64,7 +64,7 @@ "nan": "^2.14.0", "node-ssh": "^6.0.0", "only": "0.0.2", - "psl": "^1.3.1", + "psl": "^1.4.0", "pure-uuid": "^1.5.7", "rc": "^1.2.8", "rcedit": "^1.1.2",