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

lib: Fix unchecked return value #4361

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ShubhamDesai
Copy link
Contributor

@ShubhamDesai ShubhamDesai commented Sep 21, 2024

This pull request address "unchecked return value from library". The issue is identified by coverity scan (CID : 1207295, 1207291,1207292,1207294, 1207293).

All instances of remove(filename) are replaced with

if (remove(filename) != 0) {
            G_fatal_error(_("Unable to remove file %s"), filename);
}

@github-actions github-actions bot added vector Related to vector data processing C Related code is in C libraries labels Sep 21, 2024
@ShubhamDesai ShubhamDesai changed the title Check return value lib: Fix unchecked return value Sep 21, 2024
@ShubhamDesai
Copy link
Contributor Author

not sure whether to use G_warning or G_fatal_error

@wenzeslaus
Copy link
Member

Warning versus error is not clear to me either. RTreeNewIndex gets file descriptor from an open call on a temporary file name, but then the file is deleted. I understand this is cleanup, but the behavior is not clear to me and so I can't decide on whether ignoring, warning, or erroring is the right thing to do.

@ShubhamDesai
Copy link
Contributor Author

Warning versus error is not clear to me either. RTreeNewIndex gets file descriptor from an open call on a temporary file name, but then the file is deleted. I understand this is cleanup, but the behavior is not clear to me and so I can't decide on whether ignoring, warning, or erroring is the right thing to do.

Initially i used G_fatal_error so with that all test cases passed on Mac and ubuntu but failed on Windows.
when i checked the testcases most of them displayed error message with Unable to remove file.
i think because in windows systems a file cannot be removed without closing it. So added another check where first file descriptor is closed and then an attempt is made to remove the file.

Anyways for now with G_fatal i could identify the issue for closing the file descriptor and then attempt to remove

@wenzeslaus
Copy link
Member

i think because in windows systems a file cannot be removed without closing it.

Great catch. Closing seems indeed appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C libraries vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants