Run clang-tidy against Arduino 3 (#2146)

* Add macros header with more usable Arduino version defines

* Change Arduino version checking to use our version defines

* Add missing ESP8266 check

* Rename Arduino version macro to ARDUINO_VERSION_CODE

* Upgrade clang-tidy to use Arduino 3

* Fix clang-tidy warnings

* Upgrade NeoPixelBus to upstream 2.6.7

* Use Arduino-version-appropriate API to set redirect flags

* Remove now unnecessary CLANG_TIDY ifdefs

* Add preprocessor hackery to avoid including pgmspace.h

* Bump base image to 4.1.1 and update lint

* Fix nfctag

* Fix make_unique ambiguous

* Fix ignore name

* Fix ambiguous v2

* Remove unused begin

* Cast time_t to prevent issues on platforms where time_t is 32bit

Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
Oxan van Leeuwen
2021-09-13 18:55:04 +02:00
committed by GitHub
parent ed7983af41
commit 924df1e7de
30 changed files with 98 additions and 66 deletions
+4 -4
View File
@@ -104,7 +104,7 @@ void PN532::loop() {
if (!success) {
// Something failed
if (!this->current_uid_.empty()) {
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
for (auto *trigger : this->triggers_ontagremoved_)
trigger->process(tag);
}
@@ -117,7 +117,7 @@ void PN532::loop() {
if (num_targets != 1) {
// no tags found or too many
if (!this->current_uid_.empty()) {
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
for (auto *trigger : this->triggers_ontagremoved_)
trigger->process(tag);
}
@@ -281,9 +281,9 @@ std::unique_ptr<nfc::NfcTag> PN532::read_tag_(std::vector<uint8_t> &uid) {
return this->read_mifare_ultralight_tag_(uid);
} else if (type == nfc::TAG_TYPE_UNKNOWN) {
ESP_LOGV(TAG, "Cannot determine tag type");
return make_unique<nfc::NfcTag>(uid);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
} else {
return make_unique<nfc::NfcTag>(uid);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
}
}
@@ -15,15 +15,15 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_classic_tag_(std::vector<uint8_t
std::vector<uint8_t> data;
if (this->read_mifare_classic_block_(current_block, data)) {
if (!nfc::decode_mifare_classic_tlv(data, message_length, message_start_index)) {
return make_unique<nfc::NfcTag>(uid, nfc::ERROR);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::ERROR)};
}
} else {
ESP_LOGE(TAG, "Failed to read block %d", current_block);
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC)};
}
} else {
ESP_LOGV(TAG, "Tag is not NDEF formatted");
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC)};
}
uint32_t index = 0;
@@ -51,7 +51,7 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_classic_tag_(std::vector<uint8_t
}
}
buffer.erase(buffer.begin(), buffer.begin() + message_start_index);
return make_unique<nfc::NfcTag>(uid, nfc::MIFARE_CLASSIC, buffer);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::MIFARE_CLASSIC, buffer)};
}
bool PN532::read_mifare_classic_block_(uint8_t block_num, std::vector<uint8_t> &data) {
@@ -9,25 +9,25 @@ static const char *const TAG = "pn532.mifare_ultralight";
std::unique_ptr<nfc::NfcTag> PN532::read_mifare_ultralight_tag_(std::vector<uint8_t> &uid) {
if (!this->is_mifare_ultralight_formatted_()) {
ESP_LOGD(TAG, "Not NDEF formatted");
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
}
uint8_t message_length;
uint8_t message_start_index;
if (!this->find_mifare_ultralight_ndef_(message_length, message_start_index)) {
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
}
ESP_LOGVV(TAG, "message length: %d, start: %d", message_length, message_start_index);
if (message_length == 0) {
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
}
std::vector<uint8_t> data;
for (uint8_t page = nfc::MIFARE_ULTRALIGHT_DATA_START_PAGE; page < nfc::MIFARE_ULTRALIGHT_MAX_PAGE; page++) {
std::vector<uint8_t> page_data;
if (!this->read_mifare_ultralight_page_(page, page_data)) {
ESP_LOGE(TAG, "Error reading page %d", page);
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2)};
}
data.insert(data.end(), page_data.begin(), page_data.end());
@@ -38,7 +38,7 @@ std::unique_ptr<nfc::NfcTag> PN532::read_mifare_ultralight_tag_(std::vector<uint
data.erase(data.begin(), data.begin() + message_start_index);
data.erase(data.begin() + message_length, data.end());
return make_unique<nfc::NfcTag>(uid, nfc::NFC_FORUM_TYPE_2, data);
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid, nfc::NFC_FORUM_TYPE_2, data)};
}
bool PN532::read_mifare_ultralight_page_(uint8_t page_num, std::vector<uint8_t> &data) {