Changeset 3090715 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2010-11-07T21:16:56Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d0d06a
Parents:
9ce7eb5 (diff), 9ee9d5d5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/net/.

Location:
uspace/lib/c/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/generic_char_map.h

    r9ce7eb5 r3090715  
    4040#include <unistd.h>
    4141#include <errno.h>
    42 #include <err.h>
    4342
    4443#include <adt/char_map.h>
     
    8584             type *value) \
    8685        { \
    87                 ERROR_DECLARE; \
     86                int rc; \
    8887                int index; \
    8988                if (!name##_is_valid(map)) \
     
    9291                if (index < 0) \
    9392                        return index; \
    94                 if (ERROR_OCCURRED(char_map_add(&map->names, name, length, \
    95                     index))) { \
     93                rc = char_map_add(&map->names, name, length, index); \
     94                if (rc != EOK) { \
    9695                        name##_items_exclude_index(&map->values, index); \
    97                         return ERROR_CODE; \
     96                        return rc; \
    9897                } \
    9998                return EOK; \
     
    141140        int name##_initialize(name##_ref map) \
    142141        { \
    143                 ERROR_DECLARE; \
     142                int rc; \
    144143                if (!map) \
    145144                        return EINVAL; \
    146                 ERROR_PROPAGATE(char_map_initialize(&map->names)); \
    147                 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \
     145                rc = char_map_initialize(&map->names); \
     146                if (rc != EOK) \
     147                        return rc; \
     148                rc = name##_items_initialize(&map->values); \
     149                if (rc != EOK) { \
    148150                        char_map_destroy(&map->names); \
    149                         return ERROR_CODE; \
     151                        return rc; \
    150152                } \
    151153                map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
  • uspace/lib/c/include/err.h

    r9ce7eb5 r3090715  
    3737
    3838#include <stdio.h>
    39 #include <errno.h>
    40 
    41 #ifdef CONFIG_DEBUG
    42 #include <str_error.h>
    43 #endif
    4439
    4540#define errx(status, fmt, ...) { \
     
    4843}
    4944
    50 
    51 /** An actual stored error code.  */
    52 #define ERROR_CODE  error_check_return_value
    53 
    54 /** An error processing routines declaration.
    55  *
    56  * This has to be declared in the block where the error processing
    57  * is desired.
    58  */
    59 #define ERROR_DECLARE  int ERROR_CODE
    60 
    61 /** Store the value as an error code and checks if an error occurred.
    62  *
    63  * @param[in] value     The value to be checked. May be a function call.
    64  * @return              False if the value indicates success (EOK).
    65  * @return              True otherwise.
    66  */
    67 #ifdef CONFIG_DEBUG
    68 
    69 #define ERROR_OCCURRED(value) \
    70         (((ERROR_CODE = (value)) != EOK) && \
    71         ({ \
    72                 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
    73                 __FILE__, __LINE__, str_error(ERROR_CODE)); \
    74                 1; \
    75         }))
    76 
    77 #else
    78 
    79 #define ERROR_OCCURRED(value)   ((ERROR_CODE = (value)) != EOK)
    80 
    81 #endif
    82 
    83 #define ERROR_NONE(value)       !ERROR_OCCURRED((value))
    84 
    85 /** Error propagation
    86  *
    87  * Check if an error occurred and immediately exit the actual
    88  * function returning the error code.
    89  *
    90  * @param[in] value     The value to be checked. May be a function call.
    91  *
    92  */
    93 
    94 #define ERROR_PROPAGATE(value) \
    95         if (ERROR_OCCURRED(value)) \
    96                 return ERROR_CODE
    97 
    9845#endif
    9946
    10047/** @}
    10148 */
     49
Note: See TracChangeset for help on using the changeset viewer.