Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
timdawborn opened this issue Feb 9, 2015 · 0 comments · Fixed by #33

Comments

@timdawborn
Copy link
Contributor

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants