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 unaligned access in tests/genicam.c #965

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
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
12 changes: 6 additions & 6 deletions tests/genicam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,10 +1086,10 @@ create_buffer_with_chunk_data (void)
ArvChunkInfos *chunk_infos;
char *data;
size_t size;
guint32 *int_value;
guint32 int_value;
guint8 *boolean_value;
guint offset;
guint64 *float_value;
guint64 float_value;

size = 64 + 8 + 64 + 8 + 1 + 5 * sizeof (ArvChunkInfos);

Expand All @@ -1107,8 +1107,8 @@ create_buffer_with_chunk_data (void)
chunk_infos->id = GUINT32_TO_BE (0x12345678);
chunk_infos->size = GUINT32_TO_BE (8);

int_value = (guint32 *) &data[offset - 8];
*int_value = GUINT32_TO_BE (0x11223344);
int_value = GUINT32_TO_BE (0x11223344);
memcpy ((char *) &data[offset - 8], (char *)&int_value, sizeof(int_value));

offset -= 8 + sizeof (ArvChunkInfos);
chunk_infos = (ArvChunkInfos *) &data[offset];
Expand All @@ -1122,8 +1122,8 @@ create_buffer_with_chunk_data (void)
chunk_infos->id = GUINT32_TO_BE (0x12345679);
chunk_infos->size = GUINT32_TO_BE (8);

float_value = (guint64 *) &data[offset - 8];
*float_value = GUINT64_TO_BE (0x3FF199999999999A); /* Hexadecimal representation of 1.1 as double */
float_value = GUINT64_TO_BE (0x3FF199999999999A); /* Hexadecimal representation of 1.1 as double */
memcpy ((char *) &data[offset - 8], (char *)&float_value, sizeof(float_value));

offset -= 8 + sizeof (ArvChunkInfos);
chunk_infos = (ArvChunkInfos *) &data[offset];
Expand Down
Loading