mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[scheduler] Address Copilot feedback: %p type, NameType doc, test docstring
- Strip const for the %p varargs call (the format spec takes void*, not const void*; same representation everywhere but pedantically correct). - Mention SELF_POINTER in the NameType discriminator comment. - Update test docstring to match the actual const void * signatures.
This commit is contained in:
@@ -60,8 +60,9 @@ struct SchedulerNameLog {
|
||||
return buffer;
|
||||
} else { // SELF_POINTER
|
||||
// static_name carries the void* key for SELF_POINTER (pointer-width union slot).
|
||||
// Cast to const void* — %p requires a void* argument.
|
||||
ESPHOME_snprintf_P(buffer, sizeof(buffer), ESPHOME_PSTR("self:%p"), static_cast<const void *>(static_name));
|
||||
// %p is specified as void* (not const void*), so strip const for the varargs call.
|
||||
ESPHOME_snprintf_P(buffer, sizeof(buffer), ESPHOME_PSTR("self:%p"),
|
||||
const_cast<void *>(static_cast<const void *>(static_name)));
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,8 @@ class Scheduler {
|
||||
}
|
||||
|
||||
// Name storage type discriminator for SchedulerItem
|
||||
// Used to distinguish between static strings, hashed strings, numeric IDs, and internal numeric IDs
|
||||
// Used to distinguish between static strings, hashed strings, numeric IDs, internal numeric IDs,
|
||||
// and self-keyed pointers (caller-supplied `void *`, typically `this`).
|
||||
enum class NameType : uint8_t {
|
||||
STATIC_STRING = 0, // const char* pointer to static/flash storage
|
||||
HASHED_STRING = 1, // uint32_t FNV-1a hash of a runtime string
|
||||
|
||||
Reference in New Issue
Block a user