Skip to content

Commit

Permalink
[GCC|Clang] added addition compile flags.
Browse files Browse the repository at this point in the history
Added addition checks of source code, and globally change it to meet
such requirements. This flags is the same like in
https://github.com/Cyan4973/FiniteStateEntropy.git repository at the
make file.

[argument_parser|buffer|common|date_time|environment|file_system|interpreter|interpreter.file_system|interpreter.path|interpreter.property|interpreter.string_unit|load_tasks|operating_system]
'void' key word required in functions that do not have any parameters.

[buffer] added buffer_data_finish function - will help in some scenario
where casting required with end of buffer data point. See changes at the
xml unit to see what problem is solving with this function.

[environment] added missed cases for non Windows platform - new compile
flag signal that default not enough in scenario when we do need
processing some of cases from the enum in the switch operator.

[exec|load_tasks|property|text_encoding|version] deal with casting of
pointers when align policy is required to do so with adding variable
with required type or use correct already exists one if that possible.

[load_file] resolve prohibited casting with using of recently added
function - text_encoding_UTF_to_UTF8.

[path] added required const modifier to the declaration of variable.

[sleep_unit] added missed casting.

[text_encoding] added text_encoding_UTF16_to_ASCII,
text_encoding_UTF32_to_ASCII, text_encoding_UTF16_to_UTF8,
text_encoding_UTF32_to_UTF8 and text_encoding_UTF_to_UTF8 functions.

[tests_file_system] replaced #if TODO with #if defined(TODO) in order to
meet requirements from compiler with recently added flags.

[tests_text_encoding] added test on text_encoding_UTF_to_UTF8 and
text_encoding_get_one functions.

[xml] deal with pointer arithmetics and later casting to the different
type with using recently added function.
  • Loading branch information
TheVice committed Apr 2, 2024
1 parent 4a04dd9 commit ea6a47d
Show file tree
Hide file tree
Showing 39 changed files with 769 additions and 220 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ if(NOT MSVC)
endif()

target_compile_options(ant4c PRIVATE
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:MSVC>:/W4 /WX>
)

Expand Down Expand Up @@ -178,8 +178,8 @@ if(NOT MSVC)
endif()

target_compile_options(ant4c_shared PRIVATE
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:MSVC>:/W4 /WX>
)

Expand Down Expand Up @@ -221,8 +221,8 @@ if(NOT MSVC)
endif()

target_compile_options(ant4c_app PRIVATE
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror>
$<$<C_COMPILER_ID:Clang>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:GNU>:-Wall -Wextra -Werror -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef>
$<$<C_COMPILER_ID:MSVC>:/W4 /WX>
)

Expand Down
32 changes: 16 additions & 16 deletions argument_parser.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 - 2022 TheVice
* Copyright (c) 2019 - 2022, 2024 TheVice
*
*/

Expand Down Expand Up @@ -553,7 +553,7 @@ uint8_t argument_parser_wchar_t(int i, int argc, wchar_t** argv)
return 1;
}
#endif
uint8_t argument_parser_init()
uint8_t argument_parser_init(void)
{
if (!is_init)
{
Expand Down Expand Up @@ -802,57 +802,57 @@ const uint8_t* argument_parser_get_null_terminated_by_index(
return finish != start ? start : NULL;
}

uint8_t argument_parser_get_debug()
uint8_t argument_parser_get_debug(void)
{
return parameters_.debug;
}

uint8_t argument_parser_get_indent()
uint8_t argument_parser_get_indent(void)
{
return parameters_.indent;
}

uint8_t argument_parser_get_module_priority()
uint8_t argument_parser_get_module_priority(void)
{
return parameters_.module_priority;
}

uint8_t argument_parser_get_no_logo()
uint8_t argument_parser_get_no_logo(void)
{
return parameters_.no_logo;
}

uint8_t argument_parser_get_pause()
uint8_t argument_parser_get_pause(void)
{
return parameters_.pause;
}

uint8_t argument_parser_get_program_help()
uint8_t argument_parser_get_program_help(void)
{
return parameters_.program_help;
}

uint8_t argument_parser_get_project_help()
uint8_t argument_parser_get_project_help(void)
{
return parameters_.project_help;
}

uint8_t argument_parser_get_quiet()
uint8_t argument_parser_get_quiet(void)
{
return parameters_.quiet;
}

uint8_t argument_parser_get_verbose()
uint8_t argument_parser_get_verbose(void)
{
return parameters_.verbose;
}

uint16_t argument_parser_get_encoding()
uint16_t argument_parser_get_encoding(void)
{
return parameters_.encoding;
}

const void* argument_parser_get_properties()
const void* argument_parser_get_properties(void)
{
return (const void*)(&parameters_.properties);
}
Expand All @@ -862,7 +862,7 @@ const uint8_t* argument_parser_get_build_file(int index)
return argument_parser_get_null_terminated_by_index((void*)(&parameters_.build_file), index);
}

const uint8_t* argument_parser_get_log_file()
const uint8_t* argument_parser_get_log_file(void)
{
return buffer_uint8_t_data((void*)(&parameters_.log_file), 0);
}
Expand All @@ -872,12 +872,12 @@ const uint8_t* argument_parser_get_target(int index)
return argument_parser_get_null_terminated_by_index((void*)(&parameters_.target), index);
}

const uint8_t* argument_parser_get_listener()
const uint8_t* argument_parser_get_listener(void)
{
return buffer_uint8_t_data((void*)(&parameters_.listener), 0);
}

void argument_parser_release()
void argument_parser_release(void)
{
if (is_init)
{
Expand Down
32 changes: 16 additions & 16 deletions argument_parser.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 - 2020, 2022 TheVice
* Copyright (c) 2019 - 2020, 2022, 2024 TheVice
*
*/

Expand All @@ -28,26 +28,26 @@ uint8_t argument_from_char(
const char* input_start, const char* input_finish,
void* output, int* argc, char*** argv);

uint8_t argument_parser_init();
uint8_t argument_parser_init(void);

uint8_t argument_parser_get_debug();
uint8_t argument_parser_get_indent();
uint8_t argument_parser_get_module_priority();
uint8_t argument_parser_get_no_logo();
uint8_t argument_parser_get_pause();
uint8_t argument_parser_get_program_help();
uint8_t argument_parser_get_project_help();
uint8_t argument_parser_get_quiet();
uint8_t argument_parser_get_verbose();
uint16_t argument_parser_get_encoding();
uint8_t argument_parser_get_debug(void);
uint8_t argument_parser_get_indent(void);
uint8_t argument_parser_get_module_priority(void);
uint8_t argument_parser_get_no_logo(void);
uint8_t argument_parser_get_pause(void);
uint8_t argument_parser_get_program_help(void);
uint8_t argument_parser_get_project_help(void);
uint8_t argument_parser_get_quiet(void);
uint8_t argument_parser_get_verbose(void);
uint16_t argument_parser_get_encoding(void);

const void* argument_parser_get_properties();
const void* argument_parser_get_properties(void);

const uint8_t* argument_parser_get_build_file(int index);
const uint8_t* argument_parser_get_log_file();
const uint8_t* argument_parser_get_log_file(void);
const uint8_t* argument_parser_get_target(int index);
const uint8_t* argument_parser_get_listener();
const uint8_t* argument_parser_get_listener(void);

void argument_parser_release();
void argument_parser_release(void);

#endif
2 changes: 1 addition & 1 deletion bit_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
\
return 1;

uint8_t bit_converter_is_little_endian()
uint8_t bit_converter_is_little_endian(void)
{
union endian_union
{
Expand Down
2 changes: 1 addition & 1 deletion bit_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdint.h>

uint8_t bit_converter_is_little_endian();
uint8_t bit_converter_is_little_endian(void);

uint8_t bit_converter_get_bytes_from_uint16_t(uint16_t input, uint8_t* output);
uint8_t bit_converter_get_bytes_from_uint32_t(uint32_t input, uint8_t* output);
Expand Down
17 changes: 15 additions & 2 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct buffer* buffer_to_real_buffer(const void* the_buffer)
return (struct buffer*)real_buffer;
}

uint8_t buffer_size_of()
uint8_t buffer_size_of(void)
{
return (uint8_t)sizeof(struct buffer);
}
Expand Down Expand Up @@ -283,6 +283,19 @@ void* buffer_data(const void* the_buffer_, ptrdiff_t index)
return (void*)((uint8_t*)the_buffer->data + index);
}

void* buffer_data_finish(const void* the_buffer_)
{
const struct buffer* the_buffer = (const struct buffer*)the_buffer_;

if (NULL == the_buffer ||
NULL == the_buffer->data)
{
return NULL;
}

return (void*)((uint8_t*)the_buffer->data + the_buffer->size);
}

char* buffer_char_data(const void* the_buffer, ptrdiff_t data_position)
{
return (char*)buffer_data(the_buffer, sizeof(char) * data_position);
Expand Down Expand Up @@ -432,7 +445,7 @@ uint8_t buffer_return_to_pool(void* the_buffer)
return 1;
}

uint8_t buffer_release_pool()
uint8_t buffer_release_pool(void)
{
if (is_pool_init)
{
Expand Down
7 changes: 4 additions & 3 deletions buffer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019, 2022 TheVice
* Copyright (c) 2019, 2022, 2024 TheVice
*
*/

Expand All @@ -14,7 +14,7 @@

#define BUFFER_SIZE_OF (2 * sizeof(ptrdiff_t) + sizeof(void*))

uint8_t buffer_size_of();
uint8_t buffer_size_of(void);

uint8_t buffer_init(void* the_buffer, uint8_t size_of_buffer);

Expand All @@ -32,6 +32,7 @@ uint8_t buffer_append_buffer(void* the_buffer, const void* data, ptrdiff_t data_
uint8_t buffer_append_data_from_buffer(void* the_buffer, const void* the_source_buffer);

void* buffer_data(const void* the_buffer, ptrdiff_t index);
void* buffer_data_finish(const void* the_buffer);
char* buffer_char_data(const void* the_buffer, ptrdiff_t data_position);
uint8_t* buffer_uint8_t_data(const void* the_buffer, ptrdiff_t data_position);
wchar_t* buffer_wchar_t_data(const void* the_buffer, ptrdiff_t data_position);
Expand All @@ -47,6 +48,6 @@ uint8_t buffer_shrink_to_fit(void* the_buffer);

uint8_t buffer_init_pool(void** the_buffer);
uint8_t buffer_return_to_pool(void* the_buffer);
uint8_t buffer_release_pool();
uint8_t buffer_release_pool(void);

#endif
12 changes: 6 additions & 6 deletions common.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 - 2022 TheVice
* Copyright (c) 2019 - 2022, 2024 TheVice
*
*/

Expand Down Expand Up @@ -220,22 +220,22 @@ void common_set_error_output_stream(void* stream)
error_output_stream = stream;
}

void* common_get_output_stream()
void* common_get_output_stream(void)
{
return NULL == output_stream ? stdout : output_stream;
}

void* common_get_error_output_stream()
void* common_get_error_output_stream(void)
{
return NULL == error_output_stream ? stderr : error_output_stream;
}

uint8_t common_is_output_stream_standard()
uint8_t common_is_output_stream_standard(void)
{
return NULL == output_stream;
}

uint8_t common_is_error_output_stream_standard()
uint8_t common_is_error_output_stream_standard(void)
{
return NULL == error_output_stream;
}
Expand All @@ -247,7 +247,7 @@ void common_set_module_priority(uint8_t priority)
module_priority = 0 < priority;
}

uint8_t common_get_module_priority()
uint8_t common_get_module_priority(void)
{
return module_priority;
}
Expand Down
10 changes: 5 additions & 5 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ uint8_t common_get_attributes_and_arguments_for_task(

void common_set_output_stream(void* stream);
void common_set_error_output_stream(void* stream);
void* common_get_output_stream();
void* common_get_error_output_stream();
uint8_t common_is_output_stream_standard();
uint8_t common_is_error_output_stream_standard();
void* common_get_output_stream(void);
void* common_get_error_output_stream(void);
uint8_t common_is_output_stream_standard(void);
uint8_t common_is_error_output_stream_standard(void);

void common_set_module_priority(uint8_t priority);
uint8_t common_get_module_priority();
uint8_t common_get_module_priority(void);

const uint8_t* common_get_string_at(
const uint8_t* start, const uint8_t* finish,
Expand Down
8 changes: 4 additions & 4 deletions date_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ uint8_t datetime_is_leap_year(uint32_t year)
return ((!(year % 400)) || ((year % 100) && (!(year % 4))));
}

int64_t datetime_ticks()
int64_t datetime_ticks(void)
{
const clock_t ticks = clock();

Expand All @@ -497,7 +497,7 @@ int64_t datetime_ticks()
return ticks;
}

int64_t datetime_now_utc()
int64_t datetime_now_utc(void)
{
time_t now = 0;

Expand All @@ -515,7 +515,7 @@ int64_t datetime_now_utc()
(uint8_t)tm_u->tm_hour, (uint8_t)tm_u->tm_min, (uint8_t)tm_u->tm_sec);
}

int64_t datetime_now()
int64_t datetime_now(void)
{
time_t now = 0;

Expand Down Expand Up @@ -634,7 +634,7 @@ uint8_t datetime_decode(
return 1;
}
#if !defined(_WIN32)
long datetime_get_bias()
long datetime_get_bias(void)
{
time_t now = 0;

Expand Down
Loading

0 comments on commit ea6a47d

Please sign in to comment.