From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDdgB-0006m6-Q6 for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDdg4-000496-US for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDdg4-00048o-Mi for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:24 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0KIbNb9024651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 20 Jan 2015 13:37:23 -0500 Message-ID: <54BEA060.5010607@redhat.com> Date: Tue, 20 Jan 2015 13:37:20 -0500 From: John Snow MIME-Version: 1.0 References: <943d55a006aab912af62bbb89833a48baba2d69c.1421768887.git.jcody@redhat.com> In-Reply-To: <943d55a006aab912af62bbb89833a48baba2d69c.1421768887.git.jcody@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 5/6] block: mirror - change string allocation to 2-bytes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com On 01/20/2015 12:31 PM, Jeff Cody wrote: > The backing_filename string in mirror_run() is only used to check > for a NULL string, so we don't need to allocate 1024 bytes (or, later, > PATH_MAX bytes), when we only need to copy the first 2 characters. > > We technically only need 1 byte, as we are just checking for NULL, but > since backing_filename[] is populated by bdrv_get_backing_filename(), a > string size of 1 will always only return '\0'; > > Signed-off-by: Jeff Cody > --- > block/mirror.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 9019d1b..4056164 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -378,7 +378,8 @@ static void coroutine_fn mirror_run(void *opaque) > int64_t sector_num, end, sectors_per_chunk, length; > uint64_t last_pause_ns; > BlockDriverInfo bdi; > - char backing_filename[1024]; > + char backing_filename[2]; /* we only need 2 characters because we are only > + checking for a NULL string */ > int ret = 0; > int n; > > Reviewed-by: John Snow