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

Add per-crate and per-object configuration to trust return value nullability #970

Merged

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Oct 17, 2020

This has to be used carefully as many libraries forgot to put
nullability annotations on return values, which then causes a panic if
an unexpected NULL is returned.


CC @GuillaumeGomez @EPashkin @sophie-h

With this you can check what kind of changes are generated when trusting the gir files, and then report any missing nullable annotations to the C libraries.

@GuillaumeGomez
Copy link
Member

I'm not sure this is a good idea to have such a setting... In any case, please put a multi-line warning (on the console when running gir with this setting) to say that it needs to be use with a lot of caution.

@sophie-h
Copy link
Contributor

As I said in the gtk issue, I think for libraries like gtk this feature would only be realistic on a per .c-file/class basis. Otherwise we would have to check thousands of functions before being able to use this feature.

@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020 via email

@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020 via email

@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020 via email

@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020

@GuillaumeGomez Also following https://gitlab.gnome.org/GNOME/gtk/-/issues/3267#note_937101 this is basically the only way forward here. We can't change gobject-introspection and have to live with how wonderfully broken reality is :)

@sdroege sdroege force-pushed the trust_return_value_nullability branch from a0ab623 to 908a457 Compare October 17, 2020 16:15
…ability

This has to be used carefully as many libraries forgot to put
`nullability` annotations on return values, which then causes a panic if
an unexpected `NULL` is returned.
@sdroege sdroege force-pushed the trust_return_value_nullability branch from 908a457 to 3303549 Compare October 17, 2020 16:16
@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020

@sophie-h This can now also be configured per object if you want to give it a try

@sdroege sdroege changed the title Add per-crate configuration to trust return value nullability Add per-crate and per-object configuration to trust return value nullability Oct 17, 2020
@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020

@GuillaumeGomez This is also ready for review now

@sophie-h
Copy link
Contributor

I'm very happy about this. Set one object to trust_return_value_nullability, checked the diff in src/auto, found missing annotations in gtk code. I think this is a good way forward.

@sdroege
Copy link
Member Author

sdroege commented Oct 17, 2020

I'm very happy about this. Set one object to trust_return_value_nullability, checked the diff in src/auto, found missing annotations in gtk code. I think this is a good way forward.

Thanks for taking care of that :) I'll go through gio one of these days unless you want to do that.

@sophie-h
Copy link
Contributor

I'll go through gio one of these days unless you want to do that.

No, thanks :) Not sure if I will have a lot of time for that.

@sdroege
Copy link
Member Author

sdroege commented Oct 19, 2020

No, thanks :) Not sure if I will have a lot of time for that.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1708 . I'll wait until that is in a GLib release, otherwise this needs too many overrides in Gir.toml.

@sophie-h
Copy link
Contributor

Is there anything to be done here or can this be merged?

@sdroege
Copy link
Member Author

sdroege commented Oct 20, 2020

It needs @GuillaumeGomez or @EPashkin to review it :)

Copy link
Member

@EPashkin EPashkin left a comment

Choose a reason for hiding this comment

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

@sdroege Thanks, I was great idea.

Please add PR with use matches! in separate MR sometime (see CI clippy errors)

@sdroege
Copy link
Member Author

sdroege commented Oct 20, 2020

Please add PR with use matches! in separate MR sometime (see CI clippy errors)

@GuillaumeGomez already did that here: #973

Let's get this in then? :)

@sdroege
Copy link
Member Author

sdroege commented Oct 26, 2020

@GuillaumeGomez Can you take a look at this? The new GLib release fixes all the remaining missing annotations, so we could have a clean version of GLib now with improved API.

@GuillaumeGomez
Copy link
Member

After a discussion between @sdroege and I, I finally agreed on his position so let's get this in!

@GuillaumeGomez GuillaumeGomez merged commit 49cfee1 into gtk-rs:master Oct 26, 2020
@sdroege
Copy link
Member Author

sdroege commented Oct 26, 2020

Thanks!

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.

4 participants