Changeset 3090715 in mainline for uspace/lib/c


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
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/measured_strings.c

    r9ce7eb5 r3090715  
    4141#include <unistd.h>
    4242#include <errno.h>
    43 #include <err.h>
    4443#include <async.h>
    4544
     
    135134    size_t count)
    136135{
    137         ERROR_DECLARE;
    138 
    139136        size_t *lengths;
    140137        size_t index;
     
    142139        char *next;
    143140        ipc_callid_t callid;
     141        int rc;
    144142
    145143        if ((!strings) || (!data) || (count <= 0))
     
    155153                return EINVAL;
    156154        }
    157         if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths,
    158             length))) {
    159                 free(lengths);
    160                 return ERROR_CODE;
     155        rc = async_data_write_finalize(callid, lengths, length);
     156        if (rc != EOK) {
     157                free(lengths);
     158                return rc;
    161159        }
    162160
     
    187185                                return EINVAL;
    188186                        }
    189                         if (ERROR_OCCURRED(async_data_write_finalize(callid,
    190                             next, lengths[index]))) {
     187                        rc = async_data_write_finalize(callid, next,
     188                            lengths[index]);
     189                        if (rc != EOK) {
    191190                                free(*data);
    192191                                free(*strings);
    193192                                free(lengths);
    194                                 return ERROR_CODE;
     193                                return rc;
    195194                        }
    196195                        (*strings)[index].value = next;
     
    251250int measured_strings_reply(const measured_string_ref strings, size_t count)
    252251{
    253         ERROR_DECLARE;
    254 
    255252        size_t *lengths;
    256253        size_t index;
    257254        size_t length;
    258255        ipc_callid_t callid;
     256        int rc;
    259257
    260258        if ((!strings) || (count <= 0))
     
    270268                return EINVAL;
    271269        }
    272         if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) {
    273                 free(lengths);
    274                 return ERROR_CODE;
     270        rc = async_data_read_finalize(callid, lengths, length);
     271        if (rc != EOK) {
     272                free(lengths);
     273                return rc;
    275274        }
    276275        free(lengths);
     
    282281                                return EINVAL;
    283282                        }
    284                         ERROR_PROPAGATE(async_data_read_finalize(callid,
    285                             strings[index].value, strings[index].length));
     283                        rc = async_data_read_finalize(callid,
     284                            strings[index].value, strings[index].length);
     285                        if (rc != EOK)
     286                                return rc;
    286287                }
    287288        }
     
    313314    size_t count)
    314315{
    315         ERROR_DECLARE;
    316 
    317316        size_t *lengths;
    318317        size_t index;
    319318        char *next;
     319        int rc;
    320320
    321321        if ((phone < 0) || (!strings) || (!data) || (count <= 0))
     
    326326                return ENOMEM;
    327327
    328         if (ERROR_OCCURRED(async_data_read_start(phone, lengths,
    329             sizeof(size_t) * (count + 1)))) {
    330                 free(lengths);
    331                 return ERROR_CODE;
     328        rc = async_data_read_start(phone, lengths,
     329            sizeof(size_t) * (count + 1));
     330        if (rc != EOK) {
     331                free(lengths);
     332                return rc;
    332333        }
    333334
     
    350351                (*strings)[index].length = lengths[index];
    351352                if (lengths[index] > 0) {
    352                         if (ERROR_OCCURRED(async_data_read_start(phone, next,
    353                             lengths[index]))) {
     353                        rc = async_data_read_start(phone, next, lengths[index]);
     354                        if (rc != EOK) {
    354355                                free(lengths);
    355356                                free(data);
    356357                                free(strings);
    357                                 return ERROR_CODE;
     358                                return rc;
    358359                        }
    359360                        (*strings)[index].value = next;
     
    387388    size_t count)
    388389{
    389         ERROR_DECLARE;
    390 
    391390        size_t *lengths;
    392391        size_t index;
     392        int rc;
    393393
    394394        if ((phone < 0) || (!strings) || (count <= 0))
     
    399399                return ENOMEM;
    400400
    401         if (ERROR_OCCURRED(async_data_write_start(phone, lengths,
    402             sizeof(size_t) * (count + 1)))) {
    403                 free(lengths);
    404                 return ERROR_CODE;
     401        rc = async_data_write_start(phone, lengths,
     402            sizeof(size_t) * (count + 1));
     403        if (rc != EOK) {
     404                free(lengths);
     405                return rc;
    405406        }
    406407
     
    409410        for (index = 0; index < count; index++) {
    410411                if (strings[index].length > 0) {
    411                         ERROR_PROPAGATE(async_data_write_start(phone,
    412                             strings[index].value, strings[index].length));
     412                        rc = async_data_write_start(phone, strings[index].value,
     413                            strings[index].length);
     414                        if (rc != EOK)
     415                                return rc;
    413416                }
    414417        }
  • 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.