Skip to content

Commit 4e477fe

Browse files
authored
Fix comms module compiler warnings (#25)
Minor code cleanup in the comms module to fix compiler warnings triggered by Clang in the latest Android NDK.
1 parent 5a84c96 commit 4e477fe

File tree

6 files changed

+57
-11
lines changed

6 files changed

+57
-11
lines changed

source_common/comms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set(LIB_BINARY lib_layer_comms)
2525

2626
add_library(
2727
${LIB_BINARY} STATIC
28+
comms_message.cpp
2829
comms_module.cpp
2930
comms_receiver.cpp
3031
comms_transmitter.cpp)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* ----------------------------------------------------------------------------
4+
* Copyright (c) 2024 Arm Limited
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to
8+
* deal in the Software without restriction, including without limitation the
9+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
* sell copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22+
* IN THE SOFTWARE.
23+
* ----------------------------------------------------------------------------
24+
*/
25+
26+
/**
27+
* @file
28+
* The declaration of the communication module internal message types.
29+
*/
30+
31+
#include "comms/comms_message.hpp"
32+
33+
namespace Comms
34+
{
35+
36+
Message::Message(
37+
EndpointID _endpointID,
38+
MessageType _messageType,
39+
MessageID _messageID,
40+
std::unique_ptr<MessageData> _transmitData) :
41+
endpointID(_endpointID),
42+
messageType(_messageType),
43+
messageID(_messageID),
44+
transmitData(std::move(_transmitData))
45+
{
46+
47+
}
48+
49+
}

source_common/comms/comms_message.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ class Message: public Task
8383
EndpointID endpointID,
8484
MessageType messageType,
8585
MessageID messageID,
86-
std::unique_ptr<MessageData> transmitData) :
87-
endpointID(endpointID),
88-
messageType(messageType),
89-
messageID(messageID),
90-
transmitData(std::move(transmitData)) { }
86+
std::unique_ptr<MessageData> transmitData);
9187

9288
/**
9389
* @brief The type of the message.

source_common/comms/comms_module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ EndpointID CommsModule::getEndpointID(
186186
return registry[name];
187187
}
188188
// Service not found
189-
catch(std::out_of_range)
189+
catch(std::out_of_range const&)
190190
{
191191
return NO_ENDPOINT;
192192
}

source_common/comms/comms_receiver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ namespace Comms
4242
{
4343
/** See header for documentation. */
4444
Receiver::Receiver(
45-
CommsModule& parent
46-
) : parent(parent)
45+
CommsModule& _parent
46+
) : parent(_parent)
4747
{
4848
int pipe_err = pipe(stopRequestPipe);
4949
if (pipe_err)
@@ -77,7 +77,7 @@ void Receiver::stop()
7777

7878
// Poke the pipe to wake the worker thread if it is blocked on a read
7979
int data = 0xdead;
80-
write(stopRequestPipe[1], &data, sizeof(int));
80+
[[maybe_unused]] int _ = write(stopRequestPipe[1], &data, sizeof(int));
8181

8282
// Join on the worker thread
8383
worker.join();

source_common/comms/comms_transmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace Comms
3939

4040
/** See header for documentation. */
4141
Transmitter::Transmitter(
42-
CommsModule& parent
43-
) : parent(parent)
42+
CommsModule& _parent
43+
) : parent(_parent)
4444
{
4545
// Create and start a worker thread
4646
worker = std::thread(&Transmitter::runTransmitter, this);

0 commit comments

Comments
 (0)