On Tue, Jun 23, 2015 at 02:30:06PM -0700, Omar Sandoval wrote:
> > No need to introduce the wrappers, it's enough to add an alternative
> > usage string and the callback function will be the same. Also please
> > keep the aliased entries next to each other.
>
> So the reason I did that way is that this:
>
> static int cmd_rm_dev(int argc, char **argv)
> {
> char *mntpnt;
> int i, fdmnt, ret=0, e;
> DIR *dirstream = NULL;
>
> if (check_argc_min(argc, 3))
> usage(cmd_rm_dev_usage);
>
> would use the same usage string for both commands. E.g., if you do
> "btrfs device delete", the usage string would say
> "btrfs device remove...". That's a small cosmetic issue, but what do you
> think?
Ah right, I forgot about the separate usage string. We'll have to pass
it to the callback somehow in general, as it is printed eg. in the
'default:' branch of the geopt switch loop. The alias wrappers are
probably inevitable:
{ "delete", cmd_device_delete, cmd_device_delete_usage, NULL, 0 },
{ "remove", cmd_device_remove, cmd_device_remove_usage, NULL, 0 },
int cmd_device_delete(int argc, char **argv) {
return _cmd_device_delete(argc, argv, cmd_device_delete_usage);
}
int cmd_device_remove(int argc, char **argv) {
return _cmd_device_delete(argc, argv, cmd_device_remove_usage);
}
This follows a pattern so we can add a macro wrapper eventually if this
proves to be the best option.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html