Skip to content

Commit dde1f87

Browse files
committed
Fixed a bug in the value union for program storage
1 parent d071c21 commit dde1f87

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

program.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
uint8_t program[PROGRAM_MAX_SIZE];
44

5-
struct value get_integer(uint16_t position, uint8_t size)
5+
union value get_integer(uint16_t position, uint8_t size)
66
{
7-
struct value value;
7+
union value value;
88

99
switch (size) {
1010
case 1:

program.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33

44
#include "stdlib.h"
55

6-
struct value {
7-
uint8_t raw[]; // TODO: check the empty square brackets
8-
union {
9-
uint8_t u8;
10-
uint16_t u16;
11-
int32_t i32;
12-
uint32_t u32;
13-
};
6+
union value {
7+
uint8_t raw[4];
8+
uint8_t u8;
9+
uint16_t u16;
10+
int32_t i32;
11+
uint32_t u32;
1412
};
1513

1614
static const int PROGRAM_MAX_SIZE = 65536;
1715

1816
extern uint8_t program[PROGRAM_MAX_SIZE];
1917

20-
struct value get_integer(uint16_t position, uint8_t size);
18+
union value get_integer(uint16_t position, uint8_t size);
2119

2220
#endif /* end of include guard: PROGRAM_H */

0 commit comments

Comments
 (0)