Jan Beulich
2010-Sep-21 11:13 UTC
[Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler
Signed-off-by: Jan Beulich <jbeulich@novell.com> --- 2010-09-20.orig/tools/libxl/xl_cmdimpl.c 2010-09-15 17:59:07.000000000 +0200 +++ 2010-09-20/tools/libxl/xl_cmdimpl.c 2010-09-21 12:06:58.000000000 +0200 @@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar } disk.virtpath = argv[optind+2]; disk.unpluggable = 1; - disk.readwrite = ((argc-optind <= 2) || (argv[optind+3][0] == ''w'')); + disk.readwrite = ((argc-optind <= 3) || (argv[optind+3][0] == ''w'')); if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) { fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Sep-21 15:14 UTC
Re: [Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler
Jan Beulich writes ("[Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler"):> Signed-off-by: Jan Beulich <jbeulich@novell.com> > > --- 2010-09-20.orig/tools/libxl/xl_cmdimpl.c 2010-09-15 17:59:07.000000000 +0200 > +++ 2010-09-20/tools/libxl/xl_cmdimpl.c 2010-09-21 12:06:58.000000000 +0200 > @@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar > } > disk.virtpath = argv[optind+2]; > disk.unpluggable = 1; > - disk.readwrite = ((argc-optind <= 2) || (argv[optind+3][0] == ''w'')); > + disk.readwrite = ((argc-optind <= 3) || (argv[optind+3][0] == ''w''));This idiom is pretty nasty. Perhaps we should rewrite it to: + disk.readwrite = (argc-optind > 3) ? (argv[optind+3][0] == ''w'') : 1; or some such ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2010-Sep-21 16:05 UTC
Re: [Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler
>>> On 21.09.10 at 17:14, Ian Jackson <Ian.Jackson@eu.citrix.com> wrote: > Jan Beulich writes ("[Xen-devel] [PATCH] xl: fix off-by-one mistake in > block-attach handler"): >> Signed-off-by: Jan Beulich <jbeulich@novell.com> >> >> --- 2010-09-20.orig/tools/libxl/xl_cmdimpl.c 2010-09-15 17:59:07.000000000 +0200 >> +++ 2010-09-20/tools/libxl/xl_cmdimpl.c 2010-09-21 12:06:58.000000000 +0200 >> @@ -4280,7 +4280,7 @@ int main_blockattach(int argc, char **ar >> } >> disk.virtpath = argv[optind+2]; >> disk.unpluggable = 1; >> - disk.readwrite = ((argc-optind <= 2) || (argv[optind+3][0] == ''w'')); >> + disk.readwrite = ((argc-optind <= 3) || (argv[optind+3][0] == ''w'')); > > This idiom is pretty nasty. Perhaps we should rewrite it to: > > + disk.readwrite = (argc-optind > 3) ? (argv[optind+3][0] == ''w'') : 1; > > or some such ?Honestly, I don''t really care. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel