Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
qemu.2059
0085-dump-simplify-write_start_flat_head.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0085-dump-simplify-write_start_flat_head.patch of Package qemu.2059
From cfc5a554fe6c192cec453db20b7c140e39e16962 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek <lersek@redhat.com> Date: Tue, 20 May 2014 13:39:42 +0200 Subject: [PATCH] dump: simplify write_start_flat_header() Currently, the function - defines and populates an auto variable of type MakedumpfileHeader - allocates and zeroes a buffer of size MAX_SIZE_MDF_HEADER (4096) - copies the former into the latter (covering an initial portion of the latter) Fill in the MakedumpfileHeader structure in its final place (the alignment is OK because the structure lives at the address returned by g_malloc0()). Approximately-suggested-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> --- dump.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dump.c b/dump.c index ac4505e..6dec8d2 100644 --- a/dump.c +++ b/dump.c @@ -711,27 +711,25 @@ static int create_vmcore(DumpState *s) static int write_start_flat_header(int fd) { - uint8_t *buf; - MakedumpfileHeader mh; + MakedumpfileHeader *mh; int ret = 0; - memset(&mh, 0, sizeof(mh)); - memcpy(mh.signature, MAKEDUMPFILE_SIGNATURE, - MIN(sizeof mh.signature, sizeof MAKEDUMPFILE_SIGNATURE)); + QEMU_BUILD_BUG_ON(sizeof *mh > MAX_SIZE_MDF_HEADER); + mh = g_malloc0(MAX_SIZE_MDF_HEADER); - mh.type = cpu_to_be64(TYPE_FLAT_HEADER); - mh.version = cpu_to_be64(VERSION_FLAT_HEADER); + memcpy(mh->signature, MAKEDUMPFILE_SIGNATURE, + MIN(sizeof mh->signature, sizeof MAKEDUMPFILE_SIGNATURE)); - buf = g_malloc0(MAX_SIZE_MDF_HEADER); - memcpy(buf, &mh, sizeof(mh)); + mh->type = cpu_to_be64(TYPE_FLAT_HEADER); + mh->version = cpu_to_be64(VERSION_FLAT_HEADER); size_t written_size; - written_size = qemu_write_full(fd, buf, MAX_SIZE_MDF_HEADER); + written_size = qemu_write_full(fd, mh, MAX_SIZE_MDF_HEADER); if (written_size != MAX_SIZE_MDF_HEADER) { ret = -1; } - g_free(buf); + g_free(mh); return ret; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor