On 08/06/14 00:03, Olivier Brunel wrote:
On 06/07/14 15:45, Andrew Gregory wrote:
On 05/31/14 at 07:28pm, Olivier Brunel wrote:
Much like with events, instead of using a bunch of void* arguments for all questions, we now send one pointer to an alpm_question_t union. This contains the type of question that was triggered.
With this information, a question-specific struct can be accessed in order to get additional arguments.
Signed-off-by: Olivier Brunel <jjk@jjacky.com> --- This uses for alpm_quesion_t an union with all question-specific struct, I'm thinking this should resolve the issue reported with clang.
I don't actually have clang here though, Andrew could you try it and let me know whether it solves the issue or not, please?
If it does, I'll do a patch with similar changes for events.
-j
lib/libalpm/alpm.h | 104 +++++++++++++++++++++++++++++++++++++++++++++-- lib/libalpm/deps.c | 38 ++++++++++------- lib/libalpm/handle.h | 4 +- lib/libalpm/signing.c | 12 ++++-- lib/libalpm/sync.c | 60 +++++++++++++++++---------- src/pacman/callback.c | 110 +++++++++++++++++++++++++++----------------------- src/pacman/callback.h | 3 +- 7 files changed, 234 insertions(+), 97 deletions(-)
This does silence Clang's warnings about casting. I don't have much occasion to use unions personally; is it safe to read the question type directly from the union and to cast the union to the various question types rather than accessing them as fields?
I believe it is, yes. In fact it's something done frequently when dealing with e.g. XEvent or GdkEvent, both are union working similarly, where one can use the union field or typecast the pointer to the event-specific struct. Though I could change things to access union fields instead of typecasting if it is preferred?
I looked at GdkEvent: http://www.gtk-server.org/gtk1/gdk/gdk-event-structures.html I would lean to union member access rather than typecasting, but not strongly. Any other opinions here? A