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

Make MetadataWriter more robust #782

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jeremypw
Copy link
Collaborator

@jeremypw jeremypw commented Nov 22, 2024

  • Add some null checks
  • Remove asserts and replace with critical messages

The codebase contains a lot of places where the app just terminates due to an assertion failure. This does not seem necessary for production code and these have been replaced with critical messages or throwing an error and the subsequent code either omitted or continued as seems appropriate. If reviewers feel an assertion failure would cause user data corruption on continued use then it should be replaced with a call to AppWindow.panic which at least logs a message before terminating.

There were a few places where a null could theoretically be dereferenced.

It is difficult to know whether assertion failure or null dereferencing could occur in practice as the code is extremely convoluted.

@stsdc
Copy link
Member

stsdc commented Nov 23, 2024

At this point I'm expecting you also to approve your PR 😄

obraz

@stsdc stsdc requested a review from zeebok November 23, 2024 10:54
@jeremypw
Copy link
Collaborator Author

On further consideration it is not necessary to explicitly null check in the blacklist_file functions - the Vala compiler automatically inserts a null check. One disadvantage of relying on this is that is not immediately obvious what is returned if the parameter requirements are not met when the function signature returns something. In fact it seems that boolean functions return false (safe enough) and functions returning a pointer return null (might be unsafe).

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