Skip to content

Hi, I may find some error in encoding.h. #3

@PraflyGod

Description

@PraflyGod

in encoding.h:
`
/* encode 32 bits unsigned int (lsb) */

inline byte *encode32u(byte *p, uint32_t l)

{

#if IWORDS_BIG_ENDIAN

*(unsigned char*)(p + 0) = (unsigned char)((l >>  0) & 0xff);

*(unsigned char*)(p + 1) = (unsigned char)((l >>  8) & 0xff);

*(unsigned char*)(p + 2) = (unsigned char)((l >> 16) & 0xff);

*(unsigned char*)(p + 3) = (unsigned char)((l >> 24) & 0xff);

#else

*(int32_t*)p = l;

#endif

p += 4;

return p;

}

/* Decode 32 bits unsigned int (lsb) */

inline byte *decode32u(byte *p, uint32_t *l)

{

#if IWORDS_BIG_ENDIAN

*l = *(const unsigned char*)(p + 3);

*l = *(const unsigned char*)(p + 2) + (*l << 8);

*l = *(const unsigned char*)(p + 1) + (*l << 8);

*l = *(const unsigned char*)(p + 0) + (*l << 8);

#else

*l = *(const int32_t*)p;

#endif

p += 4;

return p;

}`
I think we should use "const uint32_t*" to replace "const int32_t*". Same as "int32_t" and "uint32_t".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions