fix various warnings
This commit is contained in:
6 files changed
+51
-45
No files matched your search
@@ -266,12 +266,16 @@ bool HardwarePWM::takeOwnership(uint32_t token)
|
||||
bool const thread_mode = !isInISR();
|
||||
|
||||
if (token == 0) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "zero is not a valid ownership token (attempted use in takeOwnership)");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "zero is not a valid ownership token (attempted use in takeOwnership)");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (token == this->_owner_token) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "failing to acquire ownership because already owned by requesting token (cannot take ownership twice)");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "failing to acquire ownership because already owned by requesting token (cannot take ownership twice)");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -290,22 +294,30 @@ bool HardwarePWM::releaseOwnership(uint32_t token)
|
||||
bool const thread_mode = !isInISR();
|
||||
|
||||
if (token == 0) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "zero is not a valid ownership token (attempted use in releaseOwnership)");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "zero is not a valid ownership token (attempted use in releaseOwnership)");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->isOwner(token)) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "attempt to release ownership when not the current owner");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "attempt to release ownership when not the current owner");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->usedChannelCount() != 0) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "attempt to release ownership when at least on channel is still connected");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "attempt to release ownership when at least on channel is still connected");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->enabled()) {
|
||||
if (thread_mode) LOG_LV1("HwPWM", "attempt to release ownership when PWM peripheral is still enabled");
|
||||
if (thread_mode) {
|
||||
LOG_LV1("HwPWM", "attempt to release ownership when PWM peripheral is still enabled");
|
||||
}
|
||||
return false; // if it's enabled, do not allow ownership to be released, even with no pins in use
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -109,14 +109,14 @@ constexpr static uint64_t _calculate_pulse_count(uint32_t frequency, uint32_t du
|
||||
(((uint64_t)duration) * frequency / 1000ULL);
|
||||
};
|
||||
|
||||
static int _bits_used(unsigned long x) {
|
||||
if (0 == x) return 0;
|
||||
unsigned int result = 0;
|
||||
do {
|
||||
result++;
|
||||
} while (x >>= 1);
|
||||
return result;
|
||||
}
|
||||
//static int _bits_used(unsigned long x) {
|
||||
// if (0 == x) return 0;
|
||||
// unsigned int result = 0;
|
||||
// do {
|
||||
// result++;
|
||||
// } while (x >>= 1);
|
||||
// return result;
|
||||
//}
|
||||
|
||||
static int _bits_used(unsigned long long x) {
|
||||
if (0 == x) return 0;
|
||||
|
||||
+16
-7
@@ -693,13 +693,22 @@ void String::remove(unsigned int index){
|
||||
}
|
||||
|
||||
void String::remove(unsigned int index, unsigned int count){
|
||||
if (index >= len) { return; }
|
||||
if (count <= 0) { return; }
|
||||
if (count > len - index) { count = len - index; }
|
||||
char *writeTo = buffer + index;
|
||||
len = len - count;
|
||||
strncpy(writeTo, buffer + index + count,len - index);
|
||||
buffer[len] = 0;
|
||||
// removes characters from the middle of a string.
|
||||
if (count <= 0) { return; } // exit if nothing to remove
|
||||
if (index >= len) { return; } // ensure start is within string length; thus, ensures (len-index >= 1)
|
||||
if (count > len - index) { // ensure characters to remove is no larger than total length remaining
|
||||
count = len - index;
|
||||
}
|
||||
char *writeTo = buffer + index;
|
||||
char *copyFrom = buffer + index + count;
|
||||
len = len - count;
|
||||
|
||||
// strncpy() cannot be used with overlapping buffers, so copy one char at a time
|
||||
unsigned int charactersToMove = len - index; // yes, uses post-adjusted length
|
||||
for (unsigned int i = 0; i < charactersToMove; i++, writeTo++, copyFrom++) {
|
||||
*writeTo = *copyFrom;
|
||||
}
|
||||
buffer[len] = 0;
|
||||
}
|
||||
|
||||
void String::toLowerCase(void)
|
||||
|
||||
@@ -288,7 +288,9 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
|
||||
|
||||
file.close();
|
||||
|
||||
if ( !loaded ) LOG_LV1("BOND", "CCCD setting not found");
|
||||
if ( !loaded ) {
|
||||
LOG_LV1("BOND", "CCCD setting not found");
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ void SPIClass::transfer(const void *tx_buf, void *rx_buf, size_t count)
|
||||
while (count)
|
||||
{
|
||||
// each transfer can only up to 64KB (16-bit) bytes
|
||||
const size_t xfer_len = min(count, UINT16_MAX);
|
||||
const size_t xfer_len = min((uint16_t) count, UINT16_MAX);
|
||||
|
||||
nrfx_spim_xfer_desc_t xfer_desc =
|
||||
{
|
||||
|
||||
+5
-22
@@ -7,10 +7,9 @@ import time
|
||||
|
||||
SUCCEEDED = "\033[32msucceeded\033[0m"
|
||||
FAILED = "\033[31mfailed\033[0m"
|
||||
SKIPPED = "\033[33mskipped\033[0m"
|
||||
WARNING = "\033[31mwarnings\033[0m"
|
||||
SKIPPED = "\033[36mskipped\033[0m"
|
||||
WARNING = "\033[33mwarnings\033[0m "
|
||||
|
||||
all_warnings = False
|
||||
exit_status = 0
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
@@ -31,15 +30,6 @@ else:
|
||||
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
|
||||
all_examples.sort()
|
||||
|
||||
def errorOutputFilter(line):
|
||||
if len(line) == 0:
|
||||
return False
|
||||
if line.isspace(): # Note: empty string does not match here!
|
||||
return False
|
||||
# TODO: additional items to remove?
|
||||
return True
|
||||
|
||||
|
||||
def build_examples(variant):
|
||||
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
|
||||
|
||||
@@ -67,19 +57,12 @@ def build_examples(variant):
|
||||
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
|
||||
success = SKIPPED
|
||||
else:
|
||||
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
|
||||
# preferably, would use Python logging handler to get both distinct outputs and one merged output
|
||||
# for now, split STDERR when building with all warnings enabled, so can detect warning/error output.
|
||||
if all_warnings:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
|
||||
else:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
|
||||
|
||||
# get stderr into a form where len(warningLines) indicates a true warning was output to stderr
|
||||
warningLines = [];
|
||||
if all_warnings and build_result.stderr:
|
||||
tmpWarningLines = build_result.stderr.decode("utf-8").splitlines()
|
||||
warningLines = list(filter(errorOutputFilter, (tmpWarningLines)))
|
||||
if build_result.stderr:
|
||||
warningLines = build_result.stderr.decode("utf-8").splitlines()
|
||||
|
||||
if build_result.returncode != 0:
|
||||
exit_status = build_result.returncode
|
||||
|
||||
Reference in new issue
Block a user