[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 5/6] block: mirror - change string allocation to
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PATCH v3 5/6] block: mirror - change string allocation to 2-bytes |
Date: |
Thu, 22 Jan 2015 08:03:29 -0500 |
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 <address@hidden>
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
---
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.9.3
- [Qemu-devel] [PATCH v3 0/6] Update filename string sizes in block layer, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 1/6] block: vmdk - make ret variable usage clear, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 2/6] block: vmdk - move string allocations from stack to the heap, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 3/6] block: qapi - move string allocation from stack to the heap, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 5/6] block: mirror - change string allocation to 2-bytes,
Jeff Cody <=
- [Qemu-devel] [PATCH v3 4/6] block: remove unused variable in bdrv_commit, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 6/6] block: update string sizes for filename, backing_file, exact_filename, Jeff Cody, 2015/01/22
- Re: [Qemu-devel] [PATCH v3 0/6] Update filename string sizes in block layer, Kevin Wolf, 2015/01/23