From 40ce742d048215ba4d0240885fb5adb11ee855de Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Tue, 1 Sep 2026 23:08:42 +0200 Subject: [PATCH] syslog: take the review notes on the state flag and the header length The enabled flag is a flag, so say bool. The header length no longer needs to live in xdata: it was put there when a local would not link, and there is room for it here. The overview names the row after the JSON key, so the syslog row said "syslog_server_ip" while carrying only an address. It now says "syslog_server" and carries the port with it. --- httpd/page_impl.c | 5 +++-- syslog.c | 6 +----- syslog.h | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 2f945689..e7edb0be 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -221,11 +221,12 @@ void send_basic_info(void) itoa_html(uip_netmask[0] >> 8); char_to_html('.'); itoa_html(uip_netmask[1]); char_to_html('.'); itoa_html(uip_netmask[1] >> 8); - slen += strtox(outbuf + slen, "\",\"syslog_server_ip\":\""); + slen += strtox(outbuf + slen, "\",\"syslog_server\":\""); itoa_html(syslog_state.server_ip[0]); char_to_html('.'); itoa_html(syslog_state.server_ip[1]); char_to_html('.'); itoa_html(syslog_state.server_ip[2]); char_to_html('.'); - itoa_html(syslog_state.server_ip[3]); + itoa_html(syslog_state.server_ip[3]); char_to_html(':'); + itoa_html(syslog_state.server_port); slen += strtox(outbuf + slen, "\",\"mac_address\":\""); byte_to_html(uip_ethaddr.addr[0]); char_to_html(':'); byte_to_html(uip_ethaddr.addr[1]); char_to_html(':'); diff --git a/syslog.c b/syslog.c index 7b3edca7..c552ac58 100644 --- a/syslog.c +++ b/syslog.c @@ -12,11 +12,6 @@ __xdata char logbuf[LOGBUF_SIZE]; __xdata struct syslog_state syslog_state; __xdata uip_ipaddr_t server_ip; -/* Header length, in xdata rather than on the stack: syslog_callback() is - * __banked, so a local here takes a byte of internal RAM nobody can overlay, - * and the two it costs are enough to stop the image from linking. */ -__xdata uint16_t syslog_hdr; - #define state syslog_state void syslog_init(void) __banked @@ -64,6 +59,7 @@ void syslog_stop(void) __banked void syslog_callback(uint16_t lport) __banked { + uint16_t syslog_hdr; if (lport != state.syslog_conn->lport) return; diff --git a/syslog.h b/syslog.h index 47bf968f..ad9c3fe1 100644 --- a/syslog.h +++ b/syslog.h @@ -1,6 +1,7 @@ #ifndef _SYSLOG_H_ #define _SYSLOG_H_ +#include #include #define LOGBUF_SIZE 512 @@ -8,7 +9,7 @@ #define SYSLOG_PORT_DEFAULT 514 struct syslog_state { - uint8_t enabled; + bool enabled; uint8_t line_available; uint16_t writeptr ; uint16_t readptr;