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

release: Add sanity checks at beginning of each function #464

Merged
merged 1 commit into from
Feb 10, 2023
Merged

release: Add sanity checks at beginning of each function #464

merged 1 commit into from
Feb 10, 2023

Conversation

tintou
Copy link
Contributor

@tintou tintou commented Feb 7, 2023

Allows to fail with a loud message on what happened before an actual issue.

src/as-release.c Outdated Show resolved Hide resolved
@@ -273,6 +285,9 @@ as_release_set_version (AsRelease *release, const gchar *version)
gint
as_release_vercmp (AsRelease *rel1, AsRelease *rel2)
{
g_return_val_if_fail (AS_IS_RELEASE (rel1), 0);
g_return_val_if_fail (AS_IS_RELEASE (rel2), 0);
Copy link
Owner

Choose a reason for hiding this comment

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

Those two checks aren't needed, as as_release_get_version already verifies the input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still helps the consumer to know that it is the content that they passed to vercmp that is wrong and also to know if it is rel1 or rel2

src/as-release.c Outdated Show resolved Hide resolved
src/as-release.c Outdated Show resolved Hide resolved
src/as-release.c Outdated Show resolved Hide resolved
@ximion
Copy link
Owner

ximion commented Feb 8, 2023

Thanks! That must have been quite a bit of work to add these - some newer public API has these checks, while they are generally omitted from private and internal API (with some exceptions) as well as older public API (the latter because of laziness, old conventions, and the thought that the checks won't be needed).

Allows to fail with a loud message on what happened before an actual issue.
@tintou
Copy link
Contributor Author

tintou commented Feb 9, 2023

For context, we had a crash in AppCenter on our launch day elementary/appcenter#1993 which could have just been a warning with this MR 🙂

@ximion ximion merged commit 46c4e55 into ximion:master Feb 10, 2023
@ximion
Copy link
Owner

ximion commented Feb 10, 2023

For context, we had a crash in AppCenter on our launch day elementary/appcenter#1993 which could have just been a warning with this MR slightly_smiling_face

I assumed there was a story like this behind this PR :-D
Thanks for the patch!

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