You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2020/05/07 13:28:06 UTC

[mynewt-core] branch master updated: kernel/os: Fix helpers for put/get be24

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 482a13c  kernel/os: Fix helpers for put/get be24
482a13c is described below

commit 482a13cf85408b258ae4133fbc72dca89cf47d2e
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Apr 17 15:15:56 2020 +0200

    kernel/os: Fix helpers for put/get be24
---
 kernel/os/src/endian.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/os/src/endian.c b/kernel/os/src/endian.c
index b6e2dbe..9a41709 100644
--- a/kernel/os/src/endian.c
+++ b/kernel/os/src/endian.c
@@ -145,9 +145,9 @@ put_be24(void *buf, uint32_t x)
     uint8_t *u8ptr;
 
     u8ptr = buf;
-    u8ptr[0] = (uint8_t)(x >> 24);
-    u8ptr[1] = (uint8_t)(x >> 16);
-    u8ptr[2] = (uint8_t)(x >> 8);
+    u8ptr[0] = (uint8_t)(x >> 16);
+    u8ptr[1] = (uint8_t)(x >> 8);
+    u8ptr[2] = (uint8_t)x;
 }
 
 void
@@ -198,9 +198,9 @@ get_be24(const void *buf)
     uint32_t x;
 
     u8ptr = buf;
-    x = (uint32_t)u8ptr[0] << 24;
-    x |= (uint32_t)u8ptr[1] << 16;
-    x |= (uint32_t)u8ptr[2] << 8;
+    x = (uint32_t)u8ptr[0] << 16;
+    x |= (uint32_t)u8ptr[1] << 8;
+    x |= (uint32_t)u8ptr[2];
 
     return x;
 }