From 40e5d6179860cb5cf9ce6cb943db4d0f21bf0a4e Mon Sep 17 00:00:00 2001 From: shermp <14854761+shermp@users.noreply.github.com> Date: Sun, 9 Jun 2019 22:46:48 +1200 Subject: [PATCH] Fix GCC errors and warnings --- src/minivhd.h | 5 +++-- src/minivhd_internal.h | 3 --- src/minivhd_io.h | 9 +++++++++ src/minivhd_manage.c | 2 ++ src/minivhd_util.c | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/minivhd_io.h diff --git a/src/minivhd.h b/src/minivhd.h index 6999f66..3178a93 100644 --- a/src/minivhd.h +++ b/src/minivhd.h @@ -25,7 +25,8 @@ typedef struct MVHDGeom { uint8_t spt; } MVHDGeom; -typedef struct MVHDMeta { +typedef struct MVHDMeta MVHDMeta; +struct MVHDMeta { FILE* f; char* filename; struct MVHDMeta* parent; @@ -37,7 +38,7 @@ typedef struct MVHDMeta { int (*read_sectors)(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); int (*write_sectors)(MVHDMeta* vhdm, int offset, int num_sectors, void* in_buff); int (*format_sectors)(MVHDMeta* vhdm, int offset, int num_sectors); -} MVHDMeta; +}; MVHDMeta* mvhd_open(const char* path, int* err); MVHDMeta* mvhd_create_fixed(const char* path, MVHDGeom geom, int* err); diff --git a/src/minivhd_internal.h b/src/minivhd_internal.h index cbf4142..e805d26 100644 --- a/src/minivhd_internal.h +++ b/src/minivhd_internal.h @@ -68,7 +68,4 @@ void mvhd_buffer_to_header(MVHDSparseHeader* header, uint8_t* buffer); void mvhd_footer_to_buffer(MVHDFooter* footer, uint8_t* buffer); void mvhd_header_to_buffer(MVHDSparseHeader* header, uint8_t* buffer); void mvhd_generate_uuid(uint8_t *uuid); -int mvhd_fixed_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); -int mvhd_sparse_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); -int mvhd_diff_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); #endif \ No newline at end of file diff --git a/src/minivhd_io.h b/src/minivhd_io.h new file mode 100644 index 0000000..30c4d5b --- /dev/null +++ b/src/minivhd_io.h @@ -0,0 +1,9 @@ +#ifndef MINIVHD_IO_H +#define MINIVHD_IO_H +#include "minivhd.h" + +int mvhd_fixed_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); +int mvhd_sparse_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); +int mvhd_diff_read(MVHDMeta* vhdm, int offset, int num_sectors, void* out_buff); + +#endif \ No newline at end of file diff --git a/src/minivhd_manage.c b/src/minivhd_manage.c index 6f78f4f..83af9fd 100644 --- a/src/minivhd_manage.c +++ b/src/minivhd_manage.c @@ -5,6 +5,7 @@ #include #include "bswap.h" #include "minivhd_internal.h" +#include "minivhd_io.h" #include "minivhd.h" static bool mvhd_file_is_vhd(FILE* f); @@ -181,6 +182,7 @@ MVHDMeta* mvhd_open(const char* path, int* err) { *err = bat_err; goto cleanup_file; } + mvhd_calc_sparse_values(vhdm); } else if (vhdm->footer.disk_type != MVHD_TYPE_FIXED) { *err = MVHD_ERR_TYPE; diff --git a/src/minivhd_util.c b/src/minivhd_util.c index b7d37be..9fd2012 100644 --- a/src/minivhd_util.c +++ b/src/minivhd_util.c @@ -1,5 +1,7 @@ +#include #include #include +#include #ifdef HAVE_UUID_H #include #endif