tnt has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-e1-hardware/+/36676?usp=email )
Change subject: icE1usb fw: Avoid casting random pointer to struct in set_{rx,tx}_mode
......................................................................
icE1usb fw: Avoid casting random pointer to struct in set_{rx,tx}_mode
There is really no need here, we can use `memcpy` just as well.
Not sure if this was a problem here but newer gcc are annoying
with aliasing rules and such so better safe than sorry.
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: I110ee4c014e8cfe058f7fc357decb7ab99e0be64
---
M firmware/ice40-riscv/icE1usb/usb_e1.c
1 file changed, 19 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/76/36676/1
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c
b/firmware/ice40-riscv/icE1usb/usb_e1.c
index 328ff3f..11c7401 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -345,27 +345,25 @@
static bool
_set_tx_mode_done(struct usb_xfer *xfer)
{
- const struct ice1usb_tx_config *cfg = (const struct ice1usb_tx_config *) xfer->data;
struct usb_ctrl_req *req = xfer->cb_ctx;
int port = _ifnum2port(req->wIndex);
struct usb_e1_state *usb_e1 = _get_state(port);
printf("set_tx_mode[%d] %02x%02x%02x%02x\r\n", port,
xfer->data[0], xfer->data[1], xfer->data[2], xfer->data[3]);
- usb_e1->tx_cfg = *cfg;
- e1_tx_config(port, _tx_config_reg(cfg));
+ memcpy(&usb_e1->tx_cfg, xfer->data, sizeof(struct ice1usb_tx_config));
+ e1_tx_config(port, _tx_config_reg(&usb_e1->tx_cfg));
return true;
}
static bool
_set_rx_mode_done(struct usb_xfer *xfer)
{
- const struct ice1usb_rx_config *cfg = (const struct ice1usb_rx_config *) xfer->data;
struct usb_ctrl_req *req = xfer->cb_ctx;
int port = _ifnum2port(req->wIndex);
struct usb_e1_state *usb_e1 = _get_state(port);
printf("set_rx_mode[%d] %02x\r\n", port, xfer->data[0]);
- usb_e1->rx_cfg = *cfg;
- e1_rx_config(port, _rx_config_reg(cfg));
+ memcpy(&usb_e1->rx_cfg, xfer->data, sizeof(struct ice1usb_rx_config));
+ e1_rx_config(port, _rx_config_reg(&usb_e1->rx_cfg));
return true;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-e1-hardware/+/36676?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-e1-hardware
Gerrit-Branch: master
Gerrit-Change-Id: I110ee4c014e8cfe058f7fc357decb7ab99e0be64
Gerrit-Change-Number: 36676
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-MessageType: newchange