Skip to content

Commit 14ff558

Browse files
committed
cores/arduino: warning squash
Silence a number of trivial compiler warnings in the Arduino core: - unused arguments - "constexpr const" - signed/unsigned mismatches Signed-off-by: Luca Burelli <[email protected]>
1 parent b7eb974 commit 14ff558

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

Diff for: cores/arduino/USB.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
const struct device *const usb_dev = DEVICE_DT_GET(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), cdc_acm, 0));
1515

1616
void usb_status_cb(enum usb_dc_status_code cb_status, const uint8_t *param) {
17+
(void)param; // unused
1718
if (cb_status == USB_DC_CONFIGURED) {
1819

1920
}
@@ -34,6 +35,7 @@ void arduino::SerialUSB_::_baudChangeHandler()
3435

3536
static void _baudChangeHandler(const struct device *dev, uint32_t rate)
3637
{
38+
(void)dev; // unused
3739
if (rate == 1200) {
3840
usb_disable();
3941
_on_1200_bps();
@@ -123,4 +125,4 @@ arduino::SerialUSB_::operator bool() {
123125
}
124126

125127
arduino::SerialUSB_ Serial(usb_dev);
126-
#endif
128+
#endif

Diff for: cores/arduino/abi.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern "C" void __cxa_pure_virtual(void) {}
1010
extern "C" void __cxa_deleted_virtual(void) {}
1111
extern "C" int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle) {
12+
(void)func; (void)arg; (void)dso_handle; // unused
1213
return 0;
1314
}
1415

Diff for: cores/arduino/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ static void __libc_init_array (void)
7070
}
7171

7272
extern "C" __attribute__((section(".entry_point"), used)) void entry_point(struct k_heap* stack, size_t stack_size) {
73+
(void)stack; (void)stack_size; // unused
74+
7375
// copy .data in the right place
7476
// .bss should already be in the right place
7577
// call constructors
@@ -85,14 +87,12 @@ extern "C" __attribute__((section(".entry_point"), used)) void entry_point(struc
8587

8688
//__asm volatile ("cpsie i");
8789

88-
const size_t alignment = 4096;
8990
printk("System Heap end: %p\n", &__heap_end);
9091
printk("System Heap start: %p\n", &__heap_start);
9192
printk("Sketch Heap start: %p, size %p\n", &kheap_llext_heap, &kheap_llext_heap_size);
92-
// __heap_start = (__heap_start + (alignment - 1)) & ~(alignment - 1);
9393

9494
memcpy(&_sdata, &_sidata, (&_edata - &_sdata) * sizeof(uint32_t));
9595
memset(&_sbss, 0, &_ebss - &_sbss);
9696
__libc_init_array();
9797
main();
98-
}
98+
}

Diff for: cores/arduino/new.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ void * operator new[](std::size_t size) {
4646

4747
#if __cplusplus >= 201703L
4848
void* operator new(std::size_t count, std::align_val_t al) {
49+
(void)al; // unused
4950
return operator new(count);
5051
}
5152

5253
void* operator new[](std::size_t count, std::align_val_t al) {
54+
(void)al; // unused
5355
return operator new(count);
5456
}
5557

5658
void * operator new(std::size_t size, std::align_val_t al, const std::nothrow_t tag) noexcept {
59+
(void)al; (void)tag; // unused
5760
#if defined(NEW_TERMINATES_ON_FAILURE)
5861
// Cannot call throwing operator new as standard suggests, so call
5962
// new_helper directly then
@@ -64,6 +67,7 @@ void * operator new(std::size_t size, std::align_val_t al, const std::nothrow_t
6467
}
6568

6669
void * operator new[](std::size_t size, std::align_val_t al, const std::nothrow_t& tag) noexcept {
70+
(void)al; (void)tag; // unused
6771
#if defined(NEW_TERMINATES_ON_FAILURE)
6872
// Cannot call throwing operator new[] as standard suggests, so call
6973
// malloc directly then
@@ -75,6 +79,7 @@ void * operator new[](std::size_t size, std::align_val_t al, const std::nothrow_
7579
#endif
7680

7781
void * operator new(std::size_t size, const std::nothrow_t tag) noexcept {
82+
(void)tag; // unused
7883
#if defined(NEW_TERMINATES_ON_FAILURE)
7984
// Cannot call throwing operator new as standard suggests, so call
8085
// new_helper directly then
@@ -84,6 +89,7 @@ void * operator new(std::size_t size, const std::nothrow_t tag) noexcept {
8489
#endif
8590
}
8691
void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept {
92+
(void)tag; // unused
8793
#if defined(NEW_TERMINATES_ON_FAILURE)
8894
// Cannot call throwing operator new[] as standard suggests, so call
8995
// malloc directly then
@@ -111,17 +117,21 @@ void operator delete[](void * ptr) noexcept {
111117

112118
#if __cplusplus >= 201402L
113119
void operator delete(void* ptr, std::size_t size) noexcept {
120+
(void)size; // unused
114121
operator delete(ptr);
115122
}
116123
void operator delete[](void * ptr, std::size_t size) noexcept {
124+
(void)size; // unused
117125
operator delete[](ptr);
118126
}
119127
#endif // __cplusplus >= 201402L
120128

121129
void operator delete(void* ptr, const std::nothrow_t& tag) noexcept {
130+
(void)tag; // unused
122131
operator delete(ptr);
123132
}
124133
void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept {
134+
(void)tag; // unused
125135
operator delete[](ptr);
126136
}
127137

Diff for: cores/arduino/zephyrCommon.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,37 @@ namespace {
1818
* Calculate GPIO ports/pins number statically from devicetree configuration
1919
*/
2020

21-
template <class N, class Head> constexpr const N sum_of_list(const N sum, const Head &head)
21+
template <class N, class Head> constexpr N sum_of_list(const N sum, const Head &head)
2222
{
2323
return sum + head;
2424
}
2525

2626
template <class N, class Head, class... Tail>
27-
constexpr const N sum_of_list(const N sum, const Head &head, const Tail &...tail)
27+
constexpr N sum_of_list(const N sum, const Head &head, const Tail &...tail)
2828
{
2929
return sum_of_list(sum + head, tail...);
3030
}
3131

32-
template <class N, class Head> constexpr const N max_in_list(const N max, const Head &head)
32+
template <class N, class Head> constexpr N max_in_list(const N max, const Head &head)
3333
{
3434
return (max >= head) ? max : head;
3535
}
3636

3737
template <class N, class Head, class... Tail>
38-
constexpr const N max_in_list(const N max, const Head &head, const Tail &...tail)
38+
constexpr N max_in_list(const N max, const Head &head, const Tail &...tail)
3939
{
4040
return max_in_list((max >= head) ? max : head, tail...);
4141
}
4242

4343
template <class Query, class Head>
44-
constexpr const size_t is_first_appearance(const size_t &idx, const size_t &at, const size_t &found,
44+
constexpr size_t is_first_appearance(const size_t &idx, const size_t &at, const size_t &found,
4545
const Query &query, const Head &head)
4646
{
4747
return ((found == ((size_t)-1)) && (query == head) && (idx == at)) ? 1 : 0;
4848
}
4949

5050
template <class Query, class Head, class... Tail>
51-
constexpr const size_t is_first_appearance(const size_t &idx, const size_t &at, const size_t &found,
51+
constexpr size_t is_first_appearance(const size_t &idx, const size_t &at, const size_t &found,
5252
const Query &query, const Head &head,
5353
const Tail &...tail)
5454
{
@@ -119,6 +119,7 @@ void setInterruptHandler(pin_size_t pinNumber, voidFuncPtr func)
119119

120120
void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uint32_t pins)
121121
{
122+
(void)port; // unused
122123
struct gpio_port_callback *pcb = (struct gpio_port_callback *)cb;
123124

124125
for (uint32_t i = 0; i < max_ngpios; i++) {

Diff for: cores/arduino/zephyrSerial.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void arduino::ZephyrSerial::IrqHandler()
116116

117117
void arduino::ZephyrSerial::IrqDispatch(const struct device *dev, void *data)
118118
{
119+
(void)dev; // unused
119120
reinterpret_cast<ZephyrSerial *>(data)->IrqHandler();
120121
}
121122

@@ -165,7 +166,7 @@ int arduino::ZephyrSerial::read()
165166

166167
size_t arduino::ZephyrSerial::write(const uint8_t *buffer, size_t size)
167168
{
168-
int idx = 0;
169+
size_t idx = 0;
169170

170171
while (1) {
171172
k_sem_take(&tx.sem, K_FOREVER);

0 commit comments

Comments
 (0)