[pacman-dev] [PATCH v2] alpm: Fix possible alignment issues w/ events
Allan McRae
allan at archlinux.org
Fri Jan 15 04:51:54 UTC 2016
On 04/01/16 19:58, Andrew Gregory wrote:
> On 01/02/16 at 10:14pm, Olivier Brunel wrote:
>> As reported by Rikard Falkeborn[1] using event-specific struct and then
>> typecasting to the generic alpm_event_t could possibly lead to alignment issue,
>> so we now always use alpm_event_t instead.
>>
>> [1] https://lists.archlinux.org/pipermail/pacman-dev/2015-December/020709.html
>>
>> Signed-off-by: Olivier Brunel <jjk at jjacky.com>
>> ---
>> Now always using the union member, to avoid initializer warnings (thanks Rikard)
>> and better consistency. Hopefully this time it's all good.
>>
>> lib/libalpm/add.c | 44 ++++++++++++++++++++++----------------------
>> lib/libalpm/be_sync.c | 6 +++---
>> lib/libalpm/handle.h | 2 +-
>> lib/libalpm/hook.c | 22 +++++++++++-----------
>> lib/libalpm/remove.c | 28 ++++++++++++++--------------
>> lib/libalpm/sync.c | 14 +++++++-------
>> lib/libalpm/trans.c | 2 +-
>> lib/libalpm/util.c | 6 +++---
>> 8 files changed, 62 insertions(+), 62 deletions(-)
>
> Is there any reason not to just silence the warning by casting the
> event to (void*)?
>
Something like this?
diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c
index 49a5dae..ed79fdd 100644
--- a/lib/libalpm/hook.c
+++ b/lib/libalpm/hook.c
@@ -729,7 +729,7 @@ int _alpm_hook_run(alpm_handle_t *handle,
alpm_hook_when_t when)
if(hooks_triggered != NULL) {
event.type = ALPM_EVENT_HOOK_START;
- EVENT(handle, &event);
+ EVENT(handle, (void *)&event);
hook_event.position = 1;
hook_event.total = triggered;
@@ -758,7 +758,7 @@ int _alpm_hook_run(alpm_handle_t *handle,
alpm_hook_when_t when)
alpm_list_free(hooks_triggered);
event.type = ALPM_EVENT_HOOK_DONE;
- EVENT(handle, &event);
+ EVENT(handle, (void *)&event);
}
cleanup:
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 7e6d7bc..239d6a1 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -199,7 +199,7 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t
*handle, alpm_list_t **data)
alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction started\n");
event.type = ALPM_EVENT_TRANSACTION_START;
- EVENT(handle, &event);
+ EVENT(handle, (void *)&event);
if(trans->add == NULL) {
if(_alpm_remove_packages(handle, 1) == -1) {
@@ -223,7 +223,7 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t
*handle, alpm_list_t **data)
alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction interrupted\n");
} else {
event.type = ALPM_EVENT_TRANSACTION_DONE;
- EVENT(handle, &event);
+ EVENT(handle, (void *)&event);
alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction completed\n");
_alpm_hook_run(handle, ALPM_HOOK_POST_TRANSACTION);
}
More information about the pacman-dev
mailing list