forked from tytso/e2fsprogs
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
Fixes and nitpicks for e4defrag2 #2
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kolyshkin
added a commit
to kolyshkin/e2fsprogs
that referenced
this pull request
Jul 25, 2015
There are two ways to allocate data for name_to_handle_at(): 1. Allocate the maximum possible size beforehand (that would be sizeof(struct file_handle + MAX_HANDLE_SZ). 2. Allocate the sizeof(struct file_handle), ask the kernel for the actual handle size, do realloc (as shown in EXAMPLE section of name_to_handle_at(2) man page). Here we did a mix of both approaches -- allocated the maximum size, then asked the kernel for the required size, then did nothing (i.e. not reallocated the structure). We need to choose one way or another. As currently MAX_HANDLE_SZ is 128, I don't think we should hassle with the dmonakhov#2 approach, so let's just allocate the max size and use it. Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
These are mostly typos, plus some whitespace nitpicks, missing commas, missing articles and so on. Of particular interest here is the amount of ways to misspell the word "defragmentation". Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Argument mntid of name_to_handle_at() should be "int", not "unsigned int". Fixes a bunch of compiler warnings like this one: e4defrag2.c:890:44: warning: pointer targets in passing argument 4 of ‘name_to_handle_at’ differ in signedness [-Wpointer-sign] ret = name_to_handle_at(dirfd, name, fhp, &mnt, 0); ^ In file included from /usr/include/bits/fcntl.h:61:0, from /usr/include/fcntl.h:35, from e4defrag2.c:25: /usr/include/bits/fcntl-linux.h:406:12: note: expected ‘int *’ but argument is of type ‘unsigned int *’ extern int name_to_handle_at (int __dfd, const char *__name, ^ Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Use a single tab to make output more compact (and fit into 80 columns). Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Hooray, found one more variant of "defragmentation" typo! Also, add a missing \n after the last line of usage() output Signed-off-by: Kir Kolyshkin <kir@openvz.org>
There are two ways to allocate data for name_to_handle_at(): 1. Allocate the maximum possible size beforehand (that would be sizeof(struct file_handle + MAX_HANDLE_SZ). 2. Allocate the sizeof(struct file_handle), ask the kernel for the actual handle size, do realloc (as shown in EXAMPLE section of name_to_handle_at(2) man page). Here we did a mix of both approaches -- allocated the maximum size, then asked the kernel for the required size, then did nothing (i.e. not reallocated the structure). We need to choose one way or another. As currently MAX_HANDLE_SZ is 128, I don't think we should hassle with the dmonakhov#2 approach, so let's just allocate the max size and use it. Signed-off-by: Kir Kolyshkin <kir@openvz.org>
When printing errors (such as parameter parsing errors etc) from main(), don't use __func__, use program_name instead. Also, be consistent and always prepend program_name when printing errors from main(). Was: main: can not open directory <...> Now: e4defrag2: can not open directory <...> Signed-off-by: Kir Kolyshkin <kir@openvz.org>
There are many places in the code checking a pointer for not being NULL and printing "Can't allocate memory" error if it is. Let's unify all such checks by using a macro. End result is: - cleaner code - uniform messages Signed-off-by: Kir Kolyshkin <kir@openvz.org>
kolyshkin
force-pushed
the
e4defrag2-fixes
branch
from
July 25, 2015 01:56
9e9bfc3
to
43d6c95
Compare
kolyshkin
changed the title
Trivial nitpicks for e4defrag2
Fixes and nitpicks for e4defrag2
Jul 25, 2015
dmonakhov
added a commit
that referenced
this pull request
Aug 4, 2015
Fixes and nitpicks for e4defrag2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Dima,
I took a quick look into e4defrag2 and made a few trivial fixes. Then some more...
I hope you still work on it and find the fixes useful.
[v2: consolidated some patches; more typos found]