[pacman-dev] [PATCH] Make all error messages use pm_fprintf

Allan McRae mcrae_allan at hotmail.com
Sun May 11 20:22:22 EDT 2008


Dan McGee wrote:
> On Sat, May 10, 2008 at 10:30 PM, Allan McRae <mcrae_allan at hotmail.com> wrote:
>   
>> Tested using many easily generated error conditions.
>>  Also added "malloc failure" (conf.c) and "segmentation fault" (pacman.c)
>>  error messages for translation
>>
>>  Signed-off-by: Allan McRae <mcrae_allan at hotmail.com>
>>     
> This is great, thanks. I added a few comments inline and below, but
> I've pulled this patch into my working branch and made the fixes
> myself.
>
>   
>>  ---
>>   src/pacman/conf.c    |    2 +-
>>   src/pacman/package.c |    7 +++----
>>   src/pacman/pacman.c  |    6 +++---
>>   src/pacman/query.c   |   15 ++++++++-------
>>   src/pacman/remove.c  |    6 +++---
>>   src/pacman/sync.c    |   44 ++++++++++++++++++++++++++------------------
>>   src/pacman/upgrade.c |    7 ++++---
>>   src/pacman/util.c    |    4 ++--
>>   8 files changed, 50 insertions(+), 41 deletions(-)
>>
>>  diff --git a/src/pacman/conf.c b/src/pacman/conf.c
>>  index bf3a462..bf3909a 100644
>>  --- a/src/pacman/conf.c
>>  +++ b/src/pacman/conf.c
>>  @@ -33,7 +33,7 @@ config_t *config_new(void)
>>   {
>>         config_t *newconfig = calloc(1, sizeof(config_t));
>>         if(!newconfig) {
>>  -                       fprintf(stderr, "malloc failure: could not allocate %zd bytes\n",
>>  +                       pm_fprintf(stderr, PM_LOG_ERROR, _("malloc failure: could not allocate %zd bytes\n"),
>>                                 sizeof(config_t));
>>                         return(NULL);
>>         }
>>     
> conf.c spat a warning about not knowing the definition of pm_fprintf,
> which is because util.h hadn't been included. It probably correctly
> compiled for you because you aren't using the --enable-debug option,
> so a warning would have been spit here but it wouldn't have stopped
> your compile. Just something to keep in mind- when you are doing
> development, you probably want to keep --enable-debug turned on.
>
>   

It also gets caught without the --enable-debug option. :(  I added this 
after I had tested out all the other error messages and though it was a 
simple fix that I couldn't test so....


>>  diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
>>  index 9468d51..53a96cf 100644
>>  --- a/src/pacman/pacman.c
>>  +++ b/src/pacman/pacman.c
>>  @@ -213,9 +213,9 @@ static RETSIGTYPE handler(int signum)
>>         if(signum==SIGSEGV)
>>         {
>>                 /* write a log message and write to stderr */
>>  -               pm_printf(PM_LOG_ERROR, "segmentation fault\n");
>>  -               pm_fprintf(stderr, PM_LOG_ERROR, "Internal pacman error: Segmentation fault.\n"
>>  -                       "Please submit a full bug report with --debug if appropriate.\n");
>>  +               pm_printf(PM_LOG_ERROR, _("segmentation fault\n"));
>>  +               pm_fprintf(stderr, PM_LOG_ERROR, _("Internal pacman error: Segmentation fault.\n")
>>  +                       _("Please submit a full bug report with --debug if appropriate.\n"));
>>     
> I'm not sure if you did this after the fact and didn't compile it, but
> it didn't quite work. :)
>
>
>   

It may have also been an after thought....

>
> I would recommend most people do the following:
> chmod +x .git/hooks/{applypatch-msg,commit-message,pre-commit,pre-rebase}
>   
Done.  For some reason I though that git removed these automatically 
when creating patches.  It appears I was wrong!

Allan






More information about the pacman-dev mailing list