Skip to content

Commit f4cda32

Browse files
pillo79soburi
authored andcommitted
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 9d52cbf commit f4cda32

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

cores/arduino/USB.cpp

Lines changed: 2 additions & 0 deletions
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();

cores/arduino/abi.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66

77
#include <stdlib.h>
88

9-
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
10-
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
9+
extern "C" void __cxa_pure_virtual(void) {}
10+
extern "C" void __cxa_deleted_virtual(void) {}
11+
extern "C" int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle) {
12+
(void)func; (void)arg; (void)dso_handle; // unused
13+
return 0;
14+
}
1115

1216
namespace std {
1317
[[gnu::weak, noreturn]] void terminate() {

cores/arduino/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ static void __libc_init_array (void)
6868
__init_array_start[i] ();
6969
}
7070

71-
extern "C" __attribute__((section(".entry_point"), used)) void entry_point(k_thread_stack_t* stack, size_t stack_size) {
71+
extern "C" __attribute__((section(".entry_point"), used)) void entry_point(struct k_heap* stack, size_t stack_size) {
72+
(void)stack; (void)stack_size; // unused
73+
7274
// copy .data in the right place
7375
// .bss should already be in the right place
7476
// call constructors
@@ -84,11 +86,9 @@ extern "C" __attribute__((section(".entry_point"), used)) void entry_point(k_thr
8486

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

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

9393
memcpy(&_sdata, &_sidata, (&_edata - &_sdata) * sizeof(uint32_t));
9494
memset(&_sbss, 0, &_ebss - &_sbss);

cores/arduino/new.cpp

Lines changed: 10 additions & 0 deletions
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

cores/arduino/zephyrCommon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,24 @@ inline int global_gpio_pin_configure(pin_size_t pinNumber, int flags) {
6868
return gpio_pin_configure(local_gpio_port(pinNumber), local_gpio_pin(pinNumber), flags);
6969
}
7070

71-
template <class N, class Head> constexpr const N sum_of_list(const N sum, const Head &head)
71+
template <class N, class Head> constexpr N sum_of_list(const N sum, const Head &head)
7272
{
7373
return sum + head;
7474
}
7575

7676
template <class N, class Head, class... Tail>
77-
constexpr const N sum_of_list(const N sum, const Head &head, const Tail &...tail)
77+
constexpr N sum_of_list(const N sum, const Head &head, const Tail &...tail)
7878
{
7979
return sum_of_list(sum + head, tail...);
8080
}
8181

82-
template <class N, class Head> constexpr const N max_in_list(const N max, const Head &head)
82+
template <class N, class Head> constexpr N max_in_list(const N max, const Head &head)
8383
{
8484
return (max >= head) ? max : head;
8585
}
8686

8787
template <class N, class Head, class... Tail>
88-
constexpr const N max_in_list(const N max, const Head &head, const Tail &...tail)
88+
constexpr N max_in_list(const N max, const Head &head, const Tail &...tail)
8989
{
9090
return max_in_list((max >= head) ? max : head, tail...);
9191
}

cores/arduino/zephyrSerial.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void arduino::ZephyrSerial::IrqHandler()
111111

112112
void arduino::ZephyrSerial::IrqDispatch(const struct device *dev, void *data)
113113
{
114+
(void)dev; // unused
114115
reinterpret_cast<ZephyrSerial *>(data)->IrqHandler();
115116
}
116117

@@ -149,7 +150,7 @@ int arduino::ZephyrSerial::read()
149150

150151
size_t arduino::ZephyrSerial::write(const uint8_t *buffer, size_t size)
151152
{
152-
int ret;
153+
size_t idx = 0;
153154

154155
k_sem_take(&tx.sem, K_FOREVER);
155156
ret = ring_buf_put(&tx.ringbuf, buffer, size);

0 commit comments

Comments
 (0)