[pacman-dev] [PATCH v2 2/2] Update the question callback

Olivier Brunel jjk at jjacky.com
Thu May 29 06:30:57 EDT 2014


On 05/29/14 07:41, Allan McRae wrote:
> On 26/05/14 01:30, Andrew Gregory wrote:
>> On 05/24/14 at 03:49pm, 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 struct.
>>> This contains the type of question that was triggered.
>>>
>>> With this information, the pointer can then be typecasted to the
>>> question-specific struct in order to get additional arguments.
>>>
>>> Signed-off-by: Olivier Brunel <jjk at jjacky.com>
>>> ---
>>>  lib/libalpm/alpm.h    |  92 +++++++++++++++++++++++++++++++++++++++--
>>>  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, 222 insertions(+), 97 deletions(-)
>>
>> The generic to specific struct casts cause Clang to fail when pacman
>> is configured with --enable-warningflags:
>>
>>  callback.c:377:44: error: cast from 'alpm_question_t *' (aka 'struct
>>        _alpm_question_t *') to 'alpm_question_install_ignorepkg_t *'
>>        (aka 'struct _alpm_question_install_ignorepkg_t *') increases
>>        required alignment from 4 to 8 [-Werror,-Wcast-align]
>>    ...*q = (alpm_question_install_ignorepkg_t *) question;
>>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Any suggestions of what we can do there?

I'm thinking turning the generic struct into an union of all the
specific ones would fix it, something like:

typedef struct _alpm_question_any_t {
    alpm_question_type_t type;
    int answer;
} alpm_question_any_t;

typedef union _alpm_question_t {
    alpm_question_type_t type;
    alpm_question_any_t any;
    alpm_question_install_ignorepkg_t install_ignorepkg;
    alpm_question_replace_t replace;
    ...
} alpm_question_t;

Something similar to how XEvent works.

> 
> 
>> The earlier changes to the event callback have the same issue and also
>> give errors about using non-literal strings with vprintf:
>>
>>  testdb.c:53:11: error: format string is not a string literal
>>        [-Werror,-Wformat-nonliteral]
>>                  vprintf(event->fmt, event->args);
>>                          ^~~~~~~~~~
>>
>> apg
>>
>>
>>
> 
> 



More information about the pacman-dev mailing list