1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Cleanup / refactor fd_printf and similar functions

This commit is contained in:
Nick Patavalis
2017-12-21 12:56:26 +02:00
parent aa58944f34
commit 637f7b375e
3 changed files with 21 additions and 20 deletions

View File

@ -562,22 +562,15 @@ cleanup (int drain, int noreset)
void
fatal (const char *format, ...)
{
char *s, buf[256];
va_list args;
int len;
fd_printf(STE, "\r\nFATAL: ");
va_start(args, format);
len = vsnprintf(buf, sizeof(buf), format, args);
buf[sizeof(buf) - 1] = '\0';
fd_vprintf(STE, format, args);
va_end(args);
fd_printf(STE, "\r\n");
s = "\r\nFATAL: ";
writen_ni(STE, s, strlen(s));
writen_ni(STE, buf, len);
s = "\r\n";
writen_ni(STE, s, strlen(s));
cleanup(0 /* drain */, opts.noreset);
cleanup(0 /* drain */, opts.noreset, opts.hangup);
exit(EXIT_FAILURE);
}