From: Ian Jackson Subject: Re: [PATCH] xl: fix off-by-one mistake in block-attach handler Date: Tue, 21 Sep 2010 16:14:49 +0100 Message-ID: <19608.52201.595450.682850@mariner.uk.xensource.com> References: <4C98AF750200007800018169@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4C98AF750200007800018169@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Jan Beulich writes ("[Xen-devel] [PATCH] xl: fix off-by-one mistake in block-attach handler"): > Signed-off-by: Jan Beulich > > --- 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.