Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Return int from non-free functions #5365

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

Merged
merged 10 commits into from
Jan 24, 2020
Merged

Return int from non-free functions #5365

merged 10 commits into from
Jan 24, 2020

Conversation

ethomson
Copy link
Member

Return int from all the functions that aren't dispose or free functions. This allows us to gracefully fail on bad inputs (instead of an assert or crashing with a segmentation fault).

Only functions that cannot fail will remain void. This includes:

  • *_dispose and *_free: which should gracefully take NULL pointers, ignore them, and continue.
  • giterr_clear: which cannot fail (since it just updates pointers in global state)
  • giterr_set_oom: which cannot fail (since it just updates pointers in global state)

Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor style nits about indentation, but otherwise this looks good to me. Please feel free to merge as soon as those are fixed!

git_index_name_clear(index);
if ((error = git_index_name_clear(index)) < 0 ||
(error = git_index_reuc_clear(index)) < 0)
goto done;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indentation

git_index_reuc_clear(index);
if ((error = git_index_name_clear(index)) < 0 ||
(error = git_index_reuc_clear(index)) < 0)
goto done;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well

Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
Stop returning a void for functions, future-proofing them to allow them
to fail.
@ethomson
Copy link
Member Author

Fixed! Thanks for the review @pks-t

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 this pull request may close these issues.

3 participants