Changeset 102


Ignore:
Timestamp:
08/30/11 18:51:01 (21 months ago)
Author:
pouillon
Message:

Fixed design flaws in error handlers

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/pspio_error.c

    r95 r102  
    2424 
    2525 
    26 int pspio_error_add(const int id, const char *filename, const long line) { 
     26int pspio_error_add(const char *filename, const long line) { 
    2727  int s; 
    2828  pspio_error_t *last_err; 
     
    3434    } 
    3535 
    36     pspio_error_chain->id = id; 
     36    pspio_error_chain->id = pspio_error_tmp_id; 
    3737    pspio_error_chain->line = line; 
    3838    pspio_error_chain->next = NULL; 
     
    5858  } 
    5959  last_err = last_err->next; 
    60   last_err->id = id; 
     60  last_err->id = pspio_error_tmp_id; 
    6161  last_err->line = line; 
    6262  last_err->next = NULL; 
  • trunk/src/pspio_error.h

    r95 r102  
    2626 * @brief Error codes and handlers 
    2727 */ 
     28 
     29#include <stdlib.h> 
    2830 
    2931#if defined HAVE_CONFIG_H 
     
    6163} pspio_error_t; 
    6264 
    63 static pspio_error_t *pspio_error_chain; 
     65/* The following is a VERY bad trick. Whoever finds better is welcome to 
     66 * speak. */ 
     67static int pspio_error_tmp_id = 0; 
     68static pspio_error_t *pspio_error_chain = NULL; 
    6469 
    6570 
     
    6873 * @param[in] new_error: new error to add 
    6974 */ 
    70 int pspio_error_add(const int id, const char *filename, const long line); 
     75int pspio_error_add(const char *filename, const long line); 
    7176 
    7277 
     
    8489 */ 
    8590#define HANDLE_ERROR(FUNCTION_CALL, TYPE_TO_FREE, VAR_TO_FREE) \ 
    86   int ierr_macro; \ 
    87   ierr_macro = FUNCTION_CALL; \ 
    88   if ( ierr_macro != PSPIO_SUCCESS ) { \ 
     91  pspio_error_tmp_id = FUNCTION_CALL; \ 
     92  if ( pspio_error_tmp_id != PSPIO_SUCCESS ) { \ 
    8993    pspio_ ## TYPE_TO_FREE ## _free(VAR_TO_FREE); \ 
    90     pspio_error_add(ierr_macro, __FILE__, __LINE__); \ 
    91     return ierr_macro; \ 
     94    pspio_error_add(pspio_error_tmp_id, __FILE__, __LINE__); \ 
     95    return pspio_error_tmp_id; \ 
    9296  } 
    9397#endif 
     98 
     99 
Note: See TracChangeset for help on using the changeset viewer.