-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix flashinit panic not printing #8762
Conversation
…nto pr-autoconfig-fix
…nto pr-autoconfig-fix
Just as a thought, don't we want to return something like this? FlashInitResult flashinit(); struct FlashInitResult {
bool ok { false };
const char* err_msg;
}; |
edit: my bad, I was some merged PRs late |
Too many merge conflicts were corrected with web edit, I need to correct some stuff and do a few real tests. |
I just mean the return value. Struct member name tells us what we mean right there, no need to remember triple meaning of a char pointer |
to flashinit from user_init.
FWIF: I tried this method and it increases "IROM code in flash" by 16 bytes. |
Suppose, bool could go, but methods could do the thing instead #include <cstdio>
void __panic_func(const char* file, int line, const char* func) {
printf("panic! at %s:%d::%s\n", file, line, func);
}
struct SimpleResult {
SimpleResult() = default;
constexpr SimpleResult(const char* error) :
_error(error)
{}
bool ok() const {
return _error == nullptr;
}
const char* error() const {
return _error;
}
// or, other order, depends on whats more important to replace
void check(const char* file = __builtin_FILE(),
int line = __builtin_LINE(),
const char* func = __builtin_FUNCTION())
{
if (!ok()) {
__panic_func(file, line, func);
}
}
private:
const char* _error { nullptr };
};
int main() {
SimpleResult what{"oops"};
what.check();
} |
Resolves