From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQYLu-00021q-Kk for qemu-devel@nongnu.org; Mon, 30 Sep 2013 03:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQYLo-0006X7-MU for qemu-devel@nongnu.org; Mon, 30 Sep 2013 03:57:10 -0400 Date: Mon, 30 Sep 2013 09:57:03 +0200 From: Kevin Wolf Message-ID: <20130930075703.GA2507@dhcp-200-207.str.redhat.com> References: <1380362114-29476-1-git-send-email-sw@weilnetz.de> <52488325.5090702@msgid.tls.msk.ru> <52488A4E.5010902@weilnetz.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52488A4E.5010902@weilnetz.de> Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-trivial , Michael Tokarev , qemu-devel , Stefan Hajnoczi Am 29.09.2013 um 22:15 hat Stefan Weil geschrieben: > Am 29.09.2013 21:44, schrieb Michael Tokarev: > > 28.09.2013 13:55, Stefan Weil wrote: > [...] > >> diff --git a/blockdev.c b/blockdev.c > >> index 8aa66a9..8c83f6f 100644 > >> --- a/blockdev.c > >> +++ b/blockdev.c > >> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const > >> char *target, > >> } else { > >> switch (mode) { > >> case NEW_IMAGE_MODE_EXISTING: > >> - ret = 0; > >> break; > > > > While this one is obviously unused assignment, > > there's on more usage of `ret' variable in this > > function, -- it is to store the return value > > from bdrv_open(): > > > > ret = bdrv_open(target_bs, target, NULL, flags | > > BDRV_O_NO_BACKING, drv, > > &local_err); > > if (ret < 0) {... > > > > What's the rule about converting that into if() ? > > > > Thanks, > > > > /mjt > > Is there a rule for cases like that? This pattern is very common in QEMU > code > (several occurrences in blockdev.c). Should we eliminate the 'ret' variable? > I don't think it's worth the effort. And actually I think removing it would make the code worse (less readable). Kevin