Changeset a42d7d8 in mainline for uspace/lib/bithenge/tree.c


Ignore:
Timestamp:
2012-08-19T05:28:24Z (13 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fae4d30
Parents:
1c79996
Message:

Bithenge: add fake system call errors to test error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/tree.c

    r1c79996 ra42d7d8  
    9090{
    9191        get_for_each_data_t *data = (get_for_each_data_t *)raw_data;
    92         bool equal = bithenge_node_equal(key, data->key);
     92        bool equal;
     93        int rc = bithenge_node_equal(&equal, key, data->key);
    9394        bithenge_node_dec_ref(key);
     95        if (rc != EOK)
     96                return rc;
    9497        if (equal) {
    9598                *data->out = value;
     
    348351 * internal nodes. Takes ownership of nothing.
    349352 * @memberof bithenge_node_t
     353 * @param[out] out Holds whether the nodes are equal.
    350354 * @param a, b Nodes to compare.
    351  * @return Whether the nodes are equal. If an error occurs, returns false.
     355 * @return EOK on success or an error code from errno.h.
    352356 * @todo Add support for internal nodes.
    353357 */
    354 bool bithenge_node_equal(bithenge_node_t *a, bithenge_node_t *b)
    355 {
    356         if (a->type != b->type)
    357                 return false;
     358int bithenge_node_equal(bool *out, bithenge_node_t *a, bithenge_node_t *b)
     359{
     360        if (a->type != b->type) {
     361                *out = false;
     362                return EOK;
     363        }
    358364        switch (a->type) {
    359365        case BITHENGE_NODE_INTERNAL:
    360                 return false;
     366                *out = false;
     367                return EOK;
    361368        case BITHENGE_NODE_BOOLEAN:
    362                 return a->boolean_value == b->boolean_value;
     369                *out = a->boolean_value == b->boolean_value;
     370                return EOK;
    363371        case BITHENGE_NODE_INTEGER:
    364                 return a->integer_value == b->integer_value;
     372                *out = a->integer_value == b->integer_value;
     373                return EOK;
    365374        case BITHENGE_NODE_STRING:
    366                 return !str_cmp(a->string_value.ptr, b->string_value.ptr);
     375                *out = !str_cmp(a->string_value.ptr, b->string_value.ptr);
     376                return EOK;
    367377        case BITHENGE_NODE_BLOB:
    368                 return bithenge_blob_equal(bithenge_node_as_blob(a),
     378                return bithenge_blob_equal(out, bithenge_node_as_blob(a),
    369379                    bithenge_node_as_blob(b));
    370380        }
    371         return false;
     381        return EINVAL;
    372382}
    373383
Note: See TracChangeset for help on using the changeset viewer.