httpd: subtract through a pointer of known type

uip_appdata is void *, so p - uip_appdata subtracts pointers of
different types. SDCC accepts it, C does not, and no host compiler will
build the file for a unit test. Cast to the type the byte count is meant
in; the generated firmware code is unchanged.
This commit is contained in:
d00f committed 2026-09-18 02:39:52 +02:00
1 parent 0cc09e4015
commit 10dd330e3c
1 file changed
+3 -3
+3 -3
View File
@@ -559,7 +559,7 @@ static void handle_config_fragment(__xdata uint8_t *p)
__xdata uint16_t frag_len;
uint8_t taken;
frag_len = uip_len - (p - uip_appdata);
frag_len = uip_len - (p - (__xdata uint8_t *)uip_appdata);
if (pre_acc + frag_len >= CONFIG_UPLOAD_BUF) {
print_string("Configuration too large, aborting.\n");
config_upload = 0;
@@ -589,7 +589,7 @@ static void handle_firmware_fragment(__xdata uint8_t *p)
__xdata struct httpd_state * __xdata s = &(uip_conn->appstate);
__xdata uint16_t frag_len, payload_start;
frag_len = uip_len - (p - uip_appdata);
frag_len = uip_len - (p - (__xdata uint8_t *)uip_appdata);
if (pre_acc + frag_len >= CONFIG_UPLOAD_BUF) {
print_string("Firmware upload header too large, aborting.\n");
config_upload = 0;
@@ -684,7 +684,7 @@ static uint8_t post_body_take(__xdata uint8_t *p)
send_bad_request();
return 0;
}
have = uip_len - (p - uip_appdata);
have = uip_len - (p - (__xdata uint8_t *)uip_appdata);
if (have >= content_length) {
p[content_length] = NUL;
return 1;