fix(serial_test): pass RS-485 ioctl pointer via uintptr_t on 64-bit targets (#28925)

The RS-485 ioctls cast the address of the stack variable rs485 to int,
truncating the pointer on 64-bit targets (aarch64 NuttX, x86_64
Linux/SITL) so the kernel reads/writes the serial_rs485 struct at
whatever 32-bit address remains. Cast through uintptr_t instead.

Fixes #28923

Co-authored-by: rikaken2004 <244897142+rikaken2004@users.noreply.github.com>
Co-authored-by: Julian Oes <julian@oes.ch>
This commit is contained in:
authored and GitHub committed 2026-10-31 03:46:39 +13:00
1 parent 9f29d50f92
commit a3c65d0761
1 file changed
+3 -3
+3 -3
View File
@@ -680,7 +680,7 @@ static void setup_serial_port(int baud, struct g_mod_t *g_mod, struct cli_args_t
tcsetattr(g_mod->_fd, TCSANOW, &newtio);
/* enable/disable rs485 direction control */
if (ioctl(g_mod->_fd, TIOCGRS485, (int) &rs485) < 0) {
if (ioctl(g_mod->_fd, TIOCGRS485, (unsigned long)(uintptr_t) &rs485) < 0) {
if (g_cl->_rs485_delay >= 0) {
/* error could be because hardware is missing rs485 support so only print when actually trying to activate it */
perror("Error getting RS-485 mode");
@@ -691,7 +691,7 @@ static void setup_serial_port(int baud, struct g_mod_t *g_mod, struct cli_args_t
rs485.delay_rts_after_send = g_cl->_rs485_delay;
rs485.delay_rts_before_send = 0;
if (ioctl(g_mod->_fd, TIOCSRS485, (int) &rs485) < 0) {
if (ioctl(g_mod->_fd, TIOCSRS485, (unsigned long)(uintptr_t) &rs485) < 0) {
perror("Error setting RS-485 mode");
}
@@ -700,7 +700,7 @@ static void setup_serial_port(int baud, struct g_mod_t *g_mod, struct cli_args_t
rs485.delay_rts_after_send = 0;
rs485.delay_rts_before_send = 0;
if (ioctl(g_mod->_fd, TIOCSRS485, (int) &rs485) < 0) {
if (ioctl(g_mod->_fd, TIOCSRS485, (unsigned long)(uintptr_t) &rs485) < 0) {
perror("Error setting RS-232 mode");
}
}