diff mbox

[5/6] btrfs-progs: limit minimal num of args for btrfs-image

Message ID 1403751186-31559-5-git-send-email-guihc.fnst@cn.fujitsu.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Gui Hecheng June 26, 2014, 2:53 a.m. UTC
The btrfs-image requires at least 2 args to run,
one for the source dev/file, the other for the target dev/file.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
 btrfs-image.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Sterba June 27, 2014, 12:35 p.m. UTC | #1
On Thu, Jun 26, 2014 at 10:53:05AM +0800, Gui Hecheng wrote:
> @@ -2521,6 +2521,9 @@ int main(int argc, char *argv[])
>  	}
>  
>  	argc = argc - optind;
> +	if (argc < 2)

Please use the check_argc_min helper instead. Thanks.

> +		print_usage();
> +
>  	dev_cnt = argc - 1;
>  
>  	if (create) {
--
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
Gui Hecheng June 30, 2014, 1:47 a.m. UTC | #2
On Fri, 2014-06-27 at 14:35 +0200, David Sterba wrote:
> On Thu, Jun 26, 2014 at 10:53:05AM +0800, Gui Hecheng wrote:
> > @@ -2521,6 +2521,9 @@ int main(int argc, char *argv[])
> >  	}
> >  
> >  	argc = argc - optind;
> > +	if (argc < 2)
> 
> Please use the check_argc_min helper instead. Thanks.

Yes, actually I just wanted to prevent including "btrfs.c" in
btrfs-image.c.
I will move the check_argc_* functions into utils.c and resend. Thanks,
David.

-Gui
> 
> > +		print_usage();
> > +
> >  	dev_cnt = argc - 1;
> >  
> >  	if (create) {


--
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
diff mbox

Patch

diff --git a/btrfs-image.c b/btrfs-image.c
index e0aabfd..b13f236 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -2521,6 +2521,9 @@  int main(int argc, char *argv[])
 	}
 
 	argc = argc - optind;
+	if (argc < 2)
+		print_usage();
+
 	dev_cnt = argc - 1;
 
 	if (create) {