Skip to content

Commit

Permalink
Merge pull request #25 from VeithMetro/development/pedantic-warnings
Browse files Browse the repository at this point in the history
[Warnings] Adding pedantic warnings and treating warnings as errors, fixing warnings
  • Loading branch information
pwielders authored Aug 24, 2023
2 parents 6252e0c + f76382d commit 045b5f2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,30 @@
cmake_minimum_required(VERSION 3.3)
project(Libraries)

find_package(WPEFramework)

if (BUILD_REFERENCE)
add_definitions (-DBUILD_REFERENCE=${BUILD_REFERENCE})
endif()

if(ENABLE_STRICT_COMPILER_SETTINGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Compiling with Clang")
set(CMAKE_STRICT_COMPILER_SETTINGS "-Weverything -Wextra -Wpedantic -Werror")
set(CMAKE_STRICT_CXX_COMPILER_SETTINGS "${CMAKE_STRICT_COMPILER_SETTINGS} -Wnon-virtual-dtor")
elseif(${CMAKE_COMPILER_IS_GNUCXX})
message(STATUS "Compiling with GCC")
set(CMAKE_STRICT_COMPILER_SETTINGS "-Wall -Wextra -Wpedantic -Werror")
set(CMAKE_STRICT_CXX_COMPILER_SETTINGS "${CMAKE_STRICT_COMPILER_SETTINGS} -Wnon-virtual-dtor")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
message(STATUS "Compiling with MS Visual Studio")
set(CMAKE_STRICT_COMPILER_SETTINGS "/W4")
else()
message(STATUS "Compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_STRICT_CXX_COMPILER_SETTINGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_STRICT_COMPILER_SETTINGS}")
endif()

add_subdirectory(Source)

11 changes: 5 additions & 6 deletions Source/bluetooth/BluetoothUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ int BtUtilsHciDevba(int dev_id, bdaddr_t* bdaddr)

int BtUtilsOtherBdaddr(int dd, int dev_id, long arg)
{
PUSH_WARNING(DISABLE_WARNING_MISSING_FIELD_INITIALIZERS)
struct hci_dev_info di = { .dev_id = static_cast<uint16_t>(dev_id) };
POP_WARNING()
struct hci_dev_info di;
di.dev_id = static_cast<uint16_t>(dev_id);

if (ioctl(dd, HCIGETDEVINFO, (void*)&di))
return 0;

Expand All @@ -127,9 +127,8 @@ POP_WARNING()

int BtUtilsSameBdaddr(int dd, int dev_id, long arg)
{
PUSH_WARNING(DISABLE_WARNING_MISSING_FIELD_INITIALIZERS)
struct hci_dev_info di = { .dev_id = static_cast<uint16_t>(dev_id) };
POP_WARNING()
struct hci_dev_info di;
di.dev_id = static_cast<uint16_t>(dev_id);

if (ioctl(dd, HCIGETDEVINFO, (void*)&di))
return 0;
Expand Down
3 changes: 2 additions & 1 deletion Source/bluetooth/HCISocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,9 @@ namespace Bluetooth {
// Create definitions for the HCI commands
// ------------------------------------------------------------------------
struct Command {
PUSH_WARNING(DISABLE_WARNING_PEDANTIC)
using Void = char[0];

POP_WARNING()
typedef CommandType<cmd_opcode_pack(OGF_LINK_CTL, OCF_INQUIRY), inquiry_cp, uint8_t>
Inquiry;

Expand Down
2 changes: 1 addition & 1 deletion Source/bluetooth/audio/AVDTPProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ namespace AVDTP {
}

return (code);
};
}

} // namespace AVDTP

Expand Down
2 changes: 1 addition & 1 deletion Source/bluetooth/audio/SDPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ namespace SDP {
uuid = Bluetooth::UUID((_buffer[_readerOffset] << 24) | (_buffer[_readerOffset + 1] << 16)
| (_buffer[_readerOffset + 2] << 8) | _buffer[_readerOffset + 3]);
} else {
uint8_t buffer[size];
uint8_t* buffer = static_cast<uint8_t*>(ALLOCA(size));
uint8_t i = size;
while (i-- > 0) {
buffer[i] = _buffer[_readerOffset++];
Expand Down
4 changes: 2 additions & 2 deletions Source/bluetooth/audio/codecs/SBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ ENUM_CONVERSION_BEGIN(Bluetooth::A2DP::SBC::preset)
{ Bluetooth::A2DP::SBC::MQ, _TXT("MQ") },
{ Bluetooth::A2DP::SBC::HQ, _TXT("HQ") },
{ Bluetooth::A2DP::SBC::XQ, _TXT("XQ") },
ENUM_CONVERSION_END(Bluetooth::A2DP::SBC::preset);
ENUM_CONVERSION_END(Bluetooth::A2DP::SBC::preset)

ENUM_CONVERSION_BEGIN(Bluetooth::A2DP::SBC::Config::channelmode)
{ Bluetooth::A2DP::SBC::Config::MONO, _TXT("Mono") },
{ Bluetooth::A2DP::SBC::Config::STEREO, _TXT("Stereo") },
{ Bluetooth::A2DP::SBC::Config::JOINT_STEREO, _TXT("JointSstereo") },
{ Bluetooth::A2DP::SBC::Config::DUAL_CHANNEL, _TXT("DualChannel") },
ENUM_CONVERSION_END(Bluetooth::A2DP::SBC::Config::channelmode);
ENUM_CONVERSION_END(Bluetooth::A2DP::SBC::Config::channelmode)

namespace Bluetooth {

Expand Down
4 changes: 3 additions & 1 deletion Source/bluetooth/gatt/GATTSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ bool GATTSocket::Security(const uint8_t level)
}

if (result == true) {
struct bt_security btSecurity = { .level = level, 0 };
struct bt_security btSecurity;
btSecurity.level = level;
btSecurity.key_size = 0;
if (::setsockopt(Handle(), SOL_BLUETOOTH, BT_SECURITY, &btSecurity, sizeof(btSecurity)) != 0) {
TRACE_L1("Failed to set Bluetooth Security level for device [%s], error: %d, try L2CAP Security", RemoteId().c_str(), errno);
if (::setsockopt(Handle(), SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm)) != 0) {
Expand Down

0 comments on commit 045b5f2

Please sign in to comment.