httpd: Also don't byte_to_html() and itoa_html() to save 1.5kbytes.

Also fixed compiler "warning page_impl.c:47: warning 126: unreachable code".
But I think it was a false-positive.
This commit is contained in:
René van Dorst
2025-09-11 07:32:25 +02:00
parent 18f1fb5f1a
commit 24f588effd
2 changed files with 33 additions and 5 deletions
+32 -4
View File
@@ -27,10 +27,26 @@ extern __xdata uint8_t isRTL8373;
extern __xdata uint8_t sfp_pins_last; extern __xdata uint8_t sfp_pins_last;
extern __xdata uint8_t vlan_names[VLAN_NAMES_SIZE]; extern __xdata uint8_t vlan_names[VLAN_NAMES_SIZE];
inline void byte_to_html(uint8_t a)
/* Convert only the lower nibble to ascii HEX char.
For convenience the upper nibble is masked out.
*/
inline char itohex(uint8_t val) {
// Ignore upper nibble for convenience.
val &= 0x0f;
val -= 10;
// 10 or above
if ((int8_t)val >= 0)
val += ('a' - '0' - 10);
return val + ('0' + 10);
}
// Convert uint8_t to ascii HEX char push on html-buffer.
void charhex_to_html(char c)
{ {
outbuf[slen++] = hex[(a >> 4) & 0xf]; outbuf[slen++] = itohex(c);
outbuf[slen++] = hex[a & 0xf];
} }
@@ -40,7 +56,19 @@ void char_to_html(char c)
} }
inline void itoa_html(uint8_t v) // Convert uint8_t to ascii HEX char.
void byte_to_html(uint8_t val)
{
uint8_t cnt = 2;
do {
val = (val >> 4) | (val << 4);
charhex_to_html(val);
cnt -= 1;
} while(cnt);
}
void itoa_html(uint8_t v)
{ {
uint8_t t = (v / 100) % 10; uint8_t t = (v / 100) % 10;
if (t) if (t)
+1 -1
View File
@@ -26,4 +26,4 @@ Other memory:
---------------- -------- -------- -------- -------- ---------------- -------- -------- -------- --------
PAGED EXT. RAM 0 256 PAGED EXT. RAM 0 256
EXTERNAL RAM 0x0001 0x1b28 6952 16777216 EXTERNAL RAM 0x0001 0x1b28 6952 16777216
ROM/EPROM/FLASH 0x0000 0x1bf4f 45844 16777216 ROM/EPROM/FLASH 0x0000 0x1b967 44332 16777216