Re: [PATCH] wipefs: new command

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

 



Hi!

On Mon, 2009-10-05 at 15:17:04 +0200, Karel Zak wrote:
[...]
> diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
> new file mode 100644
> index 0000000..65ac049
> --- /dev/null
> +++ b/misc-utils/wipefs.c
> @@ -0,0 +1,373 @@
[...]
> +static void
> +print_pretty(struct wipe_desc *wp, int line)
> +{
> +	if (!line) {
> +		fprintf(stdout, "offset               type\n");
> +		fprintf(stdout, "----------------------------------------------------------------\n");
> +	}
> +
> +	fprintf(stdout, "0x%-17jx  %s   [%s]", wp->offset, wp->type, wp->usage);
> +
> +	if (wp->label && *wp->label)
> +		fprintf(stdout, "\n%27s %s", "LABEL:", wp->label);
> +	if (wp->uuid)
> +		fprintf(stdout, "\n%27s %s", "UUID: ", wp->uuid);
> +	fputs("\n\n", stdout);
> +}

Why not just printf (and puts w/ one less '\n')?

[...]

> +static inline void *xmalloc(size_t sz)
[...]
> +static inline char *xstrdup(const char *s)
[...]
> +static void __attribute__((__noreturn__)) usage(FILE *out)

Most of the others functions have the return type and specifiers on a
different line.

> +{
> +	fprintf(out, _("Usage: %s [options] <filename>\n\nOptions:\n"),
> +			program_invocation_short_name);
> +
> +	fprintf(out, _(
> +	" -a, --all           wipe all magic strings (BE CAREFUL!)\n"
> +	" -f, --fake          everything to be done except for the write() call\n"

Even if mount has the same option, it feels a bit confusing, most of
the time -f tends to be used for --force, and usually --fake is
spelled -n, --dry-run or --no-act (less so --simulate).

> +	" -h, --help          this help\n"
> +	" -o, --offset <num>  offset to erase, in bytes\n"
> +	" -p, --parsable      print out in parsable instead of printable format\n"));
> +
> +	fprintf(out, _("\nFor more information see wipefs(1).\n"));
> +
> +	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
> +}
[...]
> +int
> +main(int argc, char **argv)
> +{
> +	struct wipe_desc *wp = NULL;
> +	int c, all = 0, has_offset = 0, fake = 0, mode = 0;
> +	char *fname;

Make this const?

regards,
guillem
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" 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