From e5ad813ccf8bae71de6aa344df020178698b57b3 Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Tue, 12 Mar 2024 11:08:16 +0100 Subject: [PATCH] libticalcs: fix the type of some parameters for a number of TI-Z80 & TI-68k low-level commands, to prevent value truncations. Bugs introduced by the refactor in commit 57733d551c73ad31 . Too bad the compiler did not warn about these. [Lionel: added fix for ti73_recv_CTS()] Signed-off-by: Adrien Bertrand Signed-off-by: Lionel Debroux --- libticalcs/trunk/src/cmd68k.h | 10 +++++----- libticalcs/trunk/src/cmdz80.h | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libticalcs/trunk/src/cmd68k.h b/libticalcs/trunk/src/cmd68k.h index 24152962..c42e1ed0 100644 --- a/libticalcs/trunk/src/cmd68k.h +++ b/libticalcs/trunk/src/cmd68k.h @@ -54,16 +54,16 @@ TIEXPORT3 int TICALL ti68k_recv_EOT(CalcHandle *handle); /* TI-89 family, send functions */ -static inline int ti89_send_VAR(CalcHandle* handle, uint8_t varsize, uint8_t vartype, const char* varname) { return ti68k_send_VAR(handle, varsize, vartype, varname, ti68k_handle_to_dbus_mid(handle)); } +static inline int ti89_send_VAR(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char* varname) { return ti68k_send_VAR(handle, varsize, vartype, varname, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_CTS(CalcHandle* handle) { return ti68k_send_CTS(handle, ti68k_handle_to_dbus_mid(handle)); } -static inline int ti89_send_XDP(CalcHandle* handle, uint8_t length, uint8_t* data) { return ti68k_send_XDP(handle, length, data, ti68k_handle_to_dbus_mid(handle)); } +static inline int ti89_send_XDP(CalcHandle* handle, uint32_t length, uint8_t* data) { return ti68k_send_XDP(handle, length, data, ti68k_handle_to_dbus_mid(handle)); } TIEXPORT3 int TICALL ti89_send_SKP(CalcHandle *handle, uint8_t rej_code); static inline int ti89_send_ACK(CalcHandle* handle) { return ti68k_send_ACK(handle, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_ERR(CalcHandle* handle) { return ti68k_send_ERR(handle, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_RDY(CalcHandle* handle) { return ti68k_send_RDY(handle, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_SCR(CalcHandle* handle) { return ti68k_send_SCR(handle, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_CNT(CalcHandle* handle) { return ti68k_send_CNT(handle, ti68k_handle_to_dbus_mid(handle)); } -static inline int ti89_send_KEY(CalcHandle* handle, uint8_t scancode) { return ti68k_send_KEY(handle, scancode, ti68k_handle_to_dbus_mid(handle)); } +static inline int ti89_send_KEY(CalcHandle* handle, uint16_t scancode) { return ti68k_send_KEY(handle, scancode, ti68k_handle_to_dbus_mid(handle)); } static inline int ti89_send_EOT(CalcHandle* handle) { return ti68k_send_EOT(handle, ti68k_handle_to_dbus_mid(handle)); } TIEXPORT3 int TICALL ti89_send_REQ(CalcHandle *handle, uint32_t varsize, uint8_t vartype, const char *varname); TIEXPORT3 int TICALL ti89_send_RTS(CalcHandle *handle, uint32_t varsize, uint8_t vartype, const char *varname); @@ -85,14 +85,14 @@ TIEXPORT3 int TICALL ti89_recv_RTS(CalcHandle *handle, uint32_t * varsize, uint8 /* TI-92, send functions */ static inline int ti92_send_VAR(CalcHandle* handle, uint32_t varsize, uint8_t vartype, const char* varname) { return ti68k_send_VAR(handle, varsize, vartype, varname, DBUS_MID_PC_TI92); } static inline int ti92_send_CTS(CalcHandle* handle) { return ti68k_send_CTS(handle, DBUS_MID_PC_TI92); } -static inline int ti92_send_XDP(CalcHandle* handle, uint8_t length, uint8_t* data) { return ti68k_send_XDP(handle, length, data, DBUS_MID_PC_TI92); } +static inline int ti92_send_XDP(CalcHandle* handle, uint32_t length, uint8_t* data) { return ti68k_send_XDP(handle, length, data, DBUS_MID_PC_TI92); } TIEXPORT3 int TICALL ti92_send_SKP(CalcHandle *handle, uint8_t rej_code); static inline int ti92_send_ACK(CalcHandle* handle) { return ti68k_send_ACK(handle, DBUS_MID_PC_TI92); } static inline int ti92_send_ERR(CalcHandle* handle) { return ti68k_send_ERR(handle, DBUS_MID_PC_TI92); } static inline int ti92_send_RDY(CalcHandle* handle) { return ti68k_send_RDY(handle, DBUS_MID_PC_TI92); } static inline int ti92_send_SCR(CalcHandle* handle) { return ti68k_send_SCR(handle, DBUS_MID_PC_TI92); } static inline int ti92_send_CNT(CalcHandle* handle) { return ti68k_send_CNT(handle, DBUS_MID_PC_TI92); } -static inline int ti92_send_KEY(CalcHandle* handle, uint8_t scancode) { return ti68k_send_KEY(handle, scancode, DBUS_MID_PC_TI92); } +static inline int ti92_send_KEY(CalcHandle* handle, uint16_t scancode) { return ti68k_send_KEY(handle, scancode, DBUS_MID_PC_TI92); } static inline int ti92_send_EOT(CalcHandle* handle) { return ti68k_send_EOT(handle, DBUS_MID_PC_TI92); } TIEXPORT3 int TICALL ti92_send_REQ(CalcHandle *handle, uint32_t varsize, uint8_t vartype, const char *varname); TIEXPORT3 int TICALL ti92_send_RTS(CalcHandle *handle, uint32_t varsize, uint8_t vartype, const char *varname); diff --git a/libticalcs/trunk/src/cmdz80.h b/libticalcs/trunk/src/cmdz80.h index e7ef91b2..fd6cdcb6 100644 --- a/libticalcs/trunk/src/cmdz80.h +++ b/libticalcs/trunk/src/cmdz80.h @@ -77,13 +77,13 @@ static inline int ti80_recv_ACK(CalcHandle* handle, uint16_t* status) { return t TIEXPORT3 int TICALL ti73_send_VAR(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname, uint8_t varattr, uint8_t version); TIEXPORT3 int TICALL ti73_send_VAR2(CalcHandle *handle, uint32_t length, uint8_t type, uint8_t flag, uint16_t offset, uint16_t page); static inline int ti73_send_CTS(CalcHandle* handle) { return tiz80_send_CTS(handle, tiz80_handle_to_dbus_mid_7383p(handle)); } -static inline int ti73_send_XDP(CalcHandle* handle, uint8_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_7383p(handle)); } +static inline int ti73_send_XDP(CalcHandle* handle, uint16_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_7383p(handle)); } static inline int ti73_send_SKP(CalcHandle* handle, uint8_t rej_code) { return tiz80_send_SKP(handle, rej_code, tiz80_handle_to_dbus_mid_7383p(handle)); } static inline int ti73_send_ACK(CalcHandle* handle) { return tiz80_send_ACK(handle, tiz80_handle_to_dbus_mid_7383p(handle)); } static inline int ti73_send_ERR(CalcHandle* handle) { return tiz80_send_ERR(handle, tiz80_handle_to_dbus_mid_7383p(handle)); } TIEXPORT3 int TICALL ti73_send_RDY(CalcHandle *handle); static inline int ti73_send_SCR(CalcHandle* handle) { return tiz80_send_SCR(handle, tiz80_handle_to_dbus_mid_7383p(handle)); } -static inline int ti73_send_KEY(CalcHandle* handle, uint8_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_7383p(handle)); } +static inline int ti73_send_KEY(CalcHandle* handle, uint16_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_7383p(handle)); } static inline int ti73_send_EOT(CalcHandle* handle) { return tiz80_send_EOT(handle, tiz80_handle_to_dbus_mid_7383p(handle)); } TIEXPORT3 int TICALL ti73_send_REQ(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname, uint8_t varattr, uint8_t version); TIEXPORT3 int TICALL ti73_send_REQ2(CalcHandle *handle, uint16_t appsize, uint8_t apptype, const char *appname, uint8_t appattr); @@ -102,7 +102,7 @@ TIEXPORT3 int TICALL ti73_send_SID(CalcHandle *handle, uint8_t * data); /* TI-73 family, receive functions */ TIEXPORT3 int TICALL ti73_recv_VAR(CalcHandle *handle, uint16_t * varsize, uint8_t * vartype, char *varname, uint8_t * varattr, uint8_t * version); TIEXPORT3 int TICALL ti73_recv_VAR2(CalcHandle *handle, uint16_t * length, uint8_t * type, char *name, uint16_t * offset, uint16_t * page); -static inline int ti73_recv_CTS(CalcHandle* handle, uint8_t length) { return tiz80_recv_CTS(handle, length); } +static inline int ti73_recv_CTS(CalcHandle* handle, uint16_t length) { return tiz80_recv_CTS(handle, length); } static inline int ti73_recv_SKP(CalcHandle* handle, uint8_t* rej_code) { return tiz80_recv_SKP(handle, rej_code); } TIEXPORT3 int TICALL ti73_recv_XDP(CalcHandle *handle, uint16_t * length, uint8_t * data); TIEXPORT3 int TICALL ti73_recv_SID(CalcHandle *handle, uint16_t * length, uint8_t * data); @@ -113,12 +113,12 @@ TIEXPORT3 int TICALL ti73_recv_RTS(CalcHandle *handle, uint16_t * varsize, uint8 /* TI-82 & TI-83, send functions */ TIEXPORT3 int TICALL ti82_send_VAR(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname); static inline int ti82_send_CTS(CalcHandle* handle) { return tiz80_send_CTS(handle, tiz80_handle_to_dbus_mid_8283(handle)); } -static inline int ti82_send_XDP(CalcHandle* handle, uint8_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_8283(handle)); } +static inline int ti82_send_XDP(CalcHandle* handle, uint16_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_8283(handle)); } static inline int ti82_send_SKP(CalcHandle* handle, uint8_t rej_code) { return tiz80_send_SKP(handle, rej_code, tiz80_handle_to_dbus_mid_8283(handle)); } static inline int ti82_send_ACK(CalcHandle* handle) { return tiz80_send_ACK(handle, tiz80_handle_to_dbus_mid_8283(handle)); } static inline int ti82_send_ERR(CalcHandle* handle) { return tiz80_send_ERR(handle, tiz80_handle_to_dbus_mid_8283(handle)); } static inline int ti82_send_SCR(CalcHandle* handle) { return tiz80_send_SCR(handle, tiz80_handle_to_dbus_mid_8283(handle)); } -static inline int ti82_send_KEY(CalcHandle* handle, uint8_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_8283(handle)); } +static inline int ti82_send_KEY(CalcHandle* handle, uint16_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_8283(handle)); } static inline int ti82_send_EOT(CalcHandle* handle) { return tiz80_send_EOT(handle, tiz80_handle_to_dbus_mid_8283(handle)); } TIEXPORT3 int TICALL ti82_send_REQ(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname); TIEXPORT3 int TICALL ti82_send_RTS(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname); @@ -136,12 +136,12 @@ TIEXPORT3 int TICALL ti82_recv_RTS(CalcHandle *handle, uint16_t * varsize, uint8 /* TI-85 & TI-86, send functions */ TIEXPORT3 int TICALL ti85_send_VAR(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname); static inline int ti85_send_CTS(CalcHandle* handle) { return tiz80_send_CTS(handle, tiz80_handle_to_dbus_mid_8586(handle)); } -static inline int ti85_send_XDP(CalcHandle* handle, uint8_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_8586(handle)); } +static inline int ti85_send_XDP(CalcHandle* handle, uint16_t length, uint8_t* data) { return tiz80_send_XDP(handle, length, data, tiz80_handle_to_dbus_mid_8586(handle)); } static inline int ti85_send_SKP(CalcHandle* handle, uint8_t rej_code) { return tiz80_send_SKP(handle, rej_code, tiz80_handle_to_dbus_mid_8586(handle)); } static inline int ti85_send_ACK(CalcHandle* handle) { return tiz80_send_ACK(handle, tiz80_handle_to_dbus_mid_8586(handle)); } static inline int ti85_send_ERR(CalcHandle* handle) { return tiz80_send_ERR(handle, tiz80_handle_to_dbus_mid_8586(handle)); } static inline int ti85_send_SCR(CalcHandle* handle) { return tiz80_send_SCR(handle, tiz80_handle_to_dbus_mid_8586(handle)); } -static inline int ti85_send_KEY(CalcHandle* handle, uint8_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_8586(handle)); } +static inline int ti85_send_KEY(CalcHandle* handle, uint16_t scancode) { return tiz80_send_KEY(handle, scancode, tiz80_handle_to_dbus_mid_8586(handle)); } static inline int ti85_send_EOT(CalcHandle* handle) { return tiz80_send_EOT(handle, tiz80_handle_to_dbus_mid_8586(handle)); } TIEXPORT3 int TICALL ti85_send_REQ(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname); TIEXPORT3 int TICALL ti85_send_RTS(CalcHandle *handle, uint16_t varsize, uint8_t vartype, const char *varname);