Goffredo Baroncelli
2010-Dec-20 20:06 UTC
[TRIVIAL][PATCH] Improve error handling in the btrfs command
Hi Chris, below is enclosed a trivial patch, which has the aim to improve the error reporting of the "btrfs" command. You can pull from http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git branch strerror I changed every printf("some-error") to something like: e = errno; fprintf(stderr, "ERROR: .... - %s", strerror(e)); so: 1) all the error are reported to standard error 2) At the end of the message is printed the error as returned by the system. The change is quite simple, I replaced every printf("some-error") to the line above. I don''t touched anything other. I also integrated a missing "printf" on the basis of the Ben patch. This patch leads the btrfs command to be more "user friendly" :-) Regards G.Baroncelli btrfs-list.c | 40 ++++++++++++++++++++++-------- btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- utils.c | 6 ++++ 3 files changed, 89 insertions(+), 34 deletions(-) -- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack@inwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
Chris Samuel
2010-Dec-20 22:42 UTC
Re: [TRIVIAL][PATCH] Improve error handling in the btrfs command
On 21/12/10 07:06, Goffredo Baroncelli wrote:> below is enclosed a trivial patch, which has the aim to > improve the error reporting of the "btrfs" command.Any reason to not just use perror() ? -- Chris Samuel : http://www.csamuel.org/ : Melbourne, VIC -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Goffredo Baroncelli
2010-Dec-20 22:53 UTC
Re: [TRIVIAL][PATCH] Improve error handling in the btrfs command
On Monday, 20 December, 2010, you (Chris Samuel) wrote:> On 21/12/10 07:06, Goffredo Baroncelli wrote: > > > below is enclosed a trivial patch, which has the aim to > > improve the error reporting of the "btrfs" command. > > Any reason to not just use perror() ?Some time I needed to add other info, so perror(3) may not be sufficient.. -- gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack@inwind.it> Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Chris Samuel
2010-Dec-21 00:29 UTC
Re: [TRIVIAL][PATCH] Improve error handling in the btrfs command
On 21/12/10 09:53, Goffredo Baroncelli wrote:> Some time I needed to add other info, so perror(3) may not be sufficient..Ah, of course, and you cannot rely on safely snprintf()''ing something into the string would get passed to perror() because that could easily change errno if something went wrong internally. All the best, Chris -- Chris Samuel : http://www.csamuel.org/ : Melbourne, VIC -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html