Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various bugs in eeprom handling #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 24c16.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef struct {
unsigned char address;
} t_24c16;

typedef struct {
typedef struct __attribute__((packed)){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a good idea. This moves the float field to a misaligned offset, and may crash with SIGBUS on some CPUs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest as alternative ?? Add a stuff variable instead ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to define the float inside the struct as the first item? This will reduce the padding to 1 byte. Then we can add one byte to the serial number to fill that padding byte.

char header[3];
char data_version;
char serial[6];
Expand Down