Skip to content

Commit cfb63f1

Browse files
strongly-typedsalkinium
authored andcommitted
[tests] Use reference instead of pointer
The warning modm/src/modm/communication/xpcc/response_callback.hpp:70:13: warning: cast between incompatible pointer to member types from 'void (TestingComponent2::*)(const xpcc::Header&)' to 'xpcc::ResponseCallback::Function' {aka 'void (xpcc::Communicatable::*)(const xpcc::Header&, const unsigned char*)'} [-Wcast-function-type] was already present.
1 parent 80d4110 commit cfb63f1

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

test/modm/communication/xpcc/dispatcher_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ DispatcherTest::setUp()
2626
dispatcher = new xpcc::Dispatcher(backend, postman);
2727
timeline = new Timeline();
2828

29-
component1 = new TestingComponent1(*dispatcher, timeline);
30-
component2 = new TestingComponent2(*dispatcher, timeline);
29+
component1 = new TestingComponent1(*dispatcher, *timeline);
30+
component2 = new TestingComponent2(*dispatcher, *timeline);
3131

3232
postman->component1 = component1;
3333
postman->component2 = component2;

test/modm/communication/xpcc/testing_component_1.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "testing_component_1.hpp"
1515

1616
TestingComponent1::TestingComponent1(xpcc::Dispatcher &communication,
17-
Timeline *timeline) :
17+
Timeline &timeline) :
1818
xpcc::AbstractComponent(1, communication),
1919
timeline(timeline),
2020
isDelayedResponseActive(false)
@@ -34,22 +34,22 @@ TestingComponent1::update()
3434
void
3535
TestingComponent1::actionNoParameter(const xpcc::ResponseHandle& handle)
3636
{
37-
timeline->events.append(
37+
timeline.events.append(
3838
Timeline::Event(Timeline::Type::Action, 1, 0x10, handle.getDestination()));
3939
}
4040

4141
void
4242
TestingComponent1::actionUint16(const xpcc::ResponseHandle& handle,
4343
const uint16_t *parameter)
4444
{
45-
timeline->events.append(
45+
timeline.events.append(
4646
Timeline::Event(Timeline::Type::Action, 1, 0x11, handle.getDestination(), parameter));
4747
}
4848

4949
void
5050
TestingComponent1::actionDirectResponse(const xpcc::ResponseHandle& handle)
5151
{
52-
timeline->events.append(
52+
timeline.events.append(
5353
Timeline::Event(Timeline::Type::Action, 1, 0x12, handle.getDestination()));
5454

5555
this->sendResponse(handle);
@@ -58,7 +58,7 @@ TestingComponent1::actionDirectResponse(const xpcc::ResponseHandle& handle)
5858
void
5959
TestingComponent1::actionDelayedResponse(const xpcc::ResponseHandle& handle)
6060
{
61-
timeline->events.append(
61+
timeline.events.append(
6262
Timeline::Event(Timeline::Type::Action, 1, 0x13, handle.getDestination()));
6363

6464
this->delayedResponseHandle = handle;
@@ -69,7 +69,7 @@ void
6969
TestingComponent1::actionUint16CallAction(const xpcc::ResponseHandle& handle,
7070
const uint16_t *parameter)
7171
{
72-
timeline->events.append(
72+
timeline.events.append(
7373
Timeline::Event(Timeline::Type::Action, 1, 0x14, handle.getDestination(), parameter));
7474

7575
this->callAction(2, 0x11, *parameter);
@@ -79,14 +79,14 @@ TestingComponent1::actionUint16CallAction(const xpcc::ResponseHandle& handle,
7979
void
8080
TestingComponent1::eventNoParameter(const xpcc::Header& header)
8181
{
82-
timeline->events.append(
82+
timeline.events.append(
8383
Timeline::Event(Timeline::Type::Event, 2, 0x20, header.source));
8484
}
8585

8686
void
8787
TestingComponent1::eventUint32(const xpcc::Header& header,
8888
const uint32_t *parameter)
8989
{
90-
timeline->events.append(
90+
timeline.events.append(
9191
Timeline::Event(Timeline::Type::Event, 1, 0x21, header.source, parameter));
9292
}

test/modm/communication/xpcc/testing_component_1.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class TestingComponent1 : public xpcc::AbstractComponent
2424
{
2525
public:
26-
TestingComponent1(xpcc::Dispatcher &communication, Timeline *timeline);
26+
TestingComponent1(xpcc::Dispatcher &communication, Timeline &timeline);
2727

2828
virtual ~TestingComponent1()
2929
{};
@@ -71,7 +71,7 @@ class TestingComponent1 : public xpcc::AbstractComponent
7171
eventUint32(const xpcc::Header& header, const uint32_t *parameter);
7272

7373
private:
74-
Timeline *timeline;
74+
Timeline &timeline;
7575

7676
bool isDelayedResponseActive;
7777
xpcc::ResponseHandle delayedResponseHandle;

test/modm/communication/xpcc/testing_component_2.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "testing_component_2.hpp"
1515

1616
TestingComponent2::TestingComponent2(xpcc::Dispatcher &communication,
17-
Timeline *timeline) :
17+
Timeline &timeline) :
1818
xpcc::AbstractComponent(2, communication),
1919
timeline(timeline)
2020
{
@@ -30,15 +30,15 @@ TestingComponent2::update()
3030
void
3131
TestingComponent2::actionNoParameter(const xpcc::ResponseHandle& handle)
3232
{
33-
timeline->events.append(
33+
timeline.events.append(
3434
Timeline::Event(Timeline::Type::Action, 2, 0x10, handle.getDestination()));
3535
}
3636

3737
void
3838
TestingComponent2::actionUint16(const xpcc::ResponseHandle& handle,
3939
const uint16_t *parameter)
4040
{
41-
timeline->events.append(
41+
timeline.events.append(
4242
Timeline::Event(Timeline::Type::Action, 2, 0x11, handle.getDestination(),
4343
parameter));
4444
}
@@ -47,7 +47,7 @@ TestingComponent2::actionUint16(const xpcc::ResponseHandle& handle,
4747
void
4848
TestingComponent2::eventNoParameter(const xpcc::Header& header)
4949
{
50-
timeline->events.append(
50+
timeline.events.append(
5151
Timeline::Event(Timeline::Type::Event, 2, 0x10, header.source));
5252
}
5353

@@ -56,22 +56,22 @@ TestingComponent2::eventNoParameter(const xpcc::Header& header)
5656
void
5757
TestingComponent2::responseNoParameter(const xpcc::Header& header)
5858
{
59-
timeline->events.append(
59+
timeline.events.append(
6060
Timeline::Event(Timeline::Type::Response, 2, 0x30, header.source));
6161
}
6262

6363
void
6464
TestingComponent2::responseUint16(const xpcc::Header& header,
6565
const uint16_t *parameter)
6666
{
67-
timeline->events.append(
67+
timeline.events.append(
6868
Timeline::Event(Timeline::Type::Response, 2, 0x31, header.source, parameter));
6969
}
7070

7171
void
7272
TestingComponent2::responseCallAction(const xpcc::Header& header)
7373
{
74-
timeline->events.append(
74+
timeline.events.append(
7575
Timeline::Event(Timeline::Type::Response, 2, 0x32, header.source));
7676

7777
xpcc::ResponseCallback callback(this, &TestingComponent2::responseNoParameter);

test/modm/communication/xpcc/testing_component_2.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class TestingComponent2 : public xpcc::AbstractComponent
2424
{
2525
public:
26-
TestingComponent2(xpcc::Dispatcher &communication, Timeline *timeline);
26+
TestingComponent2(xpcc::Dispatcher &communication, Timeline &timeline);
2727

2828
virtual ~TestingComponent2()
2929
{};
@@ -62,7 +62,7 @@ class TestingComponent2 : public xpcc::AbstractComponent
6262
responseCallAction(const xpcc::Header& header);
6363

6464
private:
65-
Timeline *timeline;
65+
Timeline &timeline;
6666
};
6767

6868
#endif

0 commit comments

Comments
 (0)