Fix minor code styles issues
This commit is contained in:
parent
b0517b2f39
commit
f6e5f8937b
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
GMIO_INLINE gmio_buffer_t gmio_buffer_null()
|
GMIO_INLINE gmio_buffer_t gmio_buffer_null()
|
||||||
{
|
{
|
||||||
gmio_buffer_t buff = { 0 };
|
gmio_buffer_t buff = {0};
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,35 +47,35 @@ GMIO_INLINE int gmio_fstat(int fd, gmio_stat_t* buf)
|
|||||||
|
|
||||||
gmio_stream_t gmio_stream_null()
|
gmio_stream_t gmio_stream_null()
|
||||||
{
|
{
|
||||||
gmio_stream_t null_stream = { 0 };
|
gmio_stream_t null_stream = {0};
|
||||||
return null_stream;
|
return null_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gmio_bool_t gmio_stream_stdio_at_end(void* cookie)
|
static gmio_bool_t gmio_stream_stdio_at_end(void* cookie)
|
||||||
{
|
{
|
||||||
return feof((FILE*) cookie);
|
return feof((FILE*)cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gmio_stream_stdio_error(void* cookie)
|
static int gmio_stream_stdio_error(void* cookie)
|
||||||
{
|
{
|
||||||
return ferror((FILE*) cookie);
|
return ferror((FILE*)cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t gmio_stream_stdio_read(
|
static size_t gmio_stream_stdio_read(
|
||||||
void* cookie, void* ptr, size_t item_size, size_t item_count)
|
void* cookie, void* ptr, size_t item_size, size_t item_count)
|
||||||
{
|
{
|
||||||
return fread(ptr, item_size, item_count, (FILE*) cookie);
|
return fread(ptr, item_size, item_count, (FILE*)cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t gmio_stream_stdio_write(
|
static size_t gmio_stream_stdio_write(
|
||||||
void* cookie, const void* ptr, size_t item_size, size_t item_count)
|
void* cookie, const void* ptr, size_t item_size, size_t item_count)
|
||||||
{
|
{
|
||||||
return fwrite(ptr, item_size, item_count, (FILE*) cookie);
|
return fwrite(ptr, item_size, item_count, (FILE*)cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t gmio_stream_stdio_size(void* cookie)
|
static size_t gmio_stream_stdio_size(void* cookie)
|
||||||
{
|
{
|
||||||
FILE* file = (FILE*) cookie;
|
FILE* file = (FILE*)cookie;
|
||||||
|
|
||||||
#if defined(GMIO_HAVE_SYS_TYPES_H) \
|
#if defined(GMIO_HAVE_SYS_TYPES_H) \
|
||||||
&& defined(GMIO_HAVE_SYS_STAT_H) \
|
&& defined(GMIO_HAVE_SYS_STAT_H) \
|
||||||
@ -146,7 +146,7 @@ static int gmio_stream_stdio_set_pos(void* cookie, const gmio_stream_pos_t* pos)
|
|||||||
|
|
||||||
gmio_stream_t gmio_stream_stdio(FILE* file)
|
gmio_stream_t gmio_stream_stdio(FILE* file)
|
||||||
{
|
{
|
||||||
gmio_stream_t stream = { 0 };
|
gmio_stream_t stream = gmio_stream_null();
|
||||||
stream.cookie = file;
|
stream.cookie = file;
|
||||||
stream.func_at_end = gmio_stream_stdio_at_end;
|
stream.func_at_end = gmio_stream_stdio_at_end;
|
||||||
stream.func_error = gmio_stream_stdio_error;
|
stream.func_error = gmio_stream_stdio_error;
|
||||||
|
@ -31,7 +31,7 @@ enum { GMIO_FIXED_BUFFER_SIZE = 512 };
|
|||||||
|
|
||||||
gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
||||||
{
|
{
|
||||||
char fixed_buffer[GMIO_FIXED_BUFFER_SIZE];
|
char fixed_buffer[GMIO_FIXED_BUFFER_SIZE] = {0};
|
||||||
size_t read_size = 0;
|
size_t read_size = 0;
|
||||||
gmio_stream_pos_t stream_start_pos = gmio_stream_pos_null();
|
gmio_stream_pos_t stream_start_pos = gmio_stream_pos_null();
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
|||||||
* First keep stream start position, it will be restored after read
|
* First keep stream start position, it will be restored after read
|
||||||
*/
|
*/
|
||||||
gmio_stream_get_pos(stream, &stream_start_pos);
|
gmio_stream_get_pos(stream, &stream_start_pos);
|
||||||
memset(fixed_buffer, 0, GMIO_FIXED_BUFFER_SIZE);
|
|
||||||
read_size = gmio_stream_read(stream, &fixed_buffer, 1, GMIO_FIXED_BUFFER_SIZE);
|
read_size = gmio_stream_read(stream, &fixed_buffer, 1, GMIO_FIXED_BUFFER_SIZE);
|
||||||
read_size = GMIO_MIN(read_size, GMIO_FIXED_BUFFER_SIZE);
|
read_size = GMIO_MIN(read_size, GMIO_FIXED_BUFFER_SIZE);
|
||||||
gmio_stream_set_pos(stream, &stream_start_pos);
|
gmio_stream_set_pos(stream, &stream_start_pos);
|
||||||
|
@ -35,7 +35,7 @@ int gmio_stl_read_file(
|
|||||||
|
|
||||||
file = fopen(filepath, "rb");
|
file = fopen(filepath, "rb");
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
gmio_transfer_t trsf = { 0 };
|
gmio_transfer_t trsf = {0};
|
||||||
trsf.stream = gmio_stream_stdio(file);
|
trsf.stream = gmio_stream_stdio(file);
|
||||||
trsf.buffer = gmio_buffer_default();
|
trsf.buffer = gmio_buffer_default();
|
||||||
if (task_iface != NULL)
|
if (task_iface != NULL)
|
||||||
@ -96,7 +96,7 @@ int gmio_stl_write_file(
|
|||||||
|
|
||||||
file = fopen(filepath, "wb");
|
file = fopen(filepath, "wb");
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
gmio_transfer_t trsf = { 0 };
|
gmio_transfer_t trsf = {0};
|
||||||
trsf.stream = gmio_stream_stdio(file);
|
trsf.stream = gmio_stream_stdio(file);
|
||||||
trsf.buffer = gmio_buffer_default();
|
trsf.buffer = gmio_buffer_default();
|
||||||
if (task_iface != NULL)
|
if (task_iface != NULL)
|
||||||
|
@ -196,7 +196,7 @@ GMIO_INLINE void parsing_error(gmio_stla_parse_data_t* data)
|
|||||||
GMIO_INLINE void parsing_error_token_expected(
|
GMIO_INLINE void parsing_error_token_expected(
|
||||||
gmio_stla_parse_data_t* data, gmio_stla_token_t token)
|
gmio_stla_parse_data_t* data, gmio_stla_token_t token)
|
||||||
{
|
{
|
||||||
char msg[256] = { 0 };
|
char msg[256] = {0};
|
||||||
sprintf(msg,
|
sprintf(msg,
|
||||||
"token <%s> expected, got <%s>",
|
"token <%s> expected, got <%s>",
|
||||||
token_to_string(token),
|
token_to_string(token),
|
||||||
|
@ -85,7 +85,7 @@ static void occmesh_get_triangle(
|
|||||||
|
|
||||||
gmio_stl_mesh_t gmio_stl_occmesh(const gmio_occ_stl_mesh_domain_t* mesh_domain)
|
gmio_stl_mesh_t gmio_stl_occmesh(const gmio_occ_stl_mesh_domain_t* mesh_domain)
|
||||||
{
|
{
|
||||||
gmio_stl_mesh_t mesh = { 0 };
|
gmio_stl_mesh_t mesh = {0};
|
||||||
mesh.cookie = mesh_domain;
|
mesh.cookie = mesh_domain;
|
||||||
if (mesh_domain != NULL && mesh_domain->mesh != NULL) {
|
if (mesh_domain != NULL && mesh_domain->mesh != NULL) {
|
||||||
mesh.triangle_count =
|
mesh.triangle_count =
|
||||||
@ -97,7 +97,7 @@ gmio_stl_mesh_t gmio_stl_occmesh(const gmio_occ_stl_mesh_domain_t* mesh_domain)
|
|||||||
|
|
||||||
gmio_stl_mesh_creator_t gmio_stl_occmesh_creator(StlMesh_Mesh* mesh)
|
gmio_stl_mesh_creator_t gmio_stl_occmesh_creator(StlMesh_Mesh* mesh)
|
||||||
{
|
{
|
||||||
gmio_stl_mesh_creator_t creator = { 0 };
|
gmio_stl_mesh_creator_t creator = {0};
|
||||||
creator.cookie = mesh;
|
creator.cookie = mesh;
|
||||||
creator.func_add_triangle = internal::occmesh_add_triangle;
|
creator.func_add_triangle = internal::occmesh_add_triangle;
|
||||||
return creator;
|
return creator;
|
||||||
|
@ -85,7 +85,7 @@ static int gmio_stream_qiodevice_set_pos(
|
|||||||
|
|
||||||
gmio_stream_t gmio_stream_qiodevice(QIODevice* device)
|
gmio_stream_t gmio_stream_qiodevice(QIODevice* device)
|
||||||
{
|
{
|
||||||
gmio_stream_t stream = { 0 };
|
gmio_stream_t stream = {0};
|
||||||
stream.cookie = device;
|
stream.cookie = device;
|
||||||
stream.func_at_end = gmio_stream_qiodevice_at_end;
|
stream.func_at_end = gmio_stream_qiodevice_at_end;
|
||||||
stream.func_error = gmio_stream_qiodevice_error;
|
stream.func_error = gmio_stream_qiodevice_error;
|
||||||
|
@ -35,7 +35,7 @@ const char* test_core__buffer()
|
|||||||
const size_t obj_count = 4;
|
const size_t obj_count = 4;
|
||||||
const size_t obj_size = 256;
|
const size_t obj_size = 256;
|
||||||
const size_t buff_size = obj_count * obj_size;
|
const size_t buff_size = obj_count * obj_size;
|
||||||
const uint8_t zero_buff[4 * 256] = { 0 };
|
const uint8_t zero_buff[4 * 256] = {0};
|
||||||
gmio_buffer_t buff = gmio_buffer_calloc(obj_count, obj_size);
|
gmio_buffer_t buff = gmio_buffer_calloc(obj_count, obj_size);
|
||||||
UTEST_ASSERT(buff.ptr != NULL);
|
UTEST_ASSERT(buff.ptr != NULL);
|
||||||
UTEST_ASSERT(buff.size == buff_size);
|
UTEST_ASSERT(buff.size == buff_size);
|
||||||
@ -99,7 +99,7 @@ const char* test_core__stream()
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
const gmio_stream_t null_stream = gmio_stream_null();
|
const gmio_stream_t null_stream = gmio_stream_null();
|
||||||
const uint8_t null_bytes[sizeof(gmio_stream_t)] = { 0 };
|
const uint8_t null_bytes[sizeof(gmio_stream_t)] = {0};
|
||||||
UTEST_ASSERT(memcmp(&null_stream, &null_bytes, sizeof(gmio_stream_t))
|
UTEST_ASSERT(memcmp(&null_stream, &null_bytes, sizeof(gmio_stream_t))
|
||||||
== 0);
|
== 0);
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ const char* test_platform__global_h()
|
|||||||
|
|
||||||
const char* test_platform__compiler()
|
const char* test_platform__compiler()
|
||||||
{
|
{
|
||||||
/* Check that initialization with { 0 } works as expected
|
/* Check that initialization with {0} works as expected
|
||||||
*
|
*
|
||||||
* Depending on your version, GCC can incorrectly reports the warning
|
* Depending on your version, GCC can incorrectly reports the warning
|
||||||
* "missing braces around initializer [-Wmissing-braces]"
|
* "missing braces around initializer [-Wmissing-braces]"
|
||||||
* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
|
* See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
const gmio_transfer_t trsf_null_bracket0 = { 0 };
|
const gmio_transfer_t trsf_null_bracket0 = {0};
|
||||||
gmio_transfer_t trsf_null_memset0;
|
gmio_transfer_t trsf_null_memset0;
|
||||||
|
|
||||||
memset(&trsf_null_memset0, 0, sizeof(gmio_transfer_t));
|
memset(&trsf_null_memset0, 0, sizeof(gmio_transfer_t));
|
||||||
|
@ -185,7 +185,7 @@ const char* test_stl_read()
|
|||||||
const char* test_stlb_write_header()
|
const char* test_stlb_write_header()
|
||||||
{
|
{
|
||||||
const char* filepath = "temp/solid.stlb";
|
const char* filepath = "temp/solid.stlb";
|
||||||
gmio_stlb_header_t header = { 0 };
|
gmio_stlb_header_t header = {0};
|
||||||
const char* header_str = "temp/solid.stlb generated with gmio library";
|
const char* header_str = "temp/solid.stlb generated with gmio library";
|
||||||
int error = GMIO_ERROR_OK;
|
int error = GMIO_ERROR_OK;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user