From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiqZ-0002c9-BP for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEiqT-0000su-7l for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEiqS-0000sc-Ov for qemu-devel@nongnu.org; Fri, 23 Jan 2015 13:20:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0NIKYiI020162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 23 Jan 2015 13:20:35 -0500 From: Kevin Wolf Date: Fri, 23 Jan 2015 19:20:15 +0100 Message-Id: <1422037218-31855-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1422037218-31855-1-git-send-email-kwolf@redhat.com> References: <1422037218-31855-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 09/12] block: mirror - change string allocation to 2-bytes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Jeff Cody 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 Signed-off-by: Kevin Wolf --- 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; -- 1.8.3.1