[pacman-dev] Clang warnings

Olivier Brunel jjk at jjacky.com
Fri Jan 1 12:01:40 UTC 2016

On Thu, 31 Dec 2015 14:32:45 +0100
Rikard Falkeborn <rikard.falkeborn at 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.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);

Or we could use a pointer, as that may be a little less verbose, e.g:

alpm_event_t _event;
alpm_event_hook_run_t *event = &_event.hook_run;
event->name = name;
event->desc = desc;
EVENT(handle, &_event);

I'm not sure if using EVENT(handle, event) would work then, even though
they're basically the same in the end.

Not sure which solution you guys would prefer, if any? I'd be happy to
send a patch addressing this if you'd like though.

More information about the pacman-dev mailing list