Re: [PATCH] fdisk: more meaningful error messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 02, 2011 at 10:59:04PM +0100, Francesco Cosoleto wrote:
> 
> Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
> ---
>  fdisk/fdisk.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
> index 5a69437..60a6f3a 100644
> --- a/fdisk/fdisk.c
> +++ b/fdisk/fdisk.c
> @@ -274,23 +274,23 @@ void fatal(enum failure why) {

 I think that the ideal solution is to use the fatal() function only for 
 subset of errors, so:

 - replace fatal(usage) with a regular usage() function (see for example
   sys-utils/fsfreeze.c)
 - replace fatal(out_of_memory) with lib/xalloc.h

>  		case unable_to_open:
>  			snprintf(error, sizeof(error),
> -				 _("Unable to open %s\n"), disk_device);
> +				 _("Unable to open %s: %m\n"), disk_device);
>  			break;
>  		case unable_to_read:
>  			snprintf(error, sizeof(error),
> -				 _("Unable to read %s\n"), disk_device);
> +				 _("Unable to read %s: %m\n"), disk_device);
>  			break;
>  		case unable_to_seek:
>  			snprintf(error, sizeof(error),
> -				_("Unable to seek on %s\n"),disk_device);
> +				_("Unable to seek on %s: %m\n"), disk_device);
>  			break;
>  		case unable_to_write:
>  			snprintf(error, sizeof(error),
> -				_("Unable to write %s\n"), disk_device);
> +				_("Unable to write %s: %m\n"), disk_device);
>  			break;
>  		case ioctl_error:
>  			snprintf(error, sizeof(error),
> -				 _("BLKGETSIZE ioctl failed on %s\n"),
> +				 _("BLKGETSIZE ioctl failed on %s: %m\n"),
>  				disk_device);
>  			break;


 use err() from <err.h> rather than snprintf(%m)

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux