synapticsmst: Fix alignment issues (Closes: #207)

This commit is contained in:
Mario Limonciello 2018-08-10 23:18:42 -05:00 committed by Richard Hughes
parent 128c0160b3
commit d4e443e8e2
4 changed files with 69 additions and 77 deletions

View File

@ -19,10 +19,6 @@ shared_module('fu_plugin_synapticsmst',
dependencies : [ dependencies : [
plugin_deps, plugin_deps,
], ],
# https://github.com/hughsie/fwupd/issues/207
override_options : [
'werror=false',
]
) )
if get_option('tests') if get_option('tests')
@ -53,10 +49,6 @@ if get_option('tests')
c_args : [ c_args : [
cargs, cargs,
], ],
# https://github.com/hughsie/fwupd/issues/207
override_options : [
'werror=false',
]
) )
test('synapticsmst-self-test', e, test('synapticsmst-self-test', e,
env: ['FWUPD_LOCALSTATEDIR=/tmp/fwupd-self-test/var']) env: ['FWUPD_LOCALSTATEDIR=/tmp/fwupd-self-test/var'])

View File

@ -31,7 +31,7 @@ struct _SynapticsMSTConnection {
guint8 guint8
synapticsmst_common_aux_node_read (SynapticsMSTConnection *connection, synapticsmst_common_aux_node_read (SynapticsMSTConnection *connection,
gint offset, gint *buf, gint length) guint32 offset, guint8 *buf, gint length)
{ {
if (lseek (connection->fd, offset, SEEK_SET) != offset) if (lseek (connection->fd, offset, SEEK_SET) != offset)
return DPCD_SEEK_FAIL; return DPCD_SEEK_FAIL;
@ -44,7 +44,7 @@ synapticsmst_common_aux_node_read (SynapticsMSTConnection *connection,
static guint8 static guint8
synapticsmst_common_aux_node_write (SynapticsMSTConnection *connection, synapticsmst_common_aux_node_write (SynapticsMSTConnection *connection,
gint offset, const gint *buf, gint length) guint32 offset, const guint8 *buf, gint length)
{ {
if (lseek (connection->fd, offset, SEEK_SET) != offset) if (lseek (connection->fd, offset, SEEK_SET) != offset)
return DPCD_SEEK_FAIL; return DPCD_SEEK_FAIL;
@ -74,7 +74,7 @@ synapticsmst_common_new (gint fd, guint8 layer, guint rad)
guint8 guint8
synapticsmst_common_read_dpcd (SynapticsMSTConnection *connection, synapticsmst_common_read_dpcd (SynapticsMSTConnection *connection,
gint offset, gint *buf, gint length) guint32 offset, guint8 *buf, guint32 length)
{ {
if (connection->layer && connection->remain_layer) { if (connection->layer && connection->remain_layer) {
guint8 rc, node; guint8 rc, node;
@ -92,9 +92,9 @@ synapticsmst_common_read_dpcd (SynapticsMSTConnection *connection,
guint8 guint8
synapticsmst_common_write_dpcd (SynapticsMSTConnection *connection, synapticsmst_common_write_dpcd (SynapticsMSTConnection *connection,
gint offset, guint32 offset,
const gint *buf, const guint8 *buf,
gint length) guint32 length)
{ {
if (connection->layer && connection->remain_layer) { if (connection->layer && connection->remain_layer) {
guint8 rc, node; guint8 rc, node;
@ -112,14 +112,14 @@ synapticsmst_common_write_dpcd (SynapticsMSTConnection *connection,
guint8 guint8
synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection, synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint length, guint32 length,
gint offset, guint32 offset,
const guint8 *buf) const guint8 *buf)
{ {
guint8 rc = 0; guint8 rc = 0;
gint cur_offset = offset; guint32 cur_offset = offset;
gint cur_length; guint32 cur_length;
gint data_left = length; gint data_left = length;
gint cmd; gint cmd;
gint readData = 0; gint readData = 0;
@ -135,21 +135,21 @@ synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
if (cur_length) { if (cur_length) {
/* write data */ /* write data */
rc = synapticsmst_common_write_dpcd (connection, REG_RC_DATA, (gint *)buf, cur_length); rc = synapticsmst_common_write_dpcd (connection, REG_RC_DATA, buf, cur_length);
if (rc) if (rc)
break; break;
/* write offset */ /* write offset */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_OFFSET, REG_RC_OFFSET,
&cur_offset, 4); (guint8 *)&cur_offset, 4);
if (rc) if (rc)
break; break;
/* write length */ /* write length */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_LEN, REG_RC_LEN,
&cur_length, 4); (guint8 *)&cur_length, 4);
if (rc) if (rc)
break; break;
} }
@ -158,7 +158,7 @@ synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
cmd = 0x80 | rc_cmd; cmd = 0x80 | rc_cmd;
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_CMD, REG_RC_CMD,
&cmd, 1); (guint8 *)&cmd, 1);
if (rc) if (rc)
break; break;
@ -169,7 +169,7 @@ synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
do { do {
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_RC_CMD, REG_RC_CMD,
&readData, 2); (guint8 *)&readData, 2);
clock_gettime (CLOCK_REALTIME, &t_spec); clock_gettime (CLOCK_REALTIME, &t_spec);
if (t_spec.tv_sec > deadline) { if (t_spec.tv_sec > deadline) {
rc = -1; rc = -1;
@ -193,17 +193,17 @@ synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
guint8 guint8
synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection, synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint length, guint32 length,
gint offset, guint32 offset,
guint8 *buf) guint8 *buf)
{ {
guint8 rc = 0; guint8 rc = 0;
gint cur_offset = offset; guint32 cur_offset = offset;
gint cur_length; guint32 cur_length;
gint data_need = length; gint data_need = length;
gint cmd; guint32 cmd;
gint readData = 0; guint32 readData = 0;
long deadline; long deadline;
struct timespec t_spec; struct timespec t_spec;
@ -218,14 +218,14 @@ synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
/* write offset */ /* write offset */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_OFFSET, REG_RC_OFFSET,
&cur_offset, 4); (guint8 *)&cur_offset, 4);
if (rc) if (rc)
break; break;
/* write length */ /* write length */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_LEN, REG_RC_LEN,
&cur_length, 4); (guint8 *)&cur_length, 4);
if (rc) if (rc)
break; break;
} }
@ -234,7 +234,7 @@ synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
cmd = 0x80 | rc_cmd; cmd = 0x80 | rc_cmd;
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_CMD, REG_RC_CMD,
&cmd, 1); (guint8 *)&cmd, 1);
if (rc) if (rc)
break; break;
@ -245,7 +245,7 @@ synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
do { do {
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_RC_CMD, REG_RC_CMD,
&readData, 2); (guint8 *)&readData, 2);
clock_gettime (CLOCK_REALTIME, &t_spec); clock_gettime (CLOCK_REALTIME, &t_spec);
if (t_spec.tv_sec > deadline) { if (t_spec.tv_sec > deadline) {
rc = -1; rc = -1;
@ -262,7 +262,7 @@ synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
if (cur_length) { if (cur_length) {
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_RC_DATA, REG_RC_DATA,
(gint *)buf, buf,
cur_length); cur_length);
if (rc) if (rc)
break; break;
@ -278,16 +278,16 @@ synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
guint8 guint8
synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection, synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint cmd_length, guint32 cmd_length,
gint cmd_offset, guint32 cmd_offset,
guint8 *cmd_data, guint8 *cmd_data,
gint length, guint32 length,
guint8 *buf) guint8 *buf)
{ {
guint8 rc = 0; guint8 rc = 0;
gint readData = 0; guint32 readData = 0;
gint cmd; guint32 cmd;
long deadline; long deadline;
struct timespec t_spec; struct timespec t_spec;
@ -296,7 +296,7 @@ synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
if (cmd_data != NULL) { if (cmd_data != NULL) {
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_DATA, REG_RC_DATA,
(gint *)cmd_data, cmd_data,
cmd_length); cmd_length);
if (rc) if (rc)
return rc; return rc;
@ -305,21 +305,21 @@ synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
/* write offset */ /* write offset */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_OFFSET, REG_RC_OFFSET,
&cmd_offset, 4); (guint8 *)&cmd_offset, 4);
if (rc) if (rc)
return rc; return rc;
/* write length */ /* write length */
rc = synapticsmst_common_write_dpcd (connection, rc = synapticsmst_common_write_dpcd (connection,
REG_RC_LEN, REG_RC_LEN,
&cmd_length, 4); (guint8 *)&cmd_length, 4);
if (rc) if (rc)
return rc; return rc;
} }
/* send command */ /* send command */
cmd = 0x80 | rc_cmd; cmd = 0x80 | rc_cmd;
rc = synapticsmst_common_write_dpcd (connection, REG_RC_CMD, &cmd, 1); rc = synapticsmst_common_write_dpcd (connection, REG_RC_CMD, (guint8 *)&cmd, 1);
if (rc) if (rc)
return rc; return rc;
@ -329,7 +329,7 @@ synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
do { do {
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_RC_CMD, REG_RC_CMD,
&readData, 2); (guint8 *)&readData, 2);
clock_gettime (CLOCK_REALTIME, &t_spec); clock_gettime (CLOCK_REALTIME, &t_spec);
if (t_spec.tv_sec > deadline) if (t_spec.tv_sec > deadline)
return -1; return -1;
@ -345,7 +345,7 @@ synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
if (length) { if (length) {
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_RC_DATA, REG_RC_DATA,
(gint *)buf, length); buf, length);
if (rc) if (rc)
return rc; return rc;
} }

View File

@ -67,39 +67,39 @@ SynapticsMSTConnection *synapticsmst_common_new (gint fd,
guint rad); guint rad);
guint8 synapticsmst_common_aux_node_read (SynapticsMSTConnection *connection, guint8 synapticsmst_common_aux_node_read (SynapticsMSTConnection *connection,
gint offset, guint32 offset,
gint *buf, guint8 *buf,
gint length); gint length);
guint8 synapticsmst_common_read_dpcd (SynapticsMSTConnection *connection, guint8 synapticsmst_common_read_dpcd (SynapticsMSTConnection *connection,
gint offset, guint32 offset,
gint *buf, guint8 *buf,
gint length); guint32 length);
guint8 synapticsmst_common_write_dpcd (SynapticsMSTConnection *connection, guint8 synapticsmst_common_write_dpcd (SynapticsMSTConnection *connection,
gint offset, guint32 offset,
const gint *buf, const guint8 *buf,
gint length); guint32 length);
guint8 synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection, guint8 synapticsmst_common_rc_set_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint length, guint32 length,
gint offset, guint32 offset,
const guint8 *buf); const guint8 *buf);
guint8 synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection, guint8 synapticsmst_common_rc_get_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint length, guint32 length,
gint offset, guint32 offset,
guint8 *buf); guint8 *buf);
guint8 synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection, guint8 synapticsmst_common_rc_special_get_command (SynapticsMSTConnection *connection,
gint rc_cmd, guint32 rc_cmd,
gint cmd_length, guint32 cmd_length,
gint cmd_offset, guint32 cmd_offset,
guint8 *cmd_data, guint8 *cmd_data,
gint length, guint32 length,
guint8 *buf); guint8 *buf);
guint8 synapticsmst_common_enable_remote_control (SynapticsMSTConnection *connection); guint8 synapticsmst_common_enable_remote_control (SynapticsMSTConnection *connection);

View File

@ -275,10 +275,10 @@ synapticsmst_device_scan_cascade_device (SynapticsMSTDevice *device,
} }
connection = synapticsmst_common_new (priv->fd, layer, rad); connection = synapticsmst_common_new (priv->fd, layer, rad);
rc = synapticsmst_common_read_dpcd (connection, REG_RC_CAP, (gint *)byte, 1); rc = synapticsmst_common_read_dpcd (connection, REG_RC_CAP, byte, 1);
if (rc == DPCD_SUCCESS ) { if (rc == DPCD_SUCCESS ) {
if (byte[0] & 0x04) { if (byte[0] & 0x04) {
synapticsmst_common_read_dpcd (connection, REG_VENDOR_ID, (gint *)byte, 3); synapticsmst_common_read_dpcd (connection, REG_VENDOR_ID, byte, 3);
if (byte[0] == 0x90 && byte[1] == 0xCC && byte[2] == 0x24) if (byte[0] == 0x90 && byte[1] == 0xCC && byte[2] == 0x24)
priv->has_cascade = TRUE; priv->has_cascade = TRUE;
} }
@ -488,7 +488,7 @@ synapticsmst_device_enumerate_device (SynapticsMSTDevice *device,
connection = synapticsmst_common_new (priv->fd, priv->layer, priv->rad); connection = synapticsmst_common_new (priv->fd, priv->layer, priv->rad);
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_FIRMWARE_VERSION, REG_FIRMWARE_VERSION,
(gint *)byte, 3); byte, 3);
if (rc) { if (rc) {
g_set_error_literal (error, g_set_error_literal (error,
G_IO_ERROR, G_IO_ERROR,
@ -507,7 +507,7 @@ synapticsmst_device_enumerate_device (SynapticsMSTDevice *device,
/* read board chip_id */ /* read board chip_id */
rc = synapticsmst_common_read_dpcd (connection, rc = synapticsmst_common_read_dpcd (connection,
REG_CHIP_ID, REG_CHIP_ID,
(gint *)byte, 2); byte, 2);
if (rc) { if (rc) {
g_set_error_literal (error, g_set_error_literal (error,
G_IO_ERROR, G_IO_ERROR,
@ -588,7 +588,7 @@ synapticsmst_device_get_cascade (SynapticsMSTDevice *device)
static gboolean static gboolean
synapticsmst_device_get_flash_checksum (SynapticsMSTDevice *device, synapticsmst_device_get_flash_checksum (SynapticsMSTDevice *device,
gint length, gint offset, guint32 length, guint32 offset,
guint32 *checksum, GError **error) guint32 *checksum, GError **error)
{ {
SynapticsMSTDevicePrivate *priv = GET_PRIVATE (device); SynapticsMSTDevicePrivate *priv = GET_PRIVATE (device);
@ -1549,11 +1549,11 @@ synapticsmst_device_open (SynapticsMSTDevice *device, GError **error)
} }
connection = synapticsmst_common_new (priv->fd, 0, 0); connection = synapticsmst_common_new (priv->fd, 0, 0);
if (synapticsmst_common_aux_node_read (connection, REG_RC_CAP, (gint *)byte, 1) == DPCD_SUCCESS) { if (synapticsmst_common_aux_node_read (connection, REG_RC_CAP, byte, 1) == DPCD_SUCCESS) {
if (byte[0] & 0x04) { if (byte[0] & 0x04) {
synapticsmst_common_aux_node_read (connection, synapticsmst_common_aux_node_read (connection,
REG_VENDOR_ID, REG_VENDOR_ID,
(gint *)byte, 3); byte, 3);
if (byte[0] == 0x90 && byte[1] == 0xCC && byte[2] == 0x24) if (byte[0] == 0x90 && byte[1] == 0xCC && byte[2] == 0x24)
return TRUE; return TRUE;
} }