Skip to content

Documentation on the return value of crfsuite_create_instance does not match implementation. #32

Closed
@timdawborn

Description

@timdawborn

The documentation for crfsuite_create_instance currently states that 0 is returned upon success (like the rest of the API), but the implementation returns 1 upon success due to the use of == 0 in the implementation to perform a conditional execution via short-circuit evaluation of the first half of the expression.

From current latest revision (a6f144b) of lib/crf/src/crfsuite.c:

int crfsuite_create_instance(const char *iid, void **ptr)
{
    int ret = 
        crf1de_create_instance(iid, ptr) == 0 ||
        crfsuite_dictionary_create_instance(iid, ptr) == 0;

    return ret;
}

Suggested correction:

int crfsuite_create_instance(const char *iid, void **ptr)
{
    int ret = crf1de_create_instance(iid, ptr);
    if (ret != 0)
      ret = crfsuite_dictionary_create_instance(iid, ptr);
    return ret;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions