Skip to content

Commit

Permalink
Add various patches to silence build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wdoekes committed May 1, 2022
1 parent b39c48c commit adbb9fb
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
30 changes: 30 additions & 0 deletions patches/fix_ble_deprecated_copy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Author: wdoekes
Date: 2022-05-01
Description: fixes these warnings
[36/62] Building CXX object ym/microbit-dal/source/CMakeFiles/microbit-dal.dir/drivers/MicroBitRadio.cpp.o
In file included from yotta_modules/ble/ble/GattClient.h:22,
from yotta_modules/ble/ble/BLE.h:23,
from yotta_modules/microbit-dal/inc/bluetooth/MicroBitBLEManager.h:42,
from yotta_modules/microbit-dal/source/drivers/MicroBitRadio.cpp:33:
yotta_modules/ble/ble/ServiceDiscovery.h: In member function 'virtual ble_error_t ServiceDiscovery::reset()':
yotta_modules/ble/ble/ServiceDiscovery.h:148:77:
warning: implicitly-declared 'UUID& UUID::operator=(const UUID&)' is deprecated [-Wdeprecated-copy]
148 | matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN);
| ^

--- a/yotta_modules/ble/ble/UUID.h 2022-05-01 15:44:52.354070051 +0200
+++ b/yotta_modules/ble/ble/UUID.h 2022-05-01 15:54:13.659558011 +0200
@@ -218,6 +218,13 @@ public:
return !(*this == other);
}

+ UUID &operator= (const UUID &other) {
+ this->type = other.type;
+ this->shortUUID = other.shortUUID;
+ memcpy(this->baseUUID, other.baseUUID, LENGTH_OF_LONG_UUID);
+ return *this;
+ }
+
private:
UUID_Type_t type; // UUID_TYPE_SHORT or UUID_TYPE_LONG
LongUUIDBytes_t baseUUID; // The long UUID
38 changes: 38 additions & 0 deletions patches/fix_memcpy_keyvaluestore.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Author: wdoekes
Date: 2022-05-01
Description: fix class-memaccess warning
yotta_modules/microbit-dal/source/drivers/MicroBitStorage.cpp:419:60:
warning: 'void* memcpy(void*, const void*, size_t)' copying an object
of non-trivial type 'struct KeyValueStore' from an array of 'uint32_t'
{aka 'long unsigned int'} [-Wclass-memaccess]
419 | memcpy(&store, flashBlockPointer, sizeof(KeyValueStore));
| ^

--- a/yotta_modules/microbit-dal/inc/drivers/MicroBitStorage.h 2022-05-01 16:02:39.585630339 +0200
+++ b/yotta_modules/microbit-dal/inc/drivers/MicroBitStorage.h 2022-05-01 16:05:03.613106703 +0200
@@ -46,11 +46,13 @@ struct KeyValuePair
uint8_t value[MICROBIT_STORAGE_VALUE_SIZE];
};

-struct KeyValueStore
+struct KeyValueStoreData
{
uint32_t magic;
uint32_t size;
+};

+struct KeyValueStore : KeyValueStoreData {
KeyValueStore(uint32_t magic, uint32_t size)
{
this->magic = magic;
--- a/yotta_modules/microbit-dal/source/drivers/MicroBitStorage.cpp 2022-05-01 15:58:54.010468608 +0200
+++ b/yotta_modules/microbit-dal/source/drivers/MicroBitStorage.cpp 2022-05-01 16:11:11.689171619 +0200
@@ -416,7 +416,7 @@ int MicroBitStorage::size()
KeyValueStore store = KeyValueStore();

//read our data!
- memcpy(&store, flashBlockPointer, sizeof(KeyValueStore));
+ memcpy((KeyValueStoreData*)&store, flashBlockPointer, sizeof(KeyValueStoreData));

//if we haven't used flash before, we need to configure it
if(store.magic != MICROBIT_STORAGE_MAGIC)
34 changes: 34 additions & 0 deletions patches/fix_microbitpin_0_oob.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Author: wdoekes
Date: 2022-05-01
Description: fix array-bounds compiler warning
[7/20] Building CXX object ym/microbit-dal/source/CMakeFiles/microbit-dal.dir/bluetooth/MicroBitIOPinService.cpp.o
yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:
In member function 'void MicroBitIOPinService::onDataWritten(const GattWriteCallbackParams*)':
yotta_modules/microbit-dal/source/bluetooth/MicroBitIOPinService.cpp:179:42:
warning: array subscript 0 is above array bounds of 'MicroBitPin [0]' [-Warray-bounds]
179 | io.pin[i].getDigitalValue();
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~

--- ./yotta_modules/microbit-dal/inc/drivers/MicroBitIO.h.orig 2022-05-01 16:20:30.620903580 +0200
+++ ./yotta_modules/microbit-dal/inc/drivers/MicroBitIO.h 2022-05-01 16:28:25.211997533 +0200
@@ -40,8 +40,8 @@ class MicroBitIO
{
public:

- MicroBitPin pin[0];
- MicroBitPin P0;
+ MicroBitPin *const pin;
+ MicroBitPin P0;
MicroBitPin P1;
MicroBitPin P2;
MicroBitPin P3;
--- ./yotta_modules/microbit-dal/source/drivers/MicroBitIO.cpp.orig 2022-05-01 16:29:16.055883263 +0200
+++ ./yotta_modules/microbit-dal/source/drivers/MicroBitIO.cpp 2022-05-01 16:29:37.435834531 +0200
@@ -47,6 +47,7 @@ MicroBitIO::MicroBitIO(int ID_P0, int ID
int ID_P12,int ID_P13,int ID_P14,
int ID_P15,int ID_P16,int ID_P19,
int ID_P20) :
+ pin(&this->P0),
P0 (ID_P0, MICROBIT_PIN_P0, PIN_CAPABILITY_ALL), //P0 is the left most pad (ANALOG/DIGITAL/TOUCH)
P1 (ID_P1, MICROBIT_PIN_P1, PIN_CAPABILITY_ALL), //P1 is the middle pad (ANALOG/DIGITAL/TOUCH)
P2 (ID_P2, MICROBIT_PIN_P2, PIN_CAPABILITY_ALL), //P2 is the right most pad (ANALOG/DIGITAL/TOUCH)
67 changes: 67 additions & 0 deletions patches/fix_misleading_indent.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Author: wdoekes
Date: 2022-05-01
Description: fix apparent indentation errors
Removes these kinds of errors:
warning: this 'if' clause does not guard... [-Wmisleading-indentation]

--- a/yotta_modules/microbit-dal/source/core/MicroBitHeapAllocator.cpp 2022-05-01 15:58:14.158619664 +0200
+++ b/yotta_modules/microbit-dal/source/core/MicroBitHeapAllocator.cpp 2022-05-01 15:58:39.826522248 +0200
@@ -342,7 +342,7 @@ void free(void *mem)
if (*cb == 0 || *cb & MICROBIT_HEAP_BLOCK_FREE)
microbit_panic(MICROBIT_HEAP_ERROR);

- *cb |= MICROBIT_HEAP_BLOCK_FREE;
+ *cb |= MICROBIT_HEAP_BLOCK_FREE;
return;
}
}
--- a/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp 2022-05-01 15:57:15.406844421 +0200
+++ b/yotta_modules/microbit-dal/source/core/MicroBitFiber.cpp 2022-05-01 15:57:55.514690712 +0200
@@ -189,9 +189,9 @@ void scheduler_init(EventModel &_message
if (fiber_scheduler_running())
return;

- // Store a reference to the messageBus provided.
- // This parameter will be NULL if we're being run without a message bus.
- messageBus = &_messageBus;
+ // Store a reference to the messageBus provided.
+ // This parameter will be NULL if we're being run without a message bus.
+ messageBus = &_messageBus;

// Create a new fiber context
currentFiber = getFiberContext();
@@ -205,17 +205,17 @@ void scheduler_init(EventModel &_message
idleFiber->tcb.SP = CORTEX_M0_STACK_BASE - 0x04;
idleFiber->tcb.LR = (uint32_t) &idle_task;

- if (messageBus)
- {
- // Register to receive events in the NOTIFY channel - this is used to implement wait-notify semantics
- messageBus->listen(MICROBIT_ID_NOTIFY, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
- messageBus->listen(MICROBIT_ID_NOTIFY_ONE, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
- }
+ if (messageBus)
+ {
+ // Register to receive events in the NOTIFY channel - this is used to implement wait-notify semantics
+ messageBus->listen(MICROBIT_ID_NOTIFY, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
+ messageBus->listen(MICROBIT_ID_NOTIFY_ONE, MICROBIT_EVT_ANY, scheduler_event, MESSAGE_BUS_LISTENER_IMMEDIATE);
+ }

- // register a period callback to drive the scheduler and any other registered components.
+ // register a period callback to drive the scheduler and any other registered components.
new MicroBitSystemTimerCallback(scheduler_tick);

- fiber_flags |= MICROBIT_SCHEDULER_RUNNING;
+ fiber_flags |= MICROBIT_SCHEDULER_RUNNING;
}

/**
@@ -388,7 +388,7 @@ int fiber_wait_for_event(uint16_t id, ui
if(ret == MICROBIT_OK)
schedule();

- return ret;
+ return ret;
}

/**

0 comments on commit adbb9fb

Please sign in to comment.