Skip to content

Commit fd40287

Browse files
authored
Merge pull request arduino#207 from henrygab/fix_compile_warnings3
Improve build script & fix more warnings
2 parents ea9f1a5 + 66b0a74 commit fd40287

File tree

20 files changed

+256
-168
lines changed

20 files changed

+256
-168
lines changed

.github/workflows/githubci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ jobs:
4949
arduino-cli core update-index --additional-urls $BSP_URL
5050
arduino-cli core install arduino:samd --additional-urls $BSP_URL
5151
arduino-cli core install adafruit:samd --additional-urls $BSP_URL
52-
# Repalce release BSP with our code
52+
# Replace release BSP with our code
5353
BSP_VERSION=`eval ls $HOME/$BSP_PATH`
5454
rm -r $HOME/$BSP_PATH/*
5555
ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION
5656
arduino-cli lib install $LIB_DEPS
5757
5858
- name: Build examples
5959
run: python3 extras/build_all.py ${{ matrix.arduino-platform }}
60+
61+
# How to mark this as allowed-to-fail?
62+
- name: Build examples (-Wall)
63+
run: python3 extras/build_all.py --all_warnings --warnings_do_not_cause_job_failure

cores/arduino/SERCOM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class SERCOM
248248
uint32_t getFreqRef(void) { return freqRef; };
249249
#else
250250
// The equivalent SAMD21 dummy functions...
251-
void setClockSource(__attribute__((unused)) int8_t idx, __attribute__((unused)) SercomClockSource src, __attribute__((unused)) bool core) { };
251+
void setClockSource(int8_t idx, SercomClockSource src, bool core) { (void)idx; (void)src; (void)core; };
252252
SercomClockSource getClockSource(void) { return SERCOM_CLOCK_SOURCE_FCPU; };
253253
uint32_t getFreqRef(void) { return F_CPU; };
254254
#endif

cores/arduino/WInterrupts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ void detachInterrupt(uint32_t pin)
250250
* External Interrupt Controller NVIC Interrupt Handler
251251
*/
252252
#if defined(__SAMD51__)
253-
void InterruptHandler(uint32_t i)
253+
void InterruptHandler(uint32_t unused_i)
254254
{
255+
(void)unused_i;
255256
// Calling the routine directly from -here- takes about 1us
256257
// Depending on where you are in the list it will take longer
257258

cores/arduino/math_helper.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,18 @@ uint32_t arm_compare_fixed_q15(q15_t *pIn, q15_t * pOut, uint32_t numSamples)
165165
{
166166
uint32_t i;
167167
int32_t diff;
168-
uint32_t diffCrnt;
168+
uint32_t diffCrnt = 0;
169169
uint32_t maxDiff = 0;
170170

171171
for (i = 0; i < numSamples; i++)
172172
{
173-
diff = pIn[i] - pOut[i];
174-
diffCrnt = (diff > 0) ? diff : -diff;
173+
diff = pIn[i] - pOut[i];
174+
diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff );
175175

176-
if(diffCrnt > maxDiff)
177-
{
178-
maxDiff = diffCrnt;
179-
}
176+
if(diffCrnt > maxDiff)
177+
{
178+
maxDiff = diffCrnt;
179+
}
180180
}
181181

182182
return(maxDiff);
@@ -194,18 +194,18 @@ uint32_t arm_compare_fixed_q31(q31_t *pIn, q31_t * pOut, uint32_t numSamples)
194194
{
195195
uint32_t i;
196196
int32_t diff;
197-
uint32_t diffCrnt;
197+
uint32_t diffCrnt = 0;
198198
uint32_t maxDiff = 0;
199199

200200
for (i = 0; i < numSamples; i++)
201201
{
202-
diff = pIn[i] - pOut[i];
203-
diffCrnt = (diff > 0) ? diff : -diff;
202+
diff = pIn[i] - pOut[i];
203+
diffCrnt = (uint32_t)( (diff > 0) ? diff : -diff );
204204

205-
if(diffCrnt > maxDiff)
206-
{
207-
maxDiff = diffCrnt;
208-
}
205+
if(diffCrnt > maxDiff)
206+
{
207+
maxDiff = diffCrnt;
208+
}
209209
}
210210

211211
return(maxDiff);

extras/build_all.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,51 @@
33
import sys
44
import subprocess
55
import time
6+
import argparse
7+
8+
FQBN_PREFIX='adafruit:samd:adafruit_'
9+
10+
11+
parser = argparse.ArgumentParser(
12+
description='python wrapper for adafruit arduino CI workflows',
13+
allow_abbrev=False
14+
)
15+
parser.add_argument(
16+
'--all_warnings', '--Wall',
17+
action='store_true',
18+
help='build with all warnings enabled (`--warnings all`)',
19+
)
20+
parser.add_argument(
21+
'--warnings_do_not_cause_job_failure',
22+
action='store_true',
23+
help='failed builds will be listed as failed, but not cause job to exit with an error status',
24+
)
25+
parser.add_argument(
26+
'build_boards',
27+
metavar='board',
28+
nargs='*',
29+
help='list of boards to be built -- Note that the fqbn is created by prepending "{}"'.format(FQBN_PREFIX),
30+
default= [ 'metro_m0', 'metro_m4', 'circuitplayground_m0' ]
31+
)
32+
args = parser.parse_args()
633

7-
all_warnings = False
834
exit_status = 0
935
success_count = 0
1036
fail_count = 0
1137
skip_count = 0
12-
1338
build_format = '| {:22} | {:30} | {:9} '
1439
build_separator = '-' * 80
1540

16-
default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0']
17-
18-
build_boards = []
19-
20-
# build all variants if input not existed
21-
if len(sys.argv) > 1:
22-
build_boards.append(sys.argv[1])
23-
else:
24-
build_boards = default_boards
25-
26-
def errorOutputFilter(line):
41+
def errorOutputFilter(line: str):
2742
if len(line) == 0:
2843
return False
2944
if line.isspace(): # Note: empty string does not match here!
3045
return False
3146
# TODO: additional items to remove?
3247
return True
3348

34-
35-
def build_examples(variant):
36-
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
49+
def build_examples(variant: str):
50+
global args, exit_status, success_count, fail_count, skip_count, build_format, build_separator
3751

3852
print('\n')
3953
print(build_separator)
@@ -42,7 +56,7 @@ def build_examples(variant):
4256
print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time'))
4357
print(build_separator)
4458

45-
fqbn = "adafruit:samd:adafruit_{}".format(variant)
59+
fqbn = "{}{}".format(FQBN_PREFIX, variant)
4660

4761
for sketch in glob.iglob('libraries/**/*.ino', recursive=True):
4862
start_time = time.monotonic()
@@ -58,14 +72,14 @@ def build_examples(variant):
5872
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
5973
# preferably, would use Python logging handler to get both distinct outputs and one merged output
6074
# for now, split STDERR when building with all warnings enabled, so can detect warning/error output.
61-
if all_warnings:
75+
if args.all_warnings:
6276
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6377
else:
6478
build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
6579

6680
# get stderr into a form where len(warningLines) indicates a true warning was output to stderr
6781
warningLines = [];
68-
if all_warnings and build_result.stderr:
82+
if args.all_warnings and build_result.stderr:
6983
tmpWarningLines = build_result.stderr.decode("utf-8").splitlines()
7084
warningLines = list(filter(errorOutputFilter, (tmpWarningLines)))
7185

@@ -74,7 +88,8 @@ def build_examples(variant):
7488
success = "\033[31mfailed\033[0m "
7589
fail_count += 1
7690
elif len(warningLines) != 0:
77-
exit_status = -1
91+
if not args.warnings_do_not_cause_job_failure:
92+
exit_status = -1
7893
success = "\033[31mwarnings\033[0m "
7994
fail_count += 1
8095
else:
@@ -98,7 +113,7 @@ def build_examples(variant):
98113

99114
build_time = time.monotonic()
100115

101-
for board in build_boards:
116+
for board in args.build_boards:
102117
build_examples(board)
103118

104119
print(build_separator)

libraries/Adafruit_ZeroDMA/examples/zerodma_memcpy/zerodma_memcpy.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ volatile bool transfer_is_done = false; // Done yet?
1717

1818
// Callback for end-of-DMA-transfer
1919
void dma_callback(Adafruit_ZeroDMA *dma) {
20+
(void)dma; // avoid compiler warning about unused function parameter
2021
transfer_is_done = true;
2122
}
2223

libraries/Adafruit_ZeroDMA/examples/zerodma_spi1/zerodma_spi1.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ volatile bool transfer_is_done = false; // Done yet?
1919

2020
// Callback for end-of-DMA-transfer
2121
void dma_callback(Adafruit_ZeroDMA *dma) {
22+
(void)dma; // avoid compiler warning about unused parameter
2223
transfer_is_done = true;
2324
}
2425

libraries/Adafruit_ZeroDMA/examples/zerodma_spi2/zerodma_spi2.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ volatile bool transfer_is_done = true; // Done yet?
3333

3434
// Callback for end-of-DMA-transfer
3535
void dma_callback(Adafruit_ZeroDMA *dma) {
36+
(void)dma; // avoid compiler warning about unused parameter
3637
transfer_is_done = true;
3738
}
3839

libraries/SPI/SPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class SPIClass {
149149
#else
150150
// On SAMD21, this compiles to nothing, so user code doesn't need to
151151
// check and conditionally compile lines for different architectures.
152-
void setClockSource(__attribute__((unused)) SercomClockSource clk) { };
152+
void setClockSource(SercomClockSource clk) { (void)clk; };
153153
#endif // end __SAMD51__
154154

155155
private:

libraries/Servo/src/samd/Servo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static inline void resetTC (Tc* TCx)
174174

175175
static void _initISR(Tc *tc, uint8_t channel, uint32_t id, IRQn_Type irqn, uint8_t gcmForTimer, uint8_t intEnableBit)
176176
{
177+
(void)id;
177178
// Select GCLK0 as timer/counter input clock source
178179
#if defined(__SAMD51__)
179180
int idx = gcmForTimer; // see datasheet Table 14-9
@@ -265,6 +266,7 @@ static void initISR(timer16_Sequence_t timer)
265266

266267
static void finISR(timer16_Sequence_t timer)
267268
{
269+
(void)timer;
268270
#if defined (_useTimer1)
269271
// Disable the match channel interrupt request
270272
TC_FOR_TIMER1->COUNT16.INTENCLR.reg = INTENCLR_BIT_FOR_TIMER_1;

0 commit comments

Comments
 (0)