Changeset a42d7d8 in mainline
- Timestamp:
- 2012-08-19T05:28:24Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fae4d30
- Parents:
- 1c79996
- Location:
- uspace
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bithenge/Makefile.linux
r1c79996 ra42d7d8 41 41 test.c 42 42 43 ifdef COVERAGE 44 CFLAGS += -fprofile-arcs -ftest-coverage 45 endif 46 43 47 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 44 48 -
uspace/lib/bithenge/Makefile.linux
r1c79996 ra42d7d8 46 46 tree.c 47 47 48 ifdef COVERAGE 49 CFLAGS += -fprofile-arcs -ftest-coverage 50 endif 51 52 ifdef FAILURE 53 CFLAGS += -DBITHENGE_FAILURE_ENABLE=1 54 SOURCES += failure.c 55 endif 56 48 57 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 49 58 -
uspace/lib/bithenge/blob.c
r1c79996 ra42d7d8 461 461 /** Check whether the contents of two blobs are equal. 462 462 * @memberof bithenge_blob_t 463 * @param[out] out Holds whether the blobs are equal. 463 464 * @param a, b Blobs to compare. 464 * @return Whether the blobs are equal. If an error occurs, returns false.465 */ 466 bool bithenge_blob_equal(bithenge_blob_t *a, bithenge_blob_t *b)465 * @return EOK on success, or an error code from errno.h. 466 */ 467 int bithenge_blob_equal(bool *out, bithenge_blob_t *a, bithenge_blob_t *b) 467 468 { 468 469 assert(a); … … 476 477 rc = bithenge_blob_read(a, offset, buffer_a, &size_a); 477 478 if (rc != EOK) 478 return false;479 return rc; 479 480 rc = bithenge_blob_read(b, offset, buffer_b, &size_b); 480 481 if (rc != EOK) 481 return false; 482 if (size_a != size_b || bcmp(buffer_a, buffer_b, size_a)) 483 return false; 482 return rc; 483 if (size_a != size_b || bcmp(buffer_a, buffer_b, size_a)) { 484 *out = false; 485 return EOK; 486 } 484 487 offset += size_a; 485 488 } while (size_a == sizeof(buffer_a)); 486 return true; 489 *out = true; 490 return EOK; 487 491 } 488 492 -
uspace/lib/bithenge/blob.h
r1c79996 ra42d7d8 243 243 int bithenge_new_subblob(bithenge_node_t **, bithenge_blob_t *, aoff64_t, 244 244 aoff64_t); 245 bool bithenge_blob_equal(bithenge_blob_t *, bithenge_blob_t *);245 int bithenge_blob_equal(bool *, bithenge_blob_t *, bithenge_blob_t *); 246 246 247 247 #endif -
uspace/lib/bithenge/expression.c
r1c79996 ra42d7d8 104 104 /* Check types and get values. */ 105 105 bithenge_int_t a_int = 0, b_int = 0; 106 bool a_bool = false, b_bool = false ;106 bool a_bool = false, b_bool = false, out_bool = false; 107 107 switch (self->op) { 108 108 case BITHENGE_EXPRESSION_ADD: /* fallthrough */ … … 187 187 break; 188 188 case BITHENGE_EXPRESSION_EQUALS: 189 rc = bithenge_new_boolean_node(out, bithenge_node_equal(a, b)); 189 rc = bithenge_node_equal(&out_bool, a, b); 190 if (rc != EOK) 191 break; 192 rc = bithenge_new_boolean_node(out, out_bool); 190 193 break; 191 194 case BITHENGE_EXPRESSION_NOT_EQUALS: 192 rc = bithenge_new_boolean_node(out, 193 !bithenge_node_equal(a, b)); 195 rc = bithenge_node_equal(&out_bool, a, b); 196 if (rc != EOK) 197 break; 198 rc = bithenge_new_boolean_node(out, !out_bool); 194 199 break; 195 200 case BITHENGE_EXPRESSION_AND: -
uspace/lib/bithenge/file.c
r1c79996 ra42d7d8 79 79 return ELIMIT; 80 80 if (lseek(blob->fd, offset, SEEK_SET) < 0) 81 return errno ;81 return errno == EINVAL ? EIO : EINVAL; 82 82 83 83 ssize_t amount_read; -
uspace/lib/bithenge/os.h
r1c79996 ra42d7d8 32 32 #include "linux/os.h" 33 33 #endif 34 35 #ifdef BITHENGE_FAILURE_ENABLE 36 #include "failure.h" 37 #endif -
uspace/lib/bithenge/script.c
r1c79996 ra42d7d8 731 731 } 732 732 int rc = bithenge_binary_expression(&expr, op, expr, expr2); 733 if (rc != EOK) 734 error_errno(state, rc); 733 if (rc != EOK) { 734 expr = NULL; 735 error_errno(state, rc); 736 } 735 737 } 736 738 if (state->error != EOK) { … … 940 942 int rc = bithenge_if_transform(&switch_xform, exprs[num], 941 943 xforms[num], switch_xform); 942 if (rc != EOK) 943 error_errno(state, rc); 944 if (rc != EOK) { 945 switch_xform = NULL; 946 error_errno(state, rc); 947 } 944 948 } 945 949 … … 1189 1193 if (state->error != EOK) 1190 1194 break; 1191 xforms[num] = parse_transform_no_compose(state); 1192 num++; 1195 xforms[num++] = parse_transform_no_compose(state); 1193 1196 } 1194 1197 if (state->error != EOK) { 1195 while (xforms && num --)1196 bithenge_transform_dec_ref(xforms[ num]);1198 while (xforms && num > 1) 1199 bithenge_transform_dec_ref(xforms[--num]); 1197 1200 free(xforms); 1198 1201 bithenge_transform_dec_ref(result); -
uspace/lib/bithenge/sequence.c
r1c79996 ra42d7d8 488 488 return rc; 489 489 } 490 491 rc = seq_node_init(struct_as_seq(node), &struct_node_seq_ops, inner, 492 blob, self->num_subtransforms, false); 493 if (rc != EOK) { 494 bithenge_scope_dec_ref(inner); 495 free(node); 496 return rc; 497 } 498 499 bithenge_transform_inc_ref(struct_as_transform(self)); 500 node->transform = self; 501 node->prefix = prefix; 502 490 503 /* We should inc_ref(node) here, but that would make a cycle. Instead, 491 504 * we leave it 1 too low, so that when the only remaining use of node … … 493 506 * struct_node_destroy. */ 494 507 bithenge_scope_set_current_node(inner, struct_as_node(node)); 495 496 rc = seq_node_init(struct_as_seq(node), &struct_node_seq_ops, inner,497 blob, self->num_subtransforms, false);498 508 bithenge_scope_dec_ref(inner); 499 if (rc != EOK) { 500 free(node); 501 return rc; 502 } 503 504 bithenge_transform_inc_ref(struct_as_transform(self)); 505 node->transform = self; 506 node->prefix = prefix; 509 507 510 *out = struct_as_node(node); 508 511 … … 834 837 rc = seq_node_field_offset( 835 838 node_as_seq(*out_node), &size, count); 836 if (rc != EOK)839 if (rc == EINVAL || rc == ENOENT) 837 840 break; 841 if (rc != EOK) { 842 bithenge_node_dec_ref(*out_node); 843 return rc; 844 } 838 845 *out_size = size; 839 846 } -
uspace/lib/bithenge/tree.c
r1c79996 ra42d7d8 90 90 { 91 91 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); 93 94 bithenge_node_dec_ref(key); 95 if (rc != EOK) 96 return rc; 94 97 if (equal) { 95 98 *data->out = value; … … 348 351 * internal nodes. Takes ownership of nothing. 349 352 * @memberof bithenge_node_t 353 * @param[out] out Holds whether the nodes are equal. 350 354 * @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. 352 356 * @todo Add support for internal nodes. 353 357 */ 354 bool bithenge_node_equal(bithenge_node_t *a, bithenge_node_t *b) 355 { 356 if (a->type != b->type) 357 return false; 358 int 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 } 358 364 switch (a->type) { 359 365 case BITHENGE_NODE_INTERNAL: 360 return false; 366 *out = false; 367 return EOK; 361 368 case BITHENGE_NODE_BOOLEAN: 362 return a->boolean_value == b->boolean_value; 369 *out = a->boolean_value == b->boolean_value; 370 return EOK; 363 371 case BITHENGE_NODE_INTEGER: 364 return a->integer_value == b->integer_value; 372 *out = a->integer_value == b->integer_value; 373 return EOK; 365 374 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; 367 377 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), 369 379 bithenge_node_as_blob(b)); 370 380 } 371 return false;381 return EINVAL; 372 382 } 373 383 -
uspace/lib/bithenge/tree.h
r1c79996 ra42d7d8 167 167 int bithenge_new_integer_node(bithenge_node_t **, bithenge_int_t); 168 168 int bithenge_new_string_node(bithenge_node_t **, const char *, bool); 169 bool bithenge_node_equal(bithenge_node_t *, bithenge_node_t *);169 int bithenge_node_equal(bool *, bithenge_node_t *, bithenge_node_t *); 170 170 171 171 #endif
Note:
See TracChangeset
for help on using the changeset viewer.