1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

CI - clang-format-18 (#9225)

* Fix shell variable comparison without $CI present

+ '[' = true ']'
./tests/restyle.sh: line 16: [: =: unary operator expected

vs.

+ '[' '' = true ']'

* Update to clang-format-18

new opt to skip overly eager macro formatting
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#skipmacrodefinitionbody

minor changes between 15 and 18 for ide examples

reference arduino-ide format is still stuck with 15, though
https://github.com/arduino/clang-static-binaries/releases

* Pin clang-format in CI recipe not the script itself

* style
This commit is contained in:
Max Prokhorov 2025-01-24 09:40:22 +03:00 committed by GitHub
parent bb79e9076e
commit be3035c853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 40 additions and 63 deletions

View File

@ -27,7 +27,7 @@ jobs:
run: | run: |
sudo apt update sudo apt update
python ./tests/test_restyle.py --quiet python ./tests/test_restyle.py --quiet
bash ./tests/ci/style_check.sh env CLANG_FORMAT="clang-format-18" bash ./tests/ci/style_check.sh
# Validate orthography # Validate orthography

View File

@ -492,8 +492,7 @@ namespace MDNSImplementation
{ {
MDNSServiceInfo(MDNSResponder& p_pM, MDNSResponder::hMDNSServiceQuery p_hS, MDNSServiceInfo(MDNSResponder& p_pM, MDNSResponder::hMDNSServiceQuery p_hS,
uint32_t p_u32A) : uint32_t p_u32A) :
p_pMDNSResponder(p_pM), p_pMDNSResponder(p_pM), p_hServiceQuery(p_hS), p_u32AnswerIndex(p_u32A) {};
p_hServiceQuery(p_hS), p_u32AnswerIndex(p_u32A) {};
struct CompareKey struct CompareKey
{ {
bool operator()(char const* a, char const* b) const bool operator()(char const* a, char const* b) const

View File

@ -55,8 +55,7 @@ namespace MDNSImplementation
MDNSResponder::stcMDNSServiceTxt::stcMDNSServiceTxt(const char* p_pcKey /*= 0*/, MDNSResponder::stcMDNSServiceTxt::stcMDNSServiceTxt(const char* p_pcKey /*= 0*/,
const char* p_pcValue /*= 0*/, const char* p_pcValue /*= 0*/,
bool p_bTemp /*= false*/) : bool p_bTemp /*= false*/) :
m_pNext(0), m_pNext(0), m_pcKey(0), m_pcValue(0), m_bTemp(p_bTemp)
m_pcKey(0), m_pcValue(0), m_bTemp(p_bTemp)
{ {
setKey(p_pcKey); setKey(p_pcKey);
setValue(p_pcValue); setValue(p_pcValue);
@ -67,8 +66,7 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNSServiceTxt::stcMDNSServiceTxt( MDNSResponder::stcMDNSServiceTxt::stcMDNSServiceTxt(
const MDNSResponder::stcMDNSServiceTxt& p_Other) : const MDNSResponder::stcMDNSServiceTxt& p_Other) :
m_pNext(0), m_pNext(0), m_pcKey(0), m_pcValue(0), m_bTemp(false)
m_pcKey(0), m_pcValue(0), m_bTemp(false)
{ {
operator=(p_Other); operator=(p_Other);
} }
@ -614,9 +612,8 @@ namespace MDNSImplementation
bool p_bRA /*= false*/, unsigned char p_ucRCode /*= 0*/, uint16_t p_u16QDCount /*= 0*/, bool p_bRA /*= false*/, unsigned char p_ucRCode /*= 0*/, uint16_t p_u16QDCount /*= 0*/,
uint16_t p_u16ANCount /*= 0*/, uint16_t p_u16NSCount /*= 0*/, uint16_t p_u16ANCount /*= 0*/, uint16_t p_u16NSCount /*= 0*/,
uint16_t p_u16ARCount /*= 0*/) : uint16_t p_u16ARCount /*= 0*/) :
m_u16ID(p_u16ID), m_u16ID(p_u16ID), m_1bQR(p_bQR), m_4bOpcode(p_ucOpcode), m_1bAA(p_bAA), m_1bTC(p_bTC),
m_1bQR(p_bQR), m_4bOpcode(p_ucOpcode), m_1bAA(p_bAA), m_1bTC(p_bTC), m_1bRD(p_bRD), m_1bRD(p_bRD), m_1bRA(p_bRA), m_3bZ(0), m_4bRCode(p_ucRCode), m_u16QDCount(p_u16QDCount),
m_1bRA(p_bRA), m_3bZ(0), m_4bRCode(p_ucRCode), m_u16QDCount(p_u16QDCount),
m_u16ANCount(p_u16ANCount), m_u16NSCount(p_u16NSCount), m_u16ARCount(p_u16ARCount) m_u16ANCount(p_u16ANCount), m_u16NSCount(p_u16NSCount), m_u16ARCount(p_u16ARCount)
{ {
} }
@ -813,8 +810,7 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNS_RRAttributes::stcMDNS_RRAttributes( MDNSResponder::stcMDNS_RRAttributes::stcMDNS_RRAttributes(
uint16_t p_u16Type /*= 0*/, uint16_t p_u16Class /*= 1 DNS_RRCLASS_IN Internet*/) : uint16_t p_u16Type /*= 0*/, uint16_t p_u16Class /*= 1 DNS_RRCLASS_IN Internet*/) :
m_u16Type(p_u16Type), m_u16Type(p_u16Type), m_u16Class(p_u16Class)
m_u16Class(p_u16Class)
{ {
} }
@ -910,8 +906,7 @@ namespace MDNSImplementation
MDNSResponder::stcMDNS_RRAnswer::stcMDNS_RRAnswer( MDNSResponder::stcMDNS_RRAnswer::stcMDNS_RRAnswer(
enuAnswerType p_AnswerType, const MDNSResponder::stcMDNS_RRHeader& p_Header, enuAnswerType p_AnswerType, const MDNSResponder::stcMDNS_RRHeader& p_Header,
uint32_t p_u32TTL) : uint32_t p_u32TTL) :
m_pNext(0), m_pNext(0), m_AnswerType(p_AnswerType), m_Header(p_Header), m_u32TTL(p_u32TTL)
m_AnswerType(p_AnswerType), m_Header(p_Header), m_u32TTL(p_u32TTL)
{ {
// Extract 'cache flush'-bit // Extract 'cache flush'-bit
m_bCacheFlush = (m_Header.m_Attributes.m_u16Class & 0x8000); m_bCacheFlush = (m_Header.m_Attributes.m_u16Class & 0x8000);
@ -955,8 +950,7 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNS_RRAnswerA::stcMDNS_RRAnswerA( MDNSResponder::stcMDNS_RRAnswerA::stcMDNS_RRAnswerA(
const MDNSResponder::stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) : const MDNSResponder::stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) :
stcMDNS_RRAnswer(AnswerType_A, p_Header, p_u32TTL), stcMDNS_RRAnswer(AnswerType_A, p_Header, p_u32TTL), m_IPAddress(0, 0, 0, 0)
m_IPAddress(0, 0, 0, 0)
{ {
} }
@ -1094,8 +1088,8 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNS_RRAnswerSRV::stcMDNS_RRAnswerSRV( MDNSResponder::stcMDNS_RRAnswerSRV::stcMDNS_RRAnswerSRV(
const MDNSResponder::stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) : const MDNSResponder::stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) :
stcMDNS_RRAnswer(AnswerType_SRV, p_Header, p_u32TTL), stcMDNS_RRAnswer(AnswerType_SRV, p_Header, p_u32TTL), m_u16Priority(0), m_u16Weight(0),
m_u16Priority(0), m_u16Weight(0), m_u16Port(0) m_u16Port(0)
{ {
} }
@ -1132,8 +1126,7 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNS_RRAnswerGeneric::stcMDNS_RRAnswerGeneric( MDNSResponder::stcMDNS_RRAnswerGeneric::stcMDNS_RRAnswerGeneric(
const stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) : const stcMDNS_RRHeader& p_Header, uint32_t p_u32TTL) :
stcMDNS_RRAnswer(AnswerType_Generic, p_Header, p_u32TTL), stcMDNS_RRAnswer(AnswerType_Generic, p_Header, p_u32TTL), m_u16RDLength(0), m_pu8RDData(0)
m_u16RDLength(0), m_pu8RDData(0)
{ {
} }
@ -1212,8 +1205,7 @@ namespace MDNSImplementation
MDNSResponder::stcMDNSService::stcMDNSService(const char* p_pcName /*= 0*/, MDNSResponder::stcMDNSService::stcMDNSService(const char* p_pcName /*= 0*/,
const char* p_pcService /*= 0*/, const char* p_pcService /*= 0*/,
const char* p_pcProtocol /*= 0*/) : const char* p_pcProtocol /*= 0*/) :
m_pNext(0), m_pNext(0), m_pcName(0), m_bAutoName(false), m_pcService(0), m_pcProtocol(0), m_u16Port(0),
m_pcName(0), m_bAutoName(false), m_pcService(0), m_pcProtocol(0), m_u16Port(0),
m_u8ReplyMask(0), m_fnTxtCallback(0) m_u8ReplyMask(0), m_fnTxtCallback(0)
{ {
setName(p_pcName); setName(p_pcName);
@ -1538,9 +1530,7 @@ namespace MDNSImplementation
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address::stcIP4Address constructor MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address::stcIP4Address constructor
*/ */
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address::stcIP4Address( MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcIP4Address::stcIP4Address(
IPAddress p_IPAddress, uint32_t p_u32TTL /*= 0*/) : IPAddress p_IPAddress, uint32_t p_u32TTL /*= 0*/) : m_pNext(0), m_IPAddress(p_IPAddress)
m_pNext(0),
m_IPAddress(p_IPAddress)
{ {
m_TTL.set(p_u32TTL); m_TTL.set(p_u32TTL);
} }
@ -2172,9 +2162,8 @@ namespace MDNSImplementation
*/ */
MDNSResponder::stcMDNSSendParameter::stcDomainCacheItem::stcDomainCacheItem( MDNSResponder::stcMDNSSendParameter::stcDomainCacheItem::stcDomainCacheItem(
const void* p_pHostnameOrService, bool p_bAdditionalData, uint32_t p_u16Offset) : const void* p_pHostnameOrService, bool p_bAdditionalData, uint32_t p_u16Offset) :
m_pNext(0), m_pNext(0), m_pHostnameOrService(p_pHostnameOrService),
m_pHostnameOrService(p_pHostnameOrService), m_bAdditionalData(p_bAdditionalData), m_bAdditionalData(p_bAdditionalData), m_u16Offset(p_u16Offset)
m_u16Offset(p_u16Offset)
{ {
} }

View File

@ -21,8 +21,7 @@ void setup() {
// start I2S at 8 kHz with 24-bits per sample // start I2S at 8 kHz with 24-bits per sample
if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 24)) { if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 24)) {
Serial.println("Failed to initialize I2S!"); Serial.println("Failed to initialize I2S!");
while (1) while (1); // do nothing
; // do nothing
} }
} }

View File

@ -26,8 +26,7 @@ void setup() {
// start I2S at the sample rate with 16-bits per sample // start I2S at the sample rate with 16-bits per sample
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) { if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) {
Serial.println("Failed to initialize I2S!"); Serial.println("Failed to initialize I2S!");
while (1) while (1); // do nothing
; // do nothing
} }
} }

View File

@ -55,8 +55,7 @@ void setup() {
if (!SD.begin(PIN_SD_CS)) { if (!SD.begin(PIN_SD_CS)) {
Serial.println("failed!"); Serial.println("failed!");
while (1) while (1); // init fail, die here
; // init fail, die here
} }
Serial.println("SD OK!"); Serial.println("SD OK!");
@ -69,8 +68,7 @@ void loop() {
bmpFile = SD.open(__Gsbmp_files[i]); bmpFile = SD.open(__Gsbmp_files[i]);
if (!bmpFile) { if (!bmpFile) {
Serial.println("didn't find image"); Serial.println("didn't find image");
while (1) while (1);
;
} }
if (!bmpReadHeader(bmpFile)) { if (!bmpReadHeader(bmpFile)) {

View File

@ -99,8 +99,7 @@ void setup() {
if (!SD.begin(PIN_SD_CS)) { if (!SD.begin(PIN_SD_CS)) {
Serial.println("failed!"); Serial.println("failed!");
while (1) while (1); // init fail, die here
; // init fail, die here
} }
Serial.println("SD OK!"); Serial.println("SD OK!");
@ -141,8 +140,7 @@ void loop() {
if (!bmpFile) { if (!bmpFile) {
Serial.println("didn't find image"); Serial.println("didn't find image");
while (1) while (1);
;
} }
if (!bmpReadHeader(bmpFile)) { if (!bmpReadHeader(bmpFile)) {
@ -153,8 +151,7 @@ void loop() {
bmpdraw(bmpFile, 0, 0, 1); bmpdraw(bmpFile, 0, 0, 1);
bmpFile.close(); bmpFile.close();
while (1) while (1);
;
} }
/*********************************************/ /*********************************************/

View File

@ -81,8 +81,7 @@ void setup() {
// bind RX and TX // bind RX and TX
USC0(0) |= (1 << UCLBE); USC0(0) |= (1 << UCLBE);
while (Serial.read() == -1) while (Serial.read() == -1);
;
if (Serial.hasOverrun()) { logger->print("overrun?\n"); } if (Serial.hasOverrun()) { logger->print("overrun?\n"); }
timeout = (start_ms = last_ms = millis()) + TIMEOUT; timeout = (start_ms = last_ms = millis()) + TIMEOUT;

View File

@ -27,3 +27,4 @@ BreakBeforeBraces: Allman
IndentWidth: 4 IndentWidth: 4
IndentCaseLabels: false IndentCaseLabels: false
ReflowComments: false ReflowComments: false
SkipMacroDefinitionBody: true

View File

@ -27,8 +27,7 @@ class TestCase
public: public:
TestCase(TestCase* prev, test_case_func_t func, const char* file, size_t line, const char* name, TestCase(TestCase* prev, test_case_func_t func, const char* file, size_t line, const char* name,
const char* desc) : const char* desc) :
m_func(func), m_func(func), m_file(file), m_line(line), m_name(name), m_desc(desc)
m_file(file), m_line(line), m_name(name), m_desc(desc)
{ {
if (prev) if (prev)
{ {

View File

@ -8,16 +8,13 @@ test -d ${root}/cores/esp8266
test -d ${root}/libraries test -d ${root}/libraries
# allow `env CLANG_FORMAT=clang-format-N`, or some other version # allow `env CLANG_FORMAT=clang-format-N`, or some other version
# default to v15, latest stable version from ubuntu-latest Github Actions image CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15}
cd $root cd $root
python $root/tests/restyle.py format --clang-format=$CLANG_FORMAT preset --include core --include arduino python $root/tests/restyle.py format --clang-format=$CLANG_FORMAT preset --include core --include arduino
if [ $CI = "true" ] ; then if [ "$CI" = "true" ] ; then
echo foo
python $root/tests/restyle.py assert --with-summary --with-errors python $root/tests/restyle.py assert --with-summary --with-errors
else else
echo bar
python $root/tests/restyle.py assert --with-diff python $root/tests/restyle.py assert --with-diff
fi fi