On Fri, 1 Jan 2016 23:03:22 +1000 Allan McRae <allan@archlinux.org> wrote:
On 01/01/16 22:01, Olivier Brunel wrote:
On Thu, 31 Dec 2015 14:32:45 +0100 Rikard Falkeborn <rikard.falkeborn@gmail.com> wrote:
There are some warnings recently introduced when compiling with Clang (with --enable-warningflags) for x86_64. The warnings are related to casting of specific alpm_event-types to alpm_event_t where the required alignment differs between the types. On x86, it shouldn't be a problem, but maybe there are other architectures pacman should work on where this is a real issue? Either way, I think it would be good if pacman built cleanly with Clang. Any suggestions on how to fix this?
I think the only way is not to use a specific event type but the generic one, to ensure the size is correct. I don't have clang so I didn't test this, but I think there are two ways to solve this.
Basically the issue is when using code such as:
alpm_event_hook_run_t event; event.type = ALPM_EVENT_HOOK_RUN_START; event.name = name; event.desc = desc; EVENT(handle, &event);
So we could either use the alpm_event_t and always go into the right union member, e.g:
alpm_event_t event; event.hook_run.type = ALPM_EVENT_HOOK_RUN_START; event.hook_run.name = name; event.hook_run.desc = desc; EVENT(handle, &event);
I'd prefer this way but...
What is different with these events than all the others? Why do the old ones not give warnings? We should be consistent here. I have a feeling we have had this conversation before...
Allan
I picked hook_run as an example, but it might affect older ones as well. The point is that alpm_event_t and alpm_event_hook_run_t differ in size. Now since the former is a union of all the specific events, it can hold them all, but when creating/using only a specific one, it might be of a different size. (Or maybe this is the first one to grow over the generic event?) As for having had this conversation before, I'm not sure, but there probaly have been a similar one in the other way around: how to use the generic event to get specific values, e.g. in pacman callback handler: typecast, of through the union. For the record, though sometimes we just go through the union (e.g. event->scriptlet_info.line) most times (or, whenever more than one or two values are needed, or used more than once) we just use a specific pointer, e.g: alpm_event_hook_run_t *e = &event->hook_run; -j