603468ea | 28-Sep-2015 |
Tomohiro Kusumi <kusumi.tomohiro@gmail.com> |
usr.bin/undo: Fix error handling
As mentioned in the previous commit, collect_history() should set error variable to errno when open(2) failed.
This commit does this by adding a new wrapper functio
usr.bin/undo: Fix error handling
As mentioned in the previous commit, collect_history() should set error variable to errno when open(2) failed.
This commit does this by adding a new wrapper function for collect_history() and renaming the existing collect_history() to __collect_history(). The renamed collect_history() takes const char* instead of fd and updates error if open(2) fails.
This is at least better although the error message changed by the previous commit is still there without strerror().
show more ...
|
827bb210 | 28-Sep-2015 |
Tomohiro Kusumi <kusumi.tomohiro@gmail.com> |
usr.bin/undo: Fix ambiguous and/or wrong error message
printf("%s: ITERATE ENTIRE HISTORY: %s\n", filename, strerror(error)); in doiterate() doesn't necessary show an appropriate error message.
The
usr.bin/undo: Fix ambiguous and/or wrong error message
printf("%s: ITERATE ENTIRE HISTORY: %s\n", filename, strerror(error)); in doiterate() doesn't necessary show an appropriate error message.
There are several collect_history() calls prior to printf() and this printf() is only showing the result of the last one. Also from the way collect_history() is being used, open(2) failure doesn't set error to errno value (error remains 0). This results in printf() showing "Undefined error: 0" for an invalid path and possibly hiding the real errno prior to the last collection.
This commit changes it to "No UNDO history found" without strerror(), which is never insane. The whole error handling needs to be changed in order to show an error message that is right and makes sense in every situation.
===== e.g. undo -i with invalid path # undo -i /not/existing/path /not/existing/path: ITERATE ENTIRE HISTORY: Undefined error: 0
show more ...
|
791d7504 | 27-Sep-2015 |
Tomohiro Kusumi <kusumi.tomohiro@gmail.com> |
usr.bin/undo: Use CMD_ITERATEALL
CMD_ITERATEALL hasn't been used although -i and -a set cmd to CMD_ITERATEALL. This makes doiterate() less readable. Change (A) to (B) to make it more readable and ma
usr.bin/undo: Use CMD_ITERATEALL
CMD_ITERATEALL hasn't been used although -i and -a set cmd to CMD_ITERATEALL. This makes doiterate() less readable. Change (A) to (B) to make it more readable and maintainable. No funcional changes.
=====(A) if (cmd == CMD_DUMP) { ... } else if (RB_ROOT(&tse_tree)) { ... } else { fprintf(stderr, ...); }
=====(B) switch (cmd) { case CMD_DUMP: doiterate_dump(); break; case CMD_ITERATEALL: doiterate_iterall(); break; }
show more ...
|
7fb4fc88 | 26-Sep-2015 |
Tomohiro Kusumi <kusumi.tomohiro@gmail.com> |
usr.bin/undo: Remove redundant history collection
collect_history(fd, &error, &tse_tree); is done right before this unconditionally. If the previous collect were empty, this collect after if(cmd ==
usr.bin/undo: Remove redundant history collection
collect_history(fd, &error, &tse_tree); is done right before this unconditionally. If the previous collect were empty, this collect after if(cmd == CMD_DUMP) will most likely be empty.
(It also doesn't really matter if the result has changed before and after if(cmd == CMD_DUMP) conditional since that's not what this program cares about anyway)
Also see 3260eed4.
show more ...
|
91b6127f | 26-Sep-2015 |
Tomohiro Kusumi <kusumi.tomohiro@gmail.com> |
usr.bin/undo: Rename UNDO_FLAG_SETTID[12] to UNDO_FLAG_TID_INDEX[12]
"SETTID[12]" doen't represent what these macros are used for, but rather confusing as it sounds like it has something to do with
usr.bin/undo: Rename UNDO_FLAG_SETTID[12] to UNDO_FLAG_TID_INDEX[12]
"SETTID[12]" doen't represent what these macros are used for, but rather confusing as it sounds like it has something to do with the real transaction id.
"SETTID[12]" means tid field isn't hammer's transaction id, but is placeholder index, so it should have "INDEX" somewhere in its name.
See 965778c8 for these two macros.
show more ...
|
d9f36294 | 16-Nov-2009 |
Sascha Wildner <saw@online.de> |
undo.1: Add some words about the new fake transaction id warning.
Suggested-by: polachok
While here, add an "EXIT STATUS" section and fix a sentence about hammer synctid (filesystem argument is not
undo.1: Add some words about the new fake transaction id warning.
Suggested-by: polachok
While here, add an "EXIT STATUS" section and fix a sentence about hammer synctid (filesystem argument is not optional).
show more ...
|