Skip to content

diff: fix enum value being out of allowed range#4680

Merged
ethomson merged 1 commit intolibgit2:masterfrom
pks-t:pks/diff-opts-enum
Jun 12, 2018
Merged

diff: fix enum value being out of allowed range#4680
ethomson merged 1 commit intolibgit2:masterfrom
pks-t:pks/diff-opts-enum

Conversation

@pks-t
Copy link
Copy Markdown
Member

@pks-t pks-t commented Jun 12, 2018

The C89 standard states in §6.7.2.2 "Enumeration specifiers":

The expression that defines the value of an enumeration constant shall
be an integer constant expression that has a value representable as an
int.

On most platforms, this effectively limits the range to a 32 bit signed
integer. The enum git_diff_option_t though recently gained an entry
GIT_DIFF_INDENT_HEURISTIC = (1u << 31), which breaks this limit.

Fix the issue by using a gap in git_diff_option_t's enum values. While
this has the benefit of retaining our API, it may break applications
which do not get recompiled after upgrading libgit2. But as we are
bumping the soversion on each release anyway and thus force a recompile
of dependents, this is not a problem.


Fixes #4657

The C89 standard states in §6.7.2.2 "Enumeration specifiers":

> The expression that defines the value of an enumeration constant shall
> be an integer constant expression that has a value representable as an
> int.

On most platforms, this effectively limits the range to a 32 bit signed
integer. The enum `git_diff_option_t` though recently gained an entry
`GIT_DIFF_INDENT_HEURISTIC = (1u << 31)`, which breaks this limit.

Fix the issue by using a gap in `git_diff_option_t`'s enum values. While
this has the benefit of retaining our API, it may break applications
which do not get recompiled after upgrading libgit2. But as we are
bumping the soversion on each release anyway and thus force a recompile
of dependents, this is not a problem.
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.

2 participants