Skip to content

Commit

Permalink
the cast will automatically truncate the variable
Browse files Browse the repository at this point in the history
no need for a mask
  • Loading branch information
alandekok committed Sep 25, 2019
1 parent 532d861 commit c337d56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/util/net.h
Expand Up @@ -171,14 +171,14 @@ static inline void fr_put_be16(uint8_t a[static sizeof(uint16_t)], uint16_t val)

static inline void fr_put_be32(uint8_t a[static sizeof(uint32_t)], uint32_t val)
{
fr_put_be16(a, (uint16_t) ((val >> 16) & 0xffff));
fr_put_be16(a + sizeof(uint16_t), (uint16_t) (val & 0xffff));
fr_put_be16(a, (uint16_t) (val >> 16));
fr_put_be16(a + sizeof(uint16_t), (uint16_t) val);
}

static inline void fr_put_be64(uint8_t a[static sizeof(uint64_t)], uint64_t val)
{
fr_put_be32(a, (uint32_t) ((val >> 32) & 0xffffffff));
fr_put_be32(a + sizeof(uint32_t), (uint32_t) (val & 0xffffffff));
fr_put_be32(a, (uint32_t) (val >> 32));
fr_put_be32(a + sizeof(uint32_t), (uint32_t) val);
}

static inline uint16_t fr_get_be16(uint8_t const a[static sizeof(uint16_t)])
Expand Down

0 comments on commit c337d56

Please sign in to comment.