Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
samples: Make winapi samples unmount drives before finishing execution #421
base: master
Are you sure you want to change the base?
samples: Make winapi samples unmount drives before finishing execution #421
Changes from all commits
535e842
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code makes little sense to me; mounting E failed, so it jumps to unmounting C?
The labels should be named more appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this specific label should stay as unmount_c, it's a good enough name IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JayFoxRox What would you suggest? Personally, it doesn't bother me, imho it looks just like when a function is freeing a previous allocation before returning due to an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure; I'd probably cause a fatal error if anything fails to init (to avoid having to do conditional cleanup).
If conditional cleanup is mandatory I'd probably have a boolean which stores which drives were mounted correctly (
mountedC
/mountedE
), I'd then have a generic cleanup function at the end of the scope which unmounts it (a single label calledcleanup
, which would conditionally deal with cleanup).In a real application I'd probably have something like
atexit
/ destructors which deal with this (= no labels); also ensures proper order of destruction without having to think about it.Probably not practical for a sample because it adds too much complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially with a generic label such as
cleanup
now, I think this should use booleans / keep track of it and handle everything incleanup
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a highly local variable, I don't see a benefit for putting it at function scope?
If you declare it where it's used it also won't require any additional comment.
If the variable is redeclared, you should use different names to differentiate them; in this particular sample this only seems to happen after
FindNextFile
, so you could probably doDWORD findFileError = GetLastError()
in that instance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't done everywhere