Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/bithenge/src/expression.c

    r6cd10ac rb7fd2a0  
    4848 * @param[in] ops Operations provided by the expression.
    4949 * @return EOK or an error code from errno.h. */
    50 int bithenge_init_expression(bithenge_expression_t *self,
     50errno_t bithenge_init_expression(bithenge_expression_t *self,
    5151    const bithenge_expression_ops_t *ops)
    5252{
     
    8888}
    8989
    90 static int binary_expression_evaluate(bithenge_expression_t *base,
     90static errno_t binary_expression_evaluate(bithenge_expression_t *base,
    9191    bithenge_scope_t *scope, bithenge_node_t **out)
    9292{
    93         int rc;
     93        errno_t rc;
    9494        binary_expression_t *self = expression_as_binary(base);
    9595        bithenge_node_t *a, *b;
     
    250250 * @param b The second operand.
    251251 * @return EOK on success or an error code from errno.h. */
    252 int bithenge_binary_expression(bithenge_expression_t **out,
     252errno_t bithenge_binary_expression(bithenge_expression_t **out,
    253253    bithenge_binary_op_t op, bithenge_expression_t *a,
    254254    bithenge_expression_t *b)
    255255{
    256         int rc;
     256        errno_t rc;
    257257        binary_expression_t *self = malloc(sizeof(*self));
    258258        if (!self) {
     
    283283/***************** in_node_expression                        *****************/
    284284
    285 static int in_node_evaluate(bithenge_expression_t *self,
     285static errno_t in_node_evaluate(bithenge_expression_t *self,
    286286    bithenge_scope_t *scope, bithenge_node_t **out)
    287287{
     
    306306 * @param[out] out Holds the new expression.
    307307 * @return EOK on success or an error code from errno.h. */
    308 int bithenge_in_node_expression(bithenge_expression_t **out)
     308errno_t bithenge_in_node_expression(bithenge_expression_t **out)
    309309{
    310310        if (bithenge_should_fail())
     
    319319/***************** current_node_expression                   *****************/
    320320
    321 static int current_node_evaluate(bithenge_expression_t *self,
     321static errno_t current_node_evaluate(bithenge_expression_t *self,
    322322    bithenge_scope_t *scope, bithenge_node_t **out)
    323323{
     
    340340 * @param[out] out Holds the new expression.
    341341 * @return EOK on success or an error code from errno.h. */
    342 int bithenge_current_node_expression(bithenge_expression_t **out)
     342errno_t bithenge_current_node_expression(bithenge_expression_t **out)
    343343{
    344344        bithenge_expression_inc_ref(&current_node_expression);
     
    368368}
    369369
    370 static int param_expression_evaluate(bithenge_expression_t *base,
     370static errno_t param_expression_evaluate(bithenge_expression_t *base,
    371371    bithenge_scope_t *scope, bithenge_node_t **out)
    372372{
     
    390390 * @param index The index of the parameter to get.
    391391 * @return EOK on success or an error code from errno.h. */
    392 int bithenge_param_expression(bithenge_expression_t **out, int index)
    393 {
    394         int rc;
     392errno_t bithenge_param_expression(bithenge_expression_t **out, int index)
     393{
     394        errno_t rc;
    395395        param_expression_t *self = malloc(sizeof(*self));
    396396        if (!self)
     
    430430}
    431431
    432 static int const_expression_evaluate(bithenge_expression_t *base,
     432static errno_t const_expression_evaluate(bithenge_expression_t *base,
    433433    bithenge_scope_t *scope, bithenge_node_t **out)
    434434{
     
    455455 * @param node The constant.
    456456 * @return EOK on success or an error code from errno.h. */
    457 int bithenge_const_expression(bithenge_expression_t **out,
     457errno_t bithenge_const_expression(bithenge_expression_t **out,
    458458    bithenge_node_t *node)
    459459{
    460         int rc;
     460        errno_t rc;
    461461        const_expression_t *self = malloc(sizeof(*self));
    462462        if (!self) {
     
    501501}
    502502
    503 static int scope_member_expression_evaluate(bithenge_expression_t *base,
     503static errno_t scope_member_expression_evaluate(bithenge_expression_t *base,
    504504    bithenge_scope_t *scope, bithenge_node_t **out)
    505505{
     
    511511                        continue;
    512512                bithenge_node_inc_ref(self->key);
    513                 int rc = bithenge_node_get(cur, self->key, out);
     513                errno_t rc = bithenge_node_get(cur, self->key, out);
    514514                bithenge_node_dec_ref(cur);
    515515                if (rc != ENOENT) /* EOK or error */
     
    537537 * @param key The key to search for in nodes being created.
    538538 * @return EOK on success or an error code from errno.h. */
    539 int bithenge_scope_member_expression(bithenge_expression_t **out,
     539errno_t bithenge_scope_member_expression(bithenge_expression_t **out,
    540540    bithenge_node_t *key)
    541541{
    542         int rc;
     542        errno_t rc;
    543543        scope_member_expression_t *self = malloc(sizeof(*self));
    544544        if (!self) {
     
    582582}
    583583
    584 static int subblob_expression_evaluate(bithenge_expression_t *base,
     584static errno_t subblob_expression_evaluate(bithenge_expression_t *base,
    585585    bithenge_scope_t *scope, bithenge_node_t **out)
    586586{
    587587        subblob_expression_t *self = expression_as_subblob(base);
    588588        bithenge_node_t *start_node;
    589         int rc = bithenge_expression_evaluate(self->start, scope, &start_node);
     589        errno_t rc = bithenge_expression_evaluate(self->start, scope, &start_node);
    590590        if (rc != EOK)
    591591                return rc;
     
    658658 * it is relative to the start.
    659659 * @return EOK on success or an error code from errno.h. */
    660 int bithenge_subblob_expression(bithenge_expression_t **out,
     660errno_t bithenge_subblob_expression(bithenge_expression_t **out,
    661661    bithenge_expression_t *blob, bithenge_expression_t *start,
    662662    bithenge_expression_t *limit, bool absolute_limit)
    663663{
    664         int rc;
     664        errno_t rc;
    665665        subblob_expression_t *self = malloc(sizeof(*self));
    666666        if (!self) {
     
    709709}
    710710
    711 static int param_wrapper_fill_scope(param_wrapper_t *self, bithenge_scope_t
     711static errno_t param_wrapper_fill_scope(param_wrapper_t *self, bithenge_scope_t
    712712    *inner, bithenge_scope_t *outer)
    713713{
    714         int rc;
     714        errno_t rc;
    715715        int num_params = bithenge_transform_num_params(self->transform);
    716716        rc = bithenge_scope_alloc_params(inner, num_params);
     
    730730}
    731731
    732 static int param_wrapper_apply(bithenge_transform_t *base,
     732static errno_t param_wrapper_apply(bithenge_transform_t *base,
    733733    bithenge_scope_t *outer, bithenge_node_t *in, bithenge_node_t **out)
    734734{
    735735        param_wrapper_t *self = transform_as_param_wrapper(base);
    736736        bithenge_scope_t *inner;
    737         int rc = bithenge_scope_new(&inner, outer);
     737        errno_t rc = bithenge_scope_new(&inner, outer);
    738738        if (rc != EOK)
    739739                return rc;
     
    750750}
    751751
    752 static int param_wrapper_prefix_length(bithenge_transform_t *base,
     752static errno_t param_wrapper_prefix_length(bithenge_transform_t *base,
    753753    bithenge_scope_t *outer, bithenge_blob_t *in, aoff64_t *out)
    754754{
    755755        param_wrapper_t *self = transform_as_param_wrapper(base);
    756756        bithenge_scope_t *inner;
    757         int rc = bithenge_scope_new(&inner, outer);
     757        errno_t rc = bithenge_scope_new(&inner, outer);
    758758        if (rc != EOK)
    759759                return rc;
     
    770770}
    771771
    772 static int param_wrapper_prefix_apply(bithenge_transform_t *base,
     772static errno_t param_wrapper_prefix_apply(bithenge_transform_t *base,
    773773    bithenge_scope_t *outer, bithenge_blob_t *in, bithenge_node_t **out_node,
    774774    aoff64_t *out_length)
     
    776776        param_wrapper_t *self = transform_as_param_wrapper(base);
    777777        bithenge_scope_t *inner;
    778         int rc = bithenge_scope_new(&inner, outer);
     778        errno_t rc = bithenge_scope_new(&inner, outer);
    779779        if (rc != EOK)
    780780                return rc;
     
    816816 * @param params The expressions used to calculate the parameters.
    817817 * @return EOK on success or an error code from errno.h. */
    818 int bithenge_param_wrapper(bithenge_transform_t **out,
     818errno_t bithenge_param_wrapper(bithenge_transform_t **out,
    819819    bithenge_transform_t *transform, bithenge_expression_t **params)
    820820{
    821         int rc;
     821        errno_t rc;
    822822        int num_params = bithenge_transform_num_params(transform);
    823823        param_wrapper_t *self = malloc(sizeof(*self));
     
    868868}
    869869
    870 static int expression_transform_apply(bithenge_transform_t *base,
     870static errno_t expression_transform_apply(bithenge_transform_t *base,
    871871    bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)
    872872{
    873873        expression_transform_t *self = transform_as_expression(base);
    874874        bithenge_scope_t *inner;
    875         int rc = bithenge_scope_new(&inner, scope);
     875        errno_t rc = bithenge_scope_new(&inner, scope);
    876876        if (rc != EOK)
    877877                return rc;
     
    900900 * @param expr The expression to evaluate.
    901901 * @return EOK on success or an error code from errno.h. */
    902 int bithenge_expression_transform(bithenge_transform_t ** out,
     902errno_t bithenge_expression_transform(bithenge_transform_t ** out,
    903903    bithenge_expression_t *expr)
    904904{
    905         int rc;
     905        errno_t rc;
    906906        expression_transform_t *self = malloc(sizeof(*self));
    907907        if (!self) {
     
    929929/***************** inputless_transform            *****************/
    930930
    931 static int inputless_transform_prefix_length(bithenge_transform_t *base,
     931static errno_t inputless_transform_prefix_length(bithenge_transform_t *base,
    932932    bithenge_scope_t *scope, bithenge_blob_t *in, aoff64_t *out)
    933933{
     
    936936}
    937937
    938 static int inputless_transform_prefix_apply(bithenge_transform_t *base,
     938static errno_t inputless_transform_prefix_apply(bithenge_transform_t *base,
    939939    bithenge_scope_t *scope, bithenge_blob_t *in, bithenge_node_t **out_node,
    940940    aoff64_t *out_size)
     
    957957 * @param expr The expression to evaluate.
    958958 * @return EOK on success or an error code from errno.h. */
    959 int bithenge_inputless_transform(bithenge_transform_t ** out,
     959errno_t bithenge_inputless_transform(bithenge_transform_t ** out,
    960960    bithenge_expression_t *expr)
    961961{
    962         int rc;
     962        errno_t rc;
    963963        expression_transform_t *self = malloc(sizeof(*self));
    964964        if (!self) {
     
    10041004}
    10051005
    1006 static int concat_blob_evaluate_b(concat_blob_t *self)
     1006static errno_t concat_blob_evaluate_b(concat_blob_t *self)
    10071007{
    10081008        if (self->b)
    10091009                return EOK;
    10101010        bithenge_node_t *b_node;
    1011         int rc = bithenge_expression_evaluate(self->b_expr, self->scope,
     1011        errno_t rc = bithenge_expression_evaluate(self->b_expr, self->scope,
    10121012            &b_node);
    10131013        if (rc != EOK)
     
    10261026}
    10271027
    1028 static int concat_blob_size(bithenge_blob_t *base, aoff64_t *size)
     1028static errno_t concat_blob_size(bithenge_blob_t *base, aoff64_t *size)
    10291029{
    10301030        concat_blob_t *self = blob_as_concat(base);
    1031         int rc = concat_blob_evaluate_b(self);
     1031        errno_t rc = concat_blob_evaluate_b(self);
    10321032        if (rc != EOK)
    10331033                return rc;
     
    10371037}
    10381038
    1039 static int concat_blob_read(bithenge_blob_t *base, aoff64_t offset,
     1039static errno_t concat_blob_read(bithenge_blob_t *base, aoff64_t offset,
    10401040    char *buffer, aoff64_t *size)
    10411041{
    1042         int rc;
     1042        errno_t rc;
    10431043        concat_blob_t *self = blob_as_concat(base);
    10441044
     
    10651065}
    10661066
    1067 static int concat_blob_read_bits(bithenge_blob_t *base, aoff64_t offset,
     1067static errno_t concat_blob_read_bits(bithenge_blob_t *base, aoff64_t offset,
    10681068    char *buffer, aoff64_t *size, bool little_endian)
    10691069{
    1070         int rc;
     1070        errno_t rc;
    10711071        concat_blob_t *self = blob_as_concat(base);
    10721072
     
    11181118 * @param b The second blob.
    11191119 * @return EOK on success or an error code from errno.h. */
    1120 int bithenge_concat_blob(bithenge_node_t **out, bithenge_blob_t *a,
     1120errno_t bithenge_concat_blob(bithenge_node_t **out, bithenge_blob_t *a,
    11211121    bithenge_blob_t *b)
    11221122{
     
    11241124        assert(a);
    11251125        assert(b);
    1126         int rc;
     1126        errno_t rc;
    11271127        concat_blob_t *self = malloc(sizeof(*self));
    11281128        if (!self) {
     
    11601160 * @param scope The scope in which @a b_expr should be evaluated.
    11611161 * @return EOK on success or an error code from errno.h. */
    1162 int bithenge_concat_blob_lazy(bithenge_node_t **out, bithenge_blob_t *a,
     1162errno_t bithenge_concat_blob_lazy(bithenge_node_t **out, bithenge_blob_t *a,
    11631163    bithenge_expression_t *b_expr, bithenge_scope_t *scope)
    11641164{
     
    11671167        assert(b_expr);
    11681168        assert(scope);
    1169         int rc;
     1169        errno_t rc;
    11701170        concat_blob_t *self = malloc(sizeof(*self));
    11711171        if (!self) {
Note: See TracChangeset for help on using the changeset viewer.