mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-23 00:27:06 +01:00
system: refactor build configurations
Namespace build configurations of modules, make more things into constexpr (not fully finished though) Unify code using ...Count() to parse IDs Avoid using unsigned char aka uint8_t as index, prefer size_t as most code already uses it anyway. Making sure we never accidentally truncate the value or try to read it as 32bit-wide. Also, simplify access to built in containers, since those use the wide type as well. Renames led and button types, more consistent initialization and field access.
This commit is contained in:
@@ -11,6 +11,18 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
|
||||
#include "board.h"
|
||||
#include "ntp.h"
|
||||
|
||||
bool tryParseId(const char* p, TryParseIdFunc limit, size_t& out) {
|
||||
static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<unsigned long>::max(), "");
|
||||
|
||||
char* endp { nullptr };
|
||||
out = strtoul(p, &endp, 10);
|
||||
if ((endp == p) || (*endp != '\0') || (out >= limit())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setDefaultHostname() {
|
||||
if (strlen(HOSTNAME) > 0) {
|
||||
setSetting("hostname", F(HOSTNAME));
|
||||
|
||||
Reference in New Issue
Block a user