Skip to content

Commit

Permalink
Merged PR 3440: CLEANUP: Replaced snprintf with memcpy as the scenari…
Browse files Browse the repository at this point in the history
…o is not using the subst...

CLEANUP: Replaced snprintf with memcpy as the scenario is not using the substituted argument.
CLEANUP: Fixed compilation warnings.
BUG: The examples MetaData.cpp now deletes the correct properties object.
OPTIM: While computing the hash code, make sure to check that the returned item has value before accessing it.
EXAMPLE: Added the tests for CPP examples.
  • Loading branch information
Tung Pham committed Jan 14, 2021
2 parents a668168 + 0824bdc commit 0451c19
Show file tree
Hide file tree
Showing 26 changed files with 495 additions and 164 deletions.
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ FILE(GLOB HASHC_H ${HASH}/*.h)
add_library(fiftyone-hash-c ${HASHC_SRC} ${HASHC_H})
target_link_libraries(fiftyone-hash-c fiftyone-device-detection-c)
if (MSVC)
target_compile_options(fiftyone-hash-c PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
target_compile_options(fiftyone-hash-c PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/WX")
else()
target_compile_options(fiftyone-hash-c PRIVATE ${COMPILE_OPTION_DEBUG})
target_compile_options(fiftyone-hash-c PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
endif()

FILE(GLOB HASHCPP_SRC ${HASH}/*.cpp)
Expand All @@ -57,9 +57,9 @@ target_link_libraries(fiftyone-hash-cxx
fiftyone-hash-c
fiftyone-device-detection-cxx)
if (MSVC)
target_compile_options(fiftyone-hash-cxx PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
target_compile_options(fiftyone-hash-cxx PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/WX")
else()
target_compile_options(fiftyone-hash-cxx PRIVATE ${COMPILE_OPTION_DEBUG})
target_compile_options(fiftyone-hash-cxx PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
endif()

set_target_properties(fiftyone-hash-c fiftyone-hash-cxx
Expand All @@ -71,9 +71,9 @@ file(WRITE null.cpp "")
add_library(fiftyone-device-detection-complete SHARED null.cpp)
target_link_libraries(fiftyone-device-detection-complete fiftyone-hash-cxx)
if (MSVC)
target_compile_options(fiftyone-device-detection-complete PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
target_compile_options(fiftyone-device-detection-complete PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/WX")
else()
target_compile_options(fiftyone-device-detection-complete PRIVATE ${COMPILE_OPTION_DEBUG})
target_compile_options(fiftyone-device-detection-complete PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
endif()

set_target_properties(fiftyone-device-detection-complete PROPERTIES PUBLIC_HEADER "${HASH}/hash.h")
Expand Down Expand Up @@ -128,9 +128,9 @@ foreach (api "Hash")
PROPERTIES FOLDER
"Examples/Device Detection/${api}/${upperlangext}")
if (MSVC)
target_compile_options(${name} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
target_compile_options(${name} PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/WX")
else()
target_compile_options(${name} PRIVATE ${COMPILE_OPTION_DEBUG})
target_compile_options(${name} PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
endif()
endif()
endforeach()
Expand Down Expand Up @@ -160,7 +160,10 @@ endif()

set_target_properties(fiftyone-device-detection-test-base PROPERTIES FOLDER "Tests")

add_executable(HashTests ${HASH_TEST_SRC} ${HASH_TEST_H})
add_executable(HashTests
${HASH_TEST_SRC} ${HASH_TEST_H}
${CMAKE_CURRENT_LIST_DIR}/examples/CPP/Hash/ExampleBase.cpp
${CMAKE_CURRENT_LIST_DIR}/examples/CPP/Hash/ExampleBase.hpp)
target_link_libraries(HashTests
fiftyone-device-detection-test-base
fiftyone-hash-cxx)
Expand Down
32 changes: 16 additions & 16 deletions VisualStudio/DeviceDetection.sln
Original file line number Diff line number Diff line change
Expand Up @@ -621,26 +621,26 @@ Global
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug|x64.Build.0 = Debug|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug|x86.ActiveCfg = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug|x86.Build.0 = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x64.ActiveCfg = Debug|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x64.Build.0 = Debug|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x86.ActiveCfg = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x86.Build.0 = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x64.ActiveCfg = Debug|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x64.Build.0 = Debug|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x86.ActiveCfg = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x86.Build.0 = Debug|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x64.ActiveCfg = Debug-MemoryOnly|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x64.Build.0 = Debug-MemoryOnly|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x86.ActiveCfg = Debug-MemoryOnly|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-MemoryOnly|x86.Build.0 = Debug-MemoryOnly|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x64.ActiveCfg = Debug-Single|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x64.Build.0 = Debug-Single|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x86.ActiveCfg = Debug-Single|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Debug-Single|x86.Build.0 = Debug-Single|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release|x64.ActiveCfg = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release|x64.Build.0 = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release|x86.ActiveCfg = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release|x86.Build.0 = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x64.ActiveCfg = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x64.Build.0 = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x86.ActiveCfg = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x86.Build.0 = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x64.ActiveCfg = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x64.Build.0 = Release|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x86.ActiveCfg = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x86.Build.0 = Release|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x64.ActiveCfg = Release-MemoryOnly|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x64.Build.0 = Release-MemoryOnly|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x86.ActiveCfg = Release-MemoryOnly|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-MemoryOnly|x86.Build.0 = Release-MemoryOnly|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x64.ActiveCfg = Release-Single|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x64.Build.0 = Release-Single|x64
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x86.ActiveCfg = Release-Single|Win32
{1D1FB480-9E69-4C1D-A120-1601B00B2457}.Release-Single|x86.Build.0 = Release-Single|Win32
{22E3BB54-2542-4641-9A07-7EFE0DD64670}.Debug|x64.ActiveCfg = Debug|x64
{22E3BB54-2542-4641-9A07-7EFE0DD64670}.Debug|x64.Build.0 = Debug|x64
{22E3BB54-2542-4641-9A07-7EFE0DD64670}.Debug|x86.ActiveCfg = Debug|Win32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -248,6 +249,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -270,6 +272,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -288,6 +291,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -306,6 +310,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -324,6 +329,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -340,6 +346,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -358,6 +365,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -376,6 +384,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -394,6 +403,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -416,6 +426,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -438,6 +449,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -268,6 +269,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -290,6 +292,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -308,6 +311,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -326,6 +330,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -344,6 +349,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -360,6 +366,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -378,6 +385,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -396,6 +404,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -414,6 +423,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -436,6 +446,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -458,6 +469,7 @@
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>
</PrecompiledHeaderOutputFile>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -266,6 +267,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -286,6 +288,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -306,6 +309,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -327,6 +331,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -350,6 +355,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -373,6 +379,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -396,6 +403,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -417,6 +425,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -436,6 +445,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -456,6 +466,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -478,6 +489,7 @@
<CompileAs>Default</CompileAs>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
Loading

0 comments on commit 0451c19

Please sign in to comment.