From patchwork Thu Jan 22 13:03:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 431813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 63B72140216 for ; Fri, 23 Jan 2015 00:08:15 +1100 (AEDT) Received: from localhost ([::1]:53230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEHUb-0007uV-HK for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 08:08:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEHQJ-0002UC-MD for qemu-devel@nongnu.org; Thu, 22 Jan 2015 08:03:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEHQI-0000Xy-T7 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 08:03:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEHQI-0000Xa-Lp for qemu-devel@nongnu.org; Thu, 22 Jan 2015 08:03:46 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MD3jHX011468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 22 Jan 2015 08:03:45 -0500 Received: from localhost (ovpn-112-98.phx2.redhat.com [10.3.112.98]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MD3hSK023091 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Thu, 22 Jan 2015 08:03:44 -0500 From: Jeff Cody To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 08:03:29 -0500 Message-Id: <39547db197b5ffe65a8da64801e501a8814940ad.1421931293.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, jsnow@redhat.com, famz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v3 5/6] block: mirror - change string allocation to 2-bytes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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'; Reviewed-by: Stefan Hajnoczi Reviewed-by: John Snow 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;