ソースを参照

Set warnings as errors

Paul-Louis Ageneau 5 年 前
コミット
d1f77ebb10
4 ファイル変更12 行追加3 行削除
  1. 9 0
      CMakeLists.txt
  2. 1 1
      src/peerconnection.cpp
  3. 1 1
      src/rtc.cpp
  4. 1 1
      src/tcptransport.cpp

+ 9 - 0
CMakeLists.txt

@@ -214,6 +214,15 @@ add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)
 install(TARGETS datachannel LIBRARY DESTINATION lib)
 install(FILES ${LIBDATACHANNEL_HEADERS} DESTINATION include/rtc)
 
+# Warnings as errors
+if(MSVC)
+  target_compile_options(datachannel PRIVATE /W4 /WX)
+  target_compile_options(datachannel-static PRIVATE /W4 /WX)
+else()
+  target_compile_options(datachannel PRIVATE -Wall -Wextra -Werror)
+  target_compile_options(datachannel-static PRIVATE -Wall -Wextra -Werror)
+endif()
+
 # Tests
 if(NOT NO_TESTS)
 	add_executable(datachannel-tests ${TESTS_SOURCES})

+ 1 - 1
src/peerconnection.cpp

@@ -248,7 +248,7 @@ void PeerConnection::onMedia(std::function<void(const binary &packet)> callback)
 	mMediaCallback = callback;
 }
 
-void PeerConnection::outgoingMedia(message_ptr message) {
+void PeerConnection::outgoingMedia([[maybe_unused]] message_ptr message) {
 	if (!hasMedia())
 		throw std::runtime_error("PeerConnection has no media support");
 

+ 1 - 1
src/rtc.cpp

@@ -497,7 +497,7 @@ int rtcGetDataChannelReliability(int dc, rtcReliability *reliability) {
 			throw std::invalid_argument("Unexpected null pointer");
 
 		Reliability r = dataChannel->reliability();
-		std::memset(reliability, sizeof(*reliability), 0);
+		std::memset(reliability, 0, sizeof(*reliability));
 		reliability->unordered = r.unordered;
 		if (r.type == Reliability::Type::Timed) {
 			reliability->unreliable = true;

+ 1 - 1
src/tcptransport.cpp

@@ -54,7 +54,7 @@ SelectInterrupter::~SelectInterrupter() {
 #endif
 }
 
-int SelectInterrupter::prepare(fd_set &readfds, fd_set &writefds) {
+int SelectInterrupter::prepare(fd_set &readfds, [[maybe_unused]] fd_set &writefds) {
 	std::lock_guard lock(mMutex);
 #ifdef _WIN32
 	if (mDummySock == INVALID_SOCKET)