Skip to content

Commit 47b2814

Browse files
committed
adjustments for recent gcc version, formatting improved
1 parent 30b8f65 commit 47b2814

34 files changed

+1535
-1511
lines changed

lib/cpputils_avr/src/serial_port.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ namespace avr {
3535

3636
void SerialPort::begin(const uint32_t baud) const {
3737
/* try u2x mode first */
38-
uint16_t baud_setting = (F_CPU / 4UL / baud - 1UL) / 2UL;
38+
uint16_t baud_setting = static_cast<uint16_t>((F_CPU / 4UL / baud - 1UL) / 2UL);
3939
UCSR0A = BV_8(U2X0);
4040

4141
/* the baud_setting cannot be > 4095, so switch back to non-u2x mode if the baud rate is too low */
4242
if (baud_setting > 4095U) {
4343
UCSR0A = 0;
44-
baud_setting = (F_CPU / 8UL / baud - 1UL) / 2UL;
44+
baud_setting = static_cast<uint16_t>((F_CPU / 8UL / baud - 1UL) / 2UL);
4545
}
4646

4747
/* assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register) */
48-
UBRR0H = baud_setting >> 8;
48+
UBRR0H = static_cast<uint8_t>(baud_setting >> 8);
4949
UBRR0L = baud_setting & 0xff;
5050

5151
/* set the data bits, parity, and stop bits */
@@ -62,7 +62,7 @@ void SerialPort::end() {
6262

6363
/* disable UART0 */
6464
uint8_t tmp { UCSR0B };
65-
tmp &= ~(RXEN0 | TXEN0 | RXCIE0 | UDRIE0);
65+
tmp = static_cast<uint8_t>(tmp & ~(RXEN0 | TXEN0 | RXCIE0 | UDRIE0));
6666
UCSR0B = tmp;
6767

6868
/* clear any received data */
@@ -76,8 +76,8 @@ void SerialPort::flush() const {
7676
}
7777

7878
int16_t SerialPort::read() {
79-
ExecuteAtomic<std::is_same<uint8_t, rx_buf_idx_t>::value> x;
80-
const rx_buf_idx_t head { x([this]() { return rx_buf_head_; }) };
79+
ExecuteAtomic<std::is_same<uint8_t, rx_buf_idx_t>::value> x1;
80+
const rx_buf_idx_t head { x1([this]() { return rx_buf_head_; }) };
8181

8282
if (head == rx_buf_tail_) {
8383
// if the head isn't ahead of the tail, we don't have any characters
@@ -86,8 +86,8 @@ int16_t SerialPort::read() {
8686
const uint8_t c { rx_buffer_[rx_buf_tail_] };
8787
const rx_buf_idx_t new_tail { static_cast<rx_buf_idx_t>(static_cast<rx_buf_idx_t>(rx_buf_tail_ + 1U) % sizeof(rx_buffer_)) };
8888

89-
ExecuteAtomic<std::is_same<uint8_t, rx_buf_idx_t>::value> x;
90-
x([this, new_tail]() { rx_buf_tail_ = new_tail; });
89+
ExecuteAtomic<std::is_same<uint8_t, rx_buf_idx_t>::value> x2;
90+
x2([this, new_tail]() { rx_buf_tail_ = new_tail; });
9191

9292
return static_cast<int16_t>(c);
9393
}

lib/cpputils_avr/src/utils_avr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ inline static constexpr uint16_t BV_16(const uint8_t bit) {
122122
template <typename T>
123123
inline static void CBI(volatile T* sfr, const uint8_t bit) {
124124
const T mask { BV<T>(bit) };
125-
*sfr &= ~mask;
125+
*sfr = static_cast<T>(*sfr & ~mask);
126126
}
127127

128128
/**
@@ -135,7 +135,7 @@ template <typename T>
135135
inline static void CBI(intptr_t sfr, const uint8_t bit) {
136136
auto ptr(PTR<T>(sfr));
137137
const T mask { BV<T>(bit) };
138-
*ptr &= ~mask;
138+
*ptr = static_cast<T>(*ptr & ~mask);
139139
}
140140

141141
/**

lib/rc5/rc5.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ bool RC5::read(uint16_t& message, const bool value, const uint32_t elapsed) {
7878

7979
bool RC5::read(bool& toggle, uint8_t& addr, uint8_t& cmd, const bool value, const uint32_t elapsed) {
8080
uint16_t msg;
81-
if (! read(msg, value, elapsed)) {
81+
if (!read(msg, value, elapsed)) {
8282
return false;
8383
}
8484

8585
toggle = (msg & TOGGLE_MASK) >> TOGGLE_SHIFT;
86-
addr = (msg & ADDRESS_MASK) >> ADDRESS_SHIFT;
86+
addr = static_cast<uint8_t>((msg & ADDRESS_MASK) >> ADDRESS_SHIFT);
8787

8888
// Support for extended RC5: to get extended command, invert S2 and shift into command's 7th bit
8989
const uint8_t extended { static_cast<uint8_t>((~msg & S2_MASK) >> (S2_SHIFT - 7)) };
90-
cmd = ((msg & COMMAND_MASK) >> COMMAND_SHIFT) | extended;
90+
cmd = static_cast<uint8_t>(((msg & COMMAND_MASK) >> COMMAND_SHIFT) | extended);
9191

9292
reset();
9393

lib/uclibcpp/src/abi/abi.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/* Copyright (C) 2004 Garrett A. Kajmowicz
22
3-
This file is part of the uClibc C++ Library. This library is free
4-
software; you can redistribute it and/or modify it under the
5-
terms of the GNU General Public License as published by the
6-
Free Software Foundation; either version 2, or (at your option)
7-
any later version.
8-
9-
This library is distributed in the hope that it will be useful,
10-
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
GNU General Public License for more details.
13-
14-
You should have received a copy of the GNU General Public License along
15-
with this library; see the file COPYING. If not, write to the Free
16-
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17-
USA.
3+
This file is part of the uClibc C++ Library. This library is free
4+
software; you can redistribute it and/or modify it under the
5+
terms of the GNU General Public License as published by the
6+
Free Software Foundation; either version 2, or (at your option)
7+
any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License along
15+
with this library; see the file COPYING. If not, write to the Free
16+
Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17+
USA.
1818
*/
1919

2020
#include <cstdlib>
@@ -29,17 +29,18 @@
2929
extern "C" {
3030

3131
#if defined(ARDUINO)
32-
/* Arduino defines some of these.
33-
* There can be link issues if they're redefined
34-
*/
32+
/* Arduino defines some of these.
33+
* There can be link issues if they're redefined
34+
*/
3535
#else
36-
/* This function is called in the event that a non-overidden
37-
* pure virtual function is called. The compiler should never
38-
* let that happen. We get to choose what to do - we will abort
39-
*/
40-
void __cxa_pure_virtual (){
41-
abort();
42-
}
36+
void __cxa_pure_virtual();
37+
/* This function is called in the event that a non-overidden
38+
* pure virtual function is called. The compiler should never
39+
* let that happen. We get to choose what to do - we will abort
40+
*/
41+
void __cxa_pure_virtual() {
42+
abort();
43+
}
4344

4445
#endif
4546
}

0 commit comments

Comments
 (0)