Fix most of GCC and MSVC warnings

This commit is contained in:
Hugues Delorme 2017-03-30 11:02:47 +02:00
parent c1c58f087c
commit b7832bb33d
6 changed files with 55 additions and 34 deletions

View File

@ -242,7 +242,7 @@ void bmk_gmio_stl_infos_probe_all(const void* filepath)
" Size: %uKo\n" " Size: %uKo\n"
" Facets: %u\n", " Facets: %u\n",
cfilepath, cfilepath,
infos.size / 1024, (unsigned)infos.size / 1024,
infos.facet_count); infos.facet_count);
if (infos.format == GMIO_STL_FORMAT_ASCII) if (infos.format == GMIO_STL_FORMAT_ASCII)
printf(" [STLA]Solid name: %s\n", infos.stla_solidname); printf(" [STLA]Solid name: %s\n", infos.stla_solidname);
@ -264,7 +264,7 @@ void bmk_gmio_stl_infos_probe_size(const void* filepath)
" File: %s\n" " File: %s\n"
" Size: %uKo\n", " Size: %uKo\n",
cfilepath, cfilepath,
infos.size / 1024); (unsigned)infos.size / 1024);
} }
already_exec = true; already_exec = true;
} }

View File

@ -633,22 +633,20 @@ static size_t gmio_amf_ostringstream_write_zlib(
const char* ptr, const char* ptr,
size_t len) size_t len)
{ {
const uint8_t* ptr_u8 = (const uint8_t*)ptr;
struct gmio_memblock* z_mblock = &context->z_memblock; struct gmio_memblock* z_mblock = &context->z_memblock;
struct z_stream_s* z_stream = &context->z_stream; struct z_stream_s* z_stream = &context->z_stream;
size_t total_written_len = 0; size_t total_written_len = 0;
int z_retcode = Z_OK; int z_retcode = Z_OK;
context->z_uncompressed_size += len; context->z_uncompressed_size += len;
context->z_crc32 = context->z_crc32 = gmio_zlib_crc32_update(context->z_crc32, ptr_u8, len);
gmio_zlib_crc32_update(context->z_crc32, (const uint8_t*)ptr, len);
z_stream->next_in = (z_const Bytef*)ptr; gmio_zlib_assign_zstream_in(z_stream, ptr_u8, len);
z_stream->avail_in = len;
/* Run zlib deflate() on input until output buffer not full /* Run zlib deflate() on input until output buffer not full
* Finish compression when zflush == Z_FINISH */ * Finish compression when zflush == Z_FINISH */
do { do {
z_stream->next_out = z_mblock->ptr; gmio_zlib_assign_zstream_out(z_stream, z_mblock->ptr, z_mblock->size);
z_stream->avail_out = z_mblock->size;
z_retcode = deflate(z_stream, context->z_flush); z_retcode = deflate(z_stream, context->z_flush);
/* Check state not clobbered */ /* Check state not clobbered */
if (z_retcode == Z_STREAM_ERROR) { if (z_retcode == Z_STREAM_ERROR) {

View File

@ -162,3 +162,17 @@ uint32_t gmio_zlib_crc32_initial()
{ {
return crc32(0, NULL, 0); return crc32(0, NULL, 0);
} }
void gmio_zlib_assign_zstream_in(
struct z_stream_s *zstream, const uint8_t *next_in, size_t avail_in)
{
zstream->next_in = (z_const Bytef*)next_in;
zstream->avail_in = (uInt)avail_in;
}
void gmio_zlib_assign_zstream_out(
struct z_stream_s *zstream, uint8_t *next_out, size_t avail_out)
{
zstream->next_out = next_out;
zstream->avail_out = (uInt)avail_out;
}

View File

@ -62,3 +62,11 @@ uint32_t gmio_zlib_crc32_initial();
/*! Updates a running CRC-32 with the bytes from \p buff */ /*! Updates a running CRC-32 with the bytes from \p buff */
uint32_t gmio_zlib_crc32_update( uint32_t gmio_zlib_crc32_update(
uint32_t crc, const uint8_t* buff, size_t buff_len); uint32_t crc, const uint8_t* buff, size_t buff_len);
/*! Type-safe assigns z_stream_s::next_in and z_stream_s::avail_in */
void gmio_zlib_assign_zstream_in(
struct z_stream_s* zstream, const uint8_t* next_in, size_t avail_in);
/*! Type-safe assigns z_stream_s::next_out and z_stream_s::avail_out */
void gmio_zlib_assign_zstream_out(
struct z_stream_s* zstream, uint8_t* next_out, size_t avail_out);

View File

@ -208,37 +208,37 @@ const struct __tamf__material __tamf__doc_1_materials[] = {
}; };
const struct gmio_vec3d __tamf__doc_1_vertices[] = { const struct gmio_vec3d __tamf__doc_1_vertices[] = {
{ 0., 0., 0.}, { 0., 0., 0. },
{ 1., 0., 0.}, { 1., 0., 0. },
{ 1., -1., 0.}, { 1., -1., 0. },
{ 0., -1., 0.}, { 0., -1., 0. },
{ 1., 0., 1.}, { 1., 0., 1. },
{ 1., -1., 1.}, { 1., -1., 1. },
{ 0., 0., 1.}, { 0., 0., 1. },
{ 0., -1., 1.} { 0., -1., 1. }
}; };
const struct __tamf__triangle __tamf__doc_1_triangles[] = { const struct __tamf__triangle __tamf__doc_1_triangles[] = {
{ 0, 1, 2}, { {0, 1, 2} },
{ 0, 2, 3}, { {0, 2, 3} },
{ 1, 5, 2}, { {1, 5, 2} },
{ 1, 4, 5}, { {1, 4, 5} },
{ 6, 5, 7}, { {6, 5, 7} },
{ 6, 4, 5}, { {6, 4, 5} },
{ 0, 6, 7}, { {0, 6, 7} },
{ 0, 7, 3}, { {0, 7, 3} },
{ 0, 6, 4}, { {0, 6, 4} },
{ 0, 4, 1}, { {0, 4, 1} },
{ 3, 7, 5}, { {3, 7, 5} },
{ 3, 5, 2} { {3, 5, 2} }
}; };
const struct gmio_amf_instance __tamf__doc_1_instances[] = { const struct gmio_amf_instance __tamf__doc_1_instances[] = {
{ 0, {0}, {0} }, { 0, {0, 0, 0}, {0, 0, 0} },
{ 1, {10, 0, 0}, { 45, 0, 0} }, { 1, {10, 0, 0}, {45, 0, 0} },
{ 2, {0, 10, 0}, { 0, 45, 0} }, { 2, {0, 10, 0}, {0, 45, 0} },
{ 3, {0, 0, 10}, { 0, 0, 45} }, { 3, {0, 0, 10}, {0, 0, 45} },
{ 4, {10, 10, 0}, { 45, 45, 0} }, { 4, {10, 10, 0}, {45, 45, 0} },
}; };
struct __tamf__document __tamf__create_doc_1() struct __tamf__document __tamf__create_doc_1()
@ -382,7 +382,7 @@ static const char* test_amf_write_doc_1_zip()
size_t dest_len = amf_data_len; size_t dest_len = amf_data_len;
ptr_g_memblock += dest_len; ptr_g_memblock += dest_len;
const uint8_t* amf_zdata = (const uint8_t*)wbuff.ptr + wbuff.pos; const uint8_t* amf_zdata = (const uint8_t*)wbuff.ptr + wbuff.pos;
const int error = gmio_zlib_uncompress_buffer( error = gmio_zlib_uncompress_buffer(
dest, &dest_len, amf_zdata, amf_zdata_len); dest, &dest_len, amf_zdata, amf_zdata_len);
printf("\ninfo: z_len=%u src_len=%u\n", printf("\ninfo: z_len=%u src_len=%u\n",
(unsigned)amf_zdata_len, (unsigned)amf_data_len); (unsigned)amf_zdata_len, (unsigned)amf_data_len);

View File

@ -68,6 +68,7 @@ static void __tc__run_atof(float (*func_atof)(const char*))
fres = func_atof(strbuff); fres = func_atof(strbuff);
gmio_snprintf(strbuff, sizeof(strbuff), "%E", f); gmio_snprintf(strbuff, sizeof(strbuff), "%E", f);
fres = func_atof(strbuff); fres = func_atof(strbuff);
GMIO_UNUSED(fres);
} }
} }
} }