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

Fixes and nitpicks for e4defrag2 #2

Merged
merged 8 commits into from Aug 4, 2015

Conversation

kolyshkin
Copy link

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]

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 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
@dmonakhov dmonakhov merged commit fcd2ffd into dmonakhov:e4defrag2 Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants