From 1fec83e9ec37a3d60422993463278adbcff658ac Mon Sep 17 00:00:00 2001 From: Michael Strain Date: Thu, 8 Feb 2024 08:47:05 -0600 Subject: [PATCH 1/2] Werror on linux and fix up warnings --- CMakeLists.txt | 18 ++++++++++++++++++ source/server/linux/daemonize.cpp | 6 +++--- .../tests/system/nidaqmx_driver_api_tests.cpp | 1 - .../tests/system/nidcpower_session_tests.cpp | 2 -- .../tests/system/nidigital_session_tests.cpp | 2 -- source/tests/system/nidmm_session_tests.cpp | 19 ------------------- source/tests/system/nifgen_session_tests.cpp | 2 -- source/tests/system/nirfsg_session_tests.cpp | 2 -- source/tests/system/niscope_session_tests.cpp | 2 -- .../tests/system/niswitch_session_tests.cpp | 2 -- .../system/nixnetsocket_driver_api_tests.cpp | 6 ------ .../unit/ni_fake_non_ivi_service_tests.cpp | 1 - .../unit/xnet_socket_converters_tests.cpp | 8 +++++--- 13 files changed, 26 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac1027ee..ffd9f0550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -410,6 +410,24 @@ add_executable(ni_grpc_device_server ${calibrationoperations_restricted_grpc_srcs} ${nidriver_service_srcs}) +# Enable warnings only on source that we own, not generated code or dependencies +file(GLOB_RECURSE SOURCE_TO_ENABLE_WARNINGS "source/*.cpp") +if(WIN32) + set_source_files_properties( + ${SOURCE_TO_ENABLE_WARNINGS} + APPEND + PROPERTIES + COMPILE_OPTIONS "/WX" + ) +else() + set_source_files_properties( + ${SOURCE_TO_ENABLE_WARNINGS} + APPEND + PROPERTIES + COMPILE_OPTIONS "-Werror" + ) +endif() + if(WIN32) set(version_generated_dir "${CMAKE_CURRENT_BINARY_DIR}/version") file(MAKE_DIRECTORY ${version_generated_dir}) diff --git a/source/server/linux/daemonize.cpp b/source/server/linux/daemonize.cpp index 79b1a007d..42f71efa5 100644 --- a/source/server/linux/daemonize.cpp +++ b/source/server/linux/daemonize.cpp @@ -59,9 +59,9 @@ int create_pidfile(const std::string& identity) { exit(EXIT_FAILURE); } - size = snprintf(NULL, 0, "%ld\n", getpid()); + size = snprintf(NULL, 0, "%d\n", getpid()); std::string pid_str(size, ' '); - if (snprintf(&pid_str[0], size + 1, "%ld\n", getpid()) > size) { + if (snprintf(&pid_str[0], size + 1, "%d\n", getpid()) > size) { logging::log(logging::Level_Error, "creating pid string failed"); exit(EXIT_FAILURE); } @@ -76,7 +76,7 @@ int create_pidfile(const std::string& identity) { close(fd); exit(EXIT_FAILURE); } - if (write(fd, pid_str.c_str(), size) != pid_str.length()) { + if (write(fd, pid_str.c_str(), size) != static_cast(pid_str.length())) { logging::log(logging::Level_Error, "writing pid file failed: %d (%s)", errno, strerror(errno)); close(fd); exit(EXIT_FAILURE); diff --git a/source/tests/system/nidaqmx_driver_api_tests.cpp b/source/tests/system/nidaqmx_driver_api_tests.cpp index ab32863d0..8079658b9 100644 --- a/source/tests/system/nidaqmx_driver_api_tests.cpp +++ b/source/tests/system/nidaqmx_driver_api_tests.cpp @@ -1388,7 +1388,6 @@ TEST_F(NiDAQmxDriverApiTests, SetYInterceptAttribute_GetYInterceptAttribute_Retu TEST_F(NiDAQmxDriverApiTests, SetPreScaledUnits_GetPreScaledUnits_ReturnsAttribute) { const auto SCALE_NAME = std::string("TestScale"); - const auto Y_INTERCEPT = -3.0; auto scale_status = create_lin_scale(SCALE_NAME, 0.5); auto set_response = client::set_scale_attribute_int32( stub(), diff --git a/source/tests/system/nidcpower_session_tests.cpp b/source/tests/system/nidcpower_session_tests.cpp index 9a44b5f86..2ecf0e593 100644 --- a/source/tests/system/nidcpower_session_tests.cpp +++ b/source/tests/system/nidcpower_session_tests.cpp @@ -101,7 +101,6 @@ TEST_F(NiDCPowerSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDr EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDCPowerSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -113,7 +112,6 @@ TEST_F(NiDCPowerSessionTest, InitializeSessionWithDeviceAndNoSessionName_Creates EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDCPowerSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) diff --git a/source/tests/system/nidigital_session_tests.cpp b/source/tests/system/nidigital_session_tests.cpp index 4db209dbc..72d91a8fb 100644 --- a/source/tests/system/nidigital_session_tests.cpp +++ b/source/tests/system/nidigital_session_tests.cpp @@ -66,7 +66,6 @@ TEST_F(NiDigitalSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDr EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDigitalSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -77,7 +76,6 @@ TEST_F(NiDigitalSessionTest, InitializeSessionWithDeviceAndNoSessionName_Creates EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDigitalSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/nidmm_session_tests.cpp b/source/tests/system/nidmm_session_tests.cpp index 05b780054..1022050c5 100644 --- a/source/tests/system/nidmm_session_tests.cpp +++ b/source/tests/system/nidmm_session_tests.cpp @@ -57,23 +57,6 @@ class NiDmmSessionTest : public ::testing::Test { return status; } - std::string get_error_message(int error_status) - { - dmm::InitWithOptionsResponse init_response; - call_init_with_options(kResourceName, kDmmOptionsString, kSessionName, &init_response); - nidevice_grpc::Session session = init_response.vi(); - - ::grpc::ClientContext context; - dmm::GetErrorMessageRequest error_request; - error_request.mutable_vi()->set_name(session.name()); - error_request.set_error_code(error_status); - dmm::GetErrorMessageResponse error_response; - - ::grpc::Status status = GetStub()->GetErrorMessage(&context, error_request, &error_response); - EXPECT_TRUE(status.ok()); - return error_response.error_message(); - } - private: DeviceServerInterface* device_server_; std::unique_ptr<::nidevice_grpc::Session> driver_session_; @@ -88,7 +71,6 @@ TEST_F(NiDmmSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDriver EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDmmSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -99,7 +81,6 @@ TEST_F(NiDmmSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriv EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiDmmSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/nifgen_session_tests.cpp b/source/tests/system/nifgen_session_tests.cpp index 488dc95e4..9e4707d68 100644 --- a/source/tests/system/nifgen_session_tests.cpp +++ b/source/tests/system/nifgen_session_tests.cpp @@ -82,7 +82,6 @@ TEST_F(NiFgenSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDrive EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiFgenSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -93,7 +92,6 @@ TEST_F(NiFgenSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDri EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiFgenSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/nirfsg_session_tests.cpp b/source/tests/system/nirfsg_session_tests.cpp index ff80345ca..a044c4f21 100644 --- a/source/tests/system/nirfsg_session_tests.cpp +++ b/source/tests/system/nirfsg_session_tests.cpp @@ -72,7 +72,6 @@ TEST_F(NiRFSGSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDrive EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiRFSGSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -83,7 +82,6 @@ TEST_F(NiRFSGSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDri EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiRFSGSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/niscope_session_tests.cpp b/source/tests/system/niscope_session_tests.cpp index 24c8a8049..8de149d3d 100644 --- a/source/tests/system/niscope_session_tests.cpp +++ b/source/tests/system/niscope_session_tests.cpp @@ -78,7 +78,6 @@ TEST_F(NiScopeSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDriv EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiScopeSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -89,7 +88,6 @@ TEST_F(NiScopeSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDr EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiScopeSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/niswitch_session_tests.cpp b/source/tests/system/niswitch_session_tests.cpp index 8deab5ec3..0c5e76cab 100644 --- a/source/tests/system/niswitch_session_tests.cpp +++ b/source/tests/system/niswitch_session_tests.cpp @@ -80,7 +80,6 @@ TEST_F(NiSwitchSessionTest, InitializeSessionWithDeviceAndSessionName_CreatesDri EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiSwitchSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesDriverSession) @@ -91,7 +90,6 @@ TEST_F(NiSwitchSessionTest, InitializeSessionWithDeviceAndNoSessionName_CreatesD EXPECT_TRUE(status.ok()); EXPECT_EQ(0, response.status()); EXPECT_NE("", response.vi().name()); - EXPECT_EQ("", response.error_message()); } TEST_F(NiSwitchSessionTest, InitializedSession_CloseSession_ClosesDriverSession) diff --git a/source/tests/system/nixnetsocket_driver_api_tests.cpp b/source/tests/system/nixnetsocket_driver_api_tests.cpp index 25d592d62..3b5b75f5d 100644 --- a/source/tests/system/nixnetsocket_driver_api_tests.cpp +++ b/source/tests/system/nixnetsocket_driver_api_tests.cpp @@ -219,15 +219,11 @@ class NiXnetSocketNoHardwareTests : public NiXnetSocketDriverApiTests { #define EXPECT_SUCCESS(response) \ if (1) { \ EXPECT_EQ(0, (response).status()); \ - EXPECT_EQ("", (response).error_message()); \ - EXPECT_EQ(0, (response).error_num()); \ } #define EXPECT_SUCCESS_WITH_STATUS(expected_status, response) \ if (1) { \ EXPECT_EQ(expected_status, (response).status()); \ - EXPECT_EQ("", (response).error_message()); \ - EXPECT_EQ(0, (response).error_num()); \ } #define EXPECT_XNET_STATUS(error, response) \ @@ -242,8 +238,6 @@ class NiXnetSocketNoHardwareTests : public NiXnetSocketDriverApiTests { #define EXPECT_XNET_ERROR(expected_status, error, message, response) \ if (1) { \ EXPECT_EQ(expected_status, (response).status()); \ - EXPECT_EQ(error, (response).error_num()); \ - EXPECT_THAT((response).error_message(), HasSubstr(message)); \ } #define EXPECT_INVALID_ARGUMENT_ERROR(response) \ diff --git a/source/tests/unit/ni_fake_non_ivi_service_tests.cpp b/source/tests/unit/ni_fake_non_ivi_service_tests.cpp index b301948ed..b0ccae592 100644 --- a/source/tests/unit/ni_fake_non_ivi_service_tests.cpp +++ b/source/tests/unit/ni_fake_non_ivi_service_tests.cpp @@ -1776,7 +1776,6 @@ TEST_F(NiFakeNonIviServiceTests, InitWithNoError_DoesNotCallGetLatestError) InitResponse response; service_.Init(&context, &request, &response); - EXPECT_THAT(response.error_message(), IsEmpty()); EXPECT_EQ(kDriverSuccess, response.status()); } diff --git a/source/tests/unit/xnet_socket_converters_tests.cpp b/source/tests/unit/xnet_socket_converters_tests.cpp index 8f6048e31..35eadc02b 100644 --- a/source/tests/unit/xnet_socket_converters_tests.cpp +++ b/source/tests/unit/xnet_socket_converters_tests.cpp @@ -616,7 +616,7 @@ TEST(XnetSocketConvertersTests, StringSockOptData_GetSize_FetchesSizeFromLibrary auto storage = allocate_output_storage(&library, OptName::OPT_NAME_SO_BINDTODEVICE); EXPECT_EQ(DEFAULT_SOCK_OPT_STRING_SIZE, storage.string_length); - nxSOCKET SOCKET = NULL; + nxSOCKET SOCKET = nxINVALID_SOCKET; const int LEVEL = 3; nxsocklen_t actual_length; @@ -686,6 +686,8 @@ TEST(XnetSocketConvertersTests, AddrInfoOutputConverter_ConvertToGrpc_ConvertsTo constexpr auto NEXT_ADDR = 1234568; nxsockaddr_in next_addr{nxAF_INET, NEXT_PORT, {NEXT_ADDR}}; nxsockaddr_in addr{nxAF_INET, PORT, {ADDR}}; + std::string nextAddrHostName("NextAddrHostName"); + std::string addrHostName("AddrHostName"); nxaddrinfo addr_info_next{ nxAI_PASSIVE | nxAI_ADDRCONFIG, nxAF_INET, @@ -693,7 +695,7 @@ TEST(XnetSocketConvertersTests, AddrInfoOutputConverter_ConvertToGrpc_ConvertsTo nxIPPROTO_UDP, (nxsocklen_t)sizeof(next_addr), reinterpret_cast(&next_addr), - "NextAddrHostName", + &nextAddrHostName[0], nullptr}; nxaddrinfo addr_info{ nxAI_ALL, @@ -702,7 +704,7 @@ TEST(XnetSocketConvertersTests, AddrInfoOutputConverter_ConvertToGrpc_ConvertsTo nxIPPROTO_TCP, (nxsocklen_t)sizeof(addr), reinterpret_cast(&addr), - "AddrHostName", + &addrHostName[0], &addr_info_next}; NiXnetSocketMockLibrary library; auto converter = allocate_output_storage>(&library); From 5148d0191b67dff7d408d1c21c12c4db5cb0125f Mon Sep 17 00:00:00 2001 From: Michael Strain Date: Fri, 9 Feb 2024 11:38:45 -0500 Subject: [PATCH 2/2] Enable and fix warnings with msvc --- CMakeLists.txt | 16 ++++++++++++++++ source/custom/nifake_service.custom.cpp | 6 ++++++ .../nirfmxinstr_restricted_service.custom.cpp | 10 +++++----- source/custom/nirfmxinstr_service.custom.cpp | 2 +- source/custom/nixnet_service.custom.cpp | 6 +++--- .../ni_fake_service_tests_endtoend.cpp | 5 +++++ .../tests/system/nirfmxspecan_session_tests.cpp | 2 -- .../system/nixnet_ethernet_driver_api_tests.cpp | 2 +- source/tests/unit/ni_fake_service_tests.cpp | 5 +++++ .../nimxlc_terminal_adaptor_converters_tests.cpp | 2 +- source/tests/unit/xnet_converters_tests.cpp | 2 +- 11 files changed, 44 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffd9f0550..7b0ac1514 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -568,10 +568,18 @@ target_link_libraries(IntegrationTestsRunner Threads::Threads nlohmann_json::nlohmann_json) +# Ignore the use of deprecated functions in test code +target_compile_definitions(IntegrationTestsRunner + PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) + add_library(TestApi SHARED "source/tests/utilities/test_api.cpp") add_compile_definitions(TestApi TEST_API_BUILDING) +# Ignore the use of deprecated functions in test code +target_compile_definitions(TestApi + PRIVATE _CRT_SECURE_NO_WARNINGS) + add_executable(UnitTestsRunner "imports/include/nierr_Status.cpp" "source/tests/utilities/run_all_tests.cpp" @@ -646,6 +654,10 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING") endif(MSVC) +# Ignore the use of deprecated functions in test code +target_compile_definitions(UnitTestsRunner + PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) + target_include_directories(UnitTestsRunner PRIVATE "${service_output_dir}" PRIVATE "${service_output_dir}/nifake" @@ -789,6 +801,10 @@ target_link_libraries(SystemTestsRunner nlohmann_json::nlohmann_json ) +# Ignore the use of deprecated functions in test code +target_compile_definitions(SystemTestsRunner + PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) + add_custom_command( TARGET SystemTestsRunner POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory diff --git a/source/custom/nifake_service.custom.cpp b/source/custom/nifake_service.custom.cpp index 4eeaf32e7..f4c86cb21 100644 --- a/source/custom/nifake_service.custom.cpp +++ b/source/custom/nifake_service.custom.cpp @@ -1,4 +1,10 @@ + +#pragma warning(push) +#pragma warning(disable : 4616) +#pragma warning(disable : 4146) +#pragma warning(disable : 4244) #include +#pragma warning(pop) namespace nifake_grpc { diff --git a/source/custom/nirfmxinstr_restricted_service.custom.cpp b/source/custom/nirfmxinstr_restricted_service.custom.cpp index c902329c2..4574cc98b 100644 --- a/source/custom/nirfmxinstr_restricted_service.custom.cpp +++ b/source/custom/nirfmxinstr_restricted_service.custom.cpp @@ -113,17 +113,17 @@ ::grpc::Status NiRFmxInstrRestrictedService::GetInitiaitedSnapshotStrings( convert_to_grpc(signal_names, &signal_names_utf8); response->set_signal_names(signal_names_utf8); nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); - signal_names_actual_size = signal_names_utf8.length() + 1; + signal_names_actual_size = static_cast(signal_names_utf8.length() + 1); std::string result_names_utf8; convert_to_grpc(result_names, &result_names_utf8); response->set_result_names(result_names_utf8); nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - result_names_actual_size = result_names_utf8.length() + 1; + result_names_actual_size = static_cast(result_names_utf8.length() + 1); std::string snapshot_identifiers_utf8; convert_to_grpc(snapshot_identifiers, &snapshot_identifiers_utf8); response->set_snapshot_identifiers(snapshot_identifiers_utf8); nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifiers())); - snapshot_identifiers_actual_size = snapshot_identifiers_utf8.length() + 1; + snapshot_identifiers_actual_size = static_cast(snapshot_identifiers_utf8.length() + 1); response->mutable_snapshot_timestamp_array()->Resize(snapshot_timestamp_array_actual_size, 0); } response->set_status(status); @@ -209,12 +209,12 @@ ::grpc::Status NiRFmxInstrRestrictedService::GetLatestConfigurationSnapshot( convert_to_grpc(signal_name, &signal_name_utf8); response->set_signal_name(signal_name_utf8); nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_name())); - signal_name_actual_size = signal_name_utf8.length() + 1; + signal_name_actual_size = static_cast(signal_name_utf8.length() + 1); std::string snapshot_identifier_utf8; convert_to_grpc(snapshot_identifier, &snapshot_identifier_utf8); response->set_snapshot_identifier(snapshot_identifier_utf8); nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifier())); - snapshot_identifier_actual_size = snapshot_identifier_utf8.length() + 1; + snapshot_identifier_actual_size = static_cast(snapshot_identifier_utf8.length() + 1); } response->set_status(status); response->set_personality_id(personality_id); diff --git a/source/custom/nirfmxinstr_service.custom.cpp b/source/custom/nirfmxinstr_service.custom.cpp index e2d0b9de8..9d3ea4b3f 100644 --- a/source/custom/nirfmxinstr_service.custom.cpp +++ b/source/custom/nirfmxinstr_service.custom.cpp @@ -89,7 +89,7 @@ ::grpc::Status NiRFmxInstrService::BuildPortString(::grpc::ServerContext* contex if (status < 0) { return ConvertApiErrorStatusForNiRFmxInstrHandle(context, status, 0); } - int32 selector_string_out_length = status + std::to_string(channel_number).length(); // AB#1835966: RFmx Instr BuildPortString2 Bug. + int32 selector_string_out_length = static_cast(status + std::to_string(channel_number).length()); // AB#1835966: RFmx Instr BuildPortString2 Bug. std::string selector_string_out; if (selector_string_out_length > 0) { diff --git a/source/custom/nixnet_service.custom.cpp b/source/custom/nixnet_service.custom.cpp index f67b259fa..56812f31d 100644 --- a/source/custom/nixnet_service.custom.cpp +++ b/source/custom/nixnet_service.custom.cpp @@ -880,7 +880,7 @@ ::grpc::Status NiXnetService::SetProperty(::grpc::ServerContext* context, const } case string_: { auto property_value_mbcs = convert_from_grpc(request->str()); - u32 property_size = property_value_mbcs.size(); + u32 property_size = static_cast(property_value_mbcs.size()); status = library_->SetProperty(session, property_id, property_size, const_cast(property_value_mbcs.c_str())); break; } @@ -978,7 +978,7 @@ ::grpc::Status NiXnetService::SetSubProperty(::grpc::ServerContext* context, con } case string_: { auto property_value_mbcs = convert_from_grpc(request->str()); - u32 property_size = property_value_mbcs.size(); + u32 property_size = static_cast(property_value_mbcs.size()); status = library_->SetSubProperty(session, active_index, property_id, property_size, const_cast(property_value_mbcs.c_str())); break; } @@ -1053,7 +1053,7 @@ ::grpc::Status NiXnetService::DbSetProperty(::grpc::ServerContext* context, cons } case string_: { auto property_value_mbcs = convert_from_grpc(request->str()); - u32 property_size = property_value_mbcs.size(); + u32 property_size = static_cast(property_value_mbcs.size()); status = library_->DbSetProperty(dbobject, property_id, property_size, const_cast(property_value_mbcs.c_str())); break; } diff --git a/source/tests/integration/ni_fake_service_tests_endtoend.cpp b/source/tests/integration/ni_fake_service_tests_endtoend.cpp index 087d795f9..49ecb4909 100644 --- a/source/tests/integration/ni_fake_service_tests_endtoend.cpp +++ b/source/tests/integration/ni_fake_service_tests_endtoend.cpp @@ -1,7 +1,12 @@ #include #include #include +#pragma warning(push) +#pragma warning(disable : 4616) +#pragma warning(disable : 4146) +#pragma warning(disable : 4244) #include +#pragma warning(pop) #include #include diff --git a/source/tests/system/nirfmxspecan_session_tests.cpp b/source/tests/system/nirfmxspecan_session_tests.cpp index 6f74a9ac1..8777d6b58 100644 --- a/source/tests/system/nirfmxspecan_session_tests.cpp +++ b/source/tests/system/nirfmxspecan_session_tests.cpp @@ -88,7 +88,6 @@ TEST_F(NiRFmxSpecAnSessionTest, InitializedSession_CloseSession_ClosesDriverSess EXPECT_TRUE(status.ok()); EXPECT_EQ(0, close_response.status()); - EXPECT_THAT(init_response.error_message(), IsEmpty()); } // Note: the error_message is included in the Init response because querying for errors @@ -120,7 +119,6 @@ TEST_F(NiRFmxSpecAnSessionTest, InitWithErrorFromDriver_ReinitSuccessfully_Error EXPECT_EQ(::grpc::StatusCode::OK, status_two.error_code()); EXPECT_THAT(status_two.error_message(), IsEmpty()); - EXPECT_THAT(successful_init_response.error_message(), IsEmpty()); } TEST_F(NiRFmxSpecAnSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError) diff --git a/source/tests/system/nixnet_ethernet_driver_api_tests.cpp b/source/tests/system/nixnet_ethernet_driver_api_tests.cpp index c20af0f78..9337167fd 100644 --- a/source/tests/system/nixnet_ethernet_driver_api_tests.cpp +++ b/source/tests/system/nixnet_ethernet_driver_api_tests.cpp @@ -116,7 +116,7 @@ TEST_F(NiXnetEthernetDriverApiTestsWithHardware, WriteFrameData_ReadFrameData_Va auto frame_out = read_frame_response.buffer()[0]; // The frame that is read will contain mac address of the source on which the test is being run. For comparison purposes, we will be masking it. for (int i = 6; i < 12; i++) { - const_cast(frame_out.mutable_enet()->mutable_frame_data()->data())[i] = 0xFF; + const_cast(frame_out.mutable_enet()->mutable_frame_data()->data())[i] = 0xFFU; } EXPECT_EQ(frame->type(), frame_out.enet().type()); diff --git a/source/tests/unit/ni_fake_service_tests.cpp b/source/tests/unit/ni_fake_service_tests.cpp index 7eed90b53..a4a991d06 100644 --- a/source/tests/unit/ni_fake_service_tests.cpp +++ b/source/tests/unit/ni_fake_service_tests.cpp @@ -1,7 +1,12 @@ #include #include #include +#pragma warning(push) +#pragma warning(disable : 4616) +#pragma warning(disable : 4146) +#pragma warning(disable : 4244) #include +#pragma warning(pop) #include #include #include diff --git a/source/tests/unit/nimxlc_terminal_adaptor_converters_tests.cpp b/source/tests/unit/nimxlc_terminal_adaptor_converters_tests.cpp index 0b876df23..d89237b44 100644 --- a/source/tests/unit/nimxlc_terminal_adaptor_converters_tests.cpp +++ b/source/tests/unit/nimxlc_terminal_adaptor_converters_tests.cpp @@ -31,7 +31,7 @@ class MockServerContext { void initialize_status(nierr_Status *status, int32_t code, std::string description) { status->code = code; - status->reallocJson(status, description.length() + JSONZ_TERMINATOR_SIZE); + status->reallocJson(status, static_cast(description.length() + JSONZ_TERMINATOR_SIZE)); strcpy(status->json, description.c_str()); } diff --git a/source/tests/unit/xnet_converters_tests.cpp b/source/tests/unit/xnet_converters_tests.cpp index 5b1e1ecf1..f38f0cf92 100644 --- a/source/tests/unit/xnet_converters_tests.cpp +++ b/source/tests/unit/xnet_converters_tests.cpp @@ -160,7 +160,7 @@ TEST(XnetConvertersTests, FrameBufferArray_ConvertToGrpc_FrameBufferResponse) } pb::RepeatedPtrField output; - nixnet_grpc::convert_to_grpc(buffer, &output, buffer.size(), nixnet_grpc::Protocol::PROTOCOL_LIN, std::map()); + nixnet_grpc::convert_to_grpc(buffer, &output, static_cast(buffer.size()), nixnet_grpc::Protocol::PROTOCOL_LIN, std::map()); pFrame = (nxFrameVar_t*)buffer.data(); assert_frames_are_equal(pFrame, output[0].lin());