diff mbox series

[12/18] libsbefifo: Use proper cast

Message ID 20200924044236.130586-13-amitay@ozlabs.org
State Superseded
Headers show
Series Add p10 support to libpdbg | expand

Commit Message

Amitay Isaacs Sept. 24, 2020, 4:42 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libsbefifo/cmd_control.c | 2 +-
 libsbefifo/cmd_scom.c    | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Joel Stanley Sept. 28, 2020, 6:01 a.m. UTC | #1
On Thu, 24 Sep 2020 at 04:43, Amitay Isaacs <amitay@ozlabs.org> wrote:
>
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  libsbefifo/cmd_control.c | 2 +-
>  libsbefifo/cmd_scom.c    | 6 ++++--
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
> index 4826b5d..e64f555 100644
> --- a/libsbefifo/cmd_control.c
> +++ b/libsbefifo/cmd_control.c
> @@ -36,7 +36,7 @@ static int sbefifo_istep_execute_push(uint8_t major, uint8_t minor, uint8_t **bu
>
>         cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_EXECUTE_ISTEP;
>
> -       step = (major << 16) | minor;
> +       step = ((uint32_t)major << 16) | (uint32_t)minor;
>
>         msg[0] = htobe32(nwords);
>         msg[1] = htobe32(cmd);
> diff --git a/libsbefifo/cmd_scom.c b/libsbefifo/cmd_scom.c
> index 935a00f..db8214d 100644
> --- a/libsbefifo/cmd_scom.c
> +++ b/libsbefifo/cmd_scom.c
> @@ -139,7 +139,7 @@ int sbefifo_scom_put(struct sbefifo_context *sctx, uint64_t addr, uint64_t value
>  static int sbefifo_scom_modify_push(uint64_t addr, uint64_t value, uint8_t operand, uint8_t **buf, uint32_t *buflen)
>  {
>         uint32_t *msg;
> -       uint32_t nwords, cmd;
> +       uint32_t nwords, cmd, oper;
>
>         nwords = 7;
>         *buflen = nwords * sizeof(uint32_t);
> @@ -149,9 +149,11 @@ static int sbefifo_scom_modify_push(uint64_t addr, uint64_t value, uint8_t opera
>
>         cmd = SBEFIFO_CMD_CLASS_SCOM | SBEFIFO_CMD_MODIFY_SCOM;
>
> +       oper = (uint32_t)operand;
> +
>         msg[0] = htobe32(nwords);
>         msg[1] = htobe32(cmd);
> -       msg[2] = htobe32(operand);
> +       msg[2] = htobe32(oper);
>         msg[3] = htobe32(addr >> 32);
>         msg[4] = htobe32(addr & 0xffffffff);
>         msg[5] = htobe32(value >> 32);
> --
> 2.26.2
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
diff mbox series

Patch

diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
index 4826b5d..e64f555 100644
--- a/libsbefifo/cmd_control.c
+++ b/libsbefifo/cmd_control.c
@@ -36,7 +36,7 @@  static int sbefifo_istep_execute_push(uint8_t major, uint8_t minor, uint8_t **bu
 
 	cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_EXECUTE_ISTEP;
 
-	step = (major << 16) | minor;
+	step = ((uint32_t)major << 16) | (uint32_t)minor;
 
 	msg[0] = htobe32(nwords);
 	msg[1] = htobe32(cmd);
diff --git a/libsbefifo/cmd_scom.c b/libsbefifo/cmd_scom.c
index 935a00f..db8214d 100644
--- a/libsbefifo/cmd_scom.c
+++ b/libsbefifo/cmd_scom.c
@@ -139,7 +139,7 @@  int sbefifo_scom_put(struct sbefifo_context *sctx, uint64_t addr, uint64_t value
 static int sbefifo_scom_modify_push(uint64_t addr, uint64_t value, uint8_t operand, uint8_t **buf, uint32_t *buflen)
 {
 	uint32_t *msg;
-	uint32_t nwords, cmd;
+	uint32_t nwords, cmd, oper;
 
 	nwords = 7;
 	*buflen = nwords * sizeof(uint32_t);
@@ -149,9 +149,11 @@  static int sbefifo_scom_modify_push(uint64_t addr, uint64_t value, uint8_t opera
 
 	cmd = SBEFIFO_CMD_CLASS_SCOM | SBEFIFO_CMD_MODIFY_SCOM;
 
+	oper = (uint32_t)operand;
+
 	msg[0] = htobe32(nwords);
 	msg[1] = htobe32(cmd);
-	msg[2] = htobe32(operand);
+	msg[2] = htobe32(oper);
 	msg[3] = htobe32(addr >> 32);
 	msg[4] = htobe32(addr & 0xffffffff);
 	msg[5] = htobe32(value >> 32);