Skip to content

Move utilities#14

Open
Totto16 wants to merge 24 commits into
mainfrom
move_utilities
Open

Move utilities#14
Totto16 wants to merge 24 commits into
mainfrom
move_utilities

Conversation

@Totto16
Copy link
Copy Markdown
Owner

@Totto16 Totto16 commented Apr 16, 2026

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v22.1.6) reports: 1 file(s) not formatted
  • src/utils/tqueue.h
clang-tidy (v22.1.4) reports: 94 concern(s)
  • src/ftp/file_ops.c:376:2: error: [totto-const-correctness-c]

    variable 'masks' of type 'mode_t[3]' (aka 'unsigned int[3]') can be declared 'const'

      376 |         mode_t masks[3] = { S_IRWXU, S_IRWXG, S_IRWXO };
          |         ^
          |                const 
  • src/ftp/file_ops.c:496:3: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      496 |                 LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
          |                 ^
    ../src/utils/log.h:69:24: note: expanded from macro 'LOG_MESSAGE'
       69 |                         FILE* file_stream = should_log_to_stderr ? stderr : stdout; \
          |                                             ^
  • src/ftp/file_ops.c:496:15: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      496 |                 LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
          |                             ^
    ../src/utils/log.h:88:42: note: expanded from macro 'COMBINE_LOG_FLAGS'
       88 | #define COMBINE_LOG_FLAGS(level, flags) ((FLAGS_TYPE)(level) | (FLAGS_TYPE)(flags))
          |                                          ^
  • src/ftp/file_ops.c:950:27: warning: [cppcoreguidelines-init-variables]

    variable 'to_send' is not initialized

      950 |                         const GenericDataConst to_send =
          |                                                ^
      951 |                             (const GenericDataConst)(((const uint8_t* const)raw_data.data.data) + offset);
          |                                                                                                          
          |                                                                                                           = NULL
  • src/generic/hash.c:324:22: warning: [misc-misplaced-const]

    'new_chunk' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

      324 |                         const GenericData new_chunk =
          |                                           ^
    ../src/utils/./utils.h:171:15: note: typedef declared here
      171 | typedef void* GenericData;
          |               ^
  • src/generic/secure.c:95:48: warning: [misc-misplaced-const]

    'user_data' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

       95 |                         const RTTIAnnotatedPtr user_data) { // NOLINT(totto-const-correctness-c)
          |                                                ^
    ../subprojects/trtti/src/trtti.h:91:15: note: typedef declared here
       91 | typedef void* RTTIAnnotatedPtr;
          |               ^
  • src/generic/secure.c:631:70: error: [totto-use-fixed-width-types-var]

    variable 'n_bytes' has type 'int', which should be rewritten into using a fixed type

      631 |                                           GenericData buffer, size_t n_bytes) {
          |                                                                      ^
  • src/generic/secure.h:89:70: error: [totto-use-fixed-width-types-var]

    variable 'n_bytes' has type 'int', which should be rewritten into using a fixed type

       89 |                                           GenericData buffer, size_t n_bytes);
          |                                                                      ^
  • src/generic/send.c:9:78: error: [totto-use-fixed-width-types-var]

    variable 'length' has type 'int', which should be rewritten into using a fixed type

        9 |                                       const GenericDataConst to_send, size_t length) {
          |                                                                              ^
  • src/generic/send.h:10:82: error: [totto-use-fixed-width-types-var]

    variable 'length' has type 'int', which should be rewritten into using a fixed type

       10 |                                                 GenericDataConst to_send, size_t length);
          |                                                                                  ^
  • src/http/common_log.c:10:2: error: [totto-const-correctness-c]

    pointee of variable 'collector' of type 'LogCollector *' (aka 'struct (unnamed at ../src/http/./common_log.h:25:9) *') can be declared 'const'

       10 |         LogCollector* collector = TRTTI_ALLOC(LogCollector);
          |         ^           
          |                      const
  • src/http/common_log.c:70:7: error: [totto-use-fixed-width-types-var]

    var decl '_' - type ''auto'' is not recognized by our type processor

       70 |         auto _ = TVEC_PUSH(LogEntry, &collector->entries, entry);
          |              ^
  • src/http/common_log.h:28:1: error: [totto-const-correctness-c]

    pointee of variable 'value' of type '__impl_struct_typename_rtti_LogCollector *' (aka 'struct (unnamed at /home/runner/work/my_simple_c_http_server/my_simple_c_http_server/src/http/common_log.h:28:1) *') can be declared 'const'

       28 | TRTTI_DECLARE_TYPE_AS_SUPPORTED(LogCollector)
          | ^
    ../subprojects/trtti/src/trtti.h:185:66: note: expanded from macro 'TRTTI_DECLARE_TYPE_AS_SUPPORTED'
      185 |         TRTTI_NODISCARD TRTTI_FUN_ATTRIBUTES Type* TRTTI_GET_DATA(Type)(TRTTI_VALUE_TYPENAME(Type) * \
          |                                                                         ^
    ../subprojects/trtti/src/trtti.h:67:33: note: expanded from macro 'TRTTI_VALUE_TYPENAME'
    note: expanded from here
       67 | #define TRTTI_VALUE_TYPENAME(T) __impl_struct_typename_rtti_##T
          |                                 ^
  • src/http/common_log.h:28:33: error: [totto-const-correctness-c]

    pointee of variable 'ptr' of type 'LogCollector *' (aka 'struct (unnamed at /home/runner/work/my_simple_c_http_server/my_simple_c_http_server/src/http/common_log.h:25:9) *') can be declared 'const'

       28 | TRTTI_DECLARE_TYPE_AS_SUPPORTED(LogCollector)
          |                                 ^
  • src/http/debug.c:90:2: error: [totto-const-correctness-c]

    pointee of variable 'authority_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

       90 |         JsonObject* const authority_obj = get_empty_json_object();
          |         ^         
          |                    const
  • src/http/debug.c:94:3: error: [totto-const-correctness-c]

    pointee of variable 'user_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

       94 |                 JsonObject* const user_obj = get_empty_json_object();
          |                 ^         
          |                            const
  • src/http/debug.c:136:2: error: [totto-const-correctness-c]

    pointee of variable 'root' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      136 |         JsonObject* const root = get_empty_json_object();
          |         ^         
          |                    const
  • src/http/debug.c:143:2: error: [totto-const-correctness-c]

    pointee of variable 'request_uri_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      143 |         JsonObject* const request_uri_obj = get_empty_json_object();
          |         ^         
          |                    const
  • src/http/debug.c:170:5: error: [totto-const-correctness-c]

    pointee of variable 'data_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      170 |                                 JsonObject* const data_obj = get_empty_json_object();
          |                                 ^         
          |                                            const
  • src/http/debug.c:178:6: error: [totto-const-correctness-c]

    variable 'uri_str' of type 'tstr' can be declared 'const'

      178 |                                         tstr uri_str = get_uri_as_string(uri);
          |                                         ^
          |                                              const 
  • src/http/debug.c:180:6: error: [totto-const-correctness-c]

    pointee of variable 'path_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      180 |                                         JsonObject* const path_obj = get_empty_json_object();
          |                                         ^         
          |                                                    const
  • src/http/debug.c:231:5: error: [totto-const-correctness-c]

    pointee of variable 'path_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      231 |                                 JsonObject* const path_obj = get_empty_json_object();
          |                                 ^         
          |                                            const
  • src/http/debug.c:287:2: error: [totto-const-correctness-c]

    pointee of variable 'json_headers' of type 'JsonArray *const' (aka 'struct JsonArrayImpl *const') can be declared 'const'

      287 |         JsonArray* const json_headers = get_empty_json_array();
          |         ^        
          |                   const
  • src/http/debug.c:326:2: error: [totto-const-correctness-c]

    pointee of variable 'settings_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      326 |         JsonObject* const settings_obj = get_empty_json_object();
          |         ^         
          |                    const
  • src/http/debug.c:330:3: error: [totto-const-correctness-c]

    pointee of variable 'send_settings_obj' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      330 |                 JsonObject* const send_settings_obj = get_empty_json_object();
          |                 ^         
          |                            const
  • src/http/folder.c:240:3: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      240 |                 LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
          |                 ^
    ../src/utils/log.h:69:24: note: expanded from macro 'LOG_MESSAGE'
       69 |                         FILE* file_stream = should_log_to_stderr ? stderr : stdout; \
          |                                             ^
  • src/http/folder.c:240:15: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      240 |                 LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
          |                             ^
    ../src/utils/log.h:88:42: note: expanded from macro 'COMBINE_LOG_FLAGS'
       88 | #define COMBINE_LOG_FLAGS(level, flags) ((FLAGS_TYPE)(level) | (FLAGS_TYPE)(flags))
          |                                          ^
  • src/http/hpack.c:32:34: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       32 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                         ^
  • src/http/hpack.c:32:51: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       32 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                                          ^
  • src/http/hpack.c:32:66: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       32 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                                                         ^
  • src/http/hpack.c:61:14: error: [totto-use-fixed-width-types-var]

    cast to type 'unsigned int', should be rewritten into using a fixed type

       61 |                 result += (byte & 0x7FU) << amount; // NOLINT(readability-magic-numbers)
          |                            ^
  • src/http/hpack.c:61:31: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       61 |                 result += (byte & 0x7FU) << amount; // NOLINT(readability-magic-numbers)
          |                                             ^
  • src/http/hpack.c:62:7: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       62 |                 if((byte & 0x80) ==                 // NOLINT(readability-magic-numbers)
          |                     ^
  • src/http/hpack.c:81:34: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       81 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                         ^
  • src/http/hpack.c:81:51: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       81 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                                          ^
  • src/http/hpack.c:81:66: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       81 |         const uint8_t mask = (uint8_t)((((uint8_t)1U) << prefix_bits) - (uint8_t)1U);
          |                                                                         ^
  • src/http/hpack.c:860:9: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      860 |                             (byte & 0xF0) == 0 &&
          |                              ^
  • src/http/hpack_huffman.c:134:10: warning: [cppcoreguidelines-init-variables]

    variable 'bits_mask' is not initialized

      134 |         uint8_t bits_mask = (uint8_t)((1U << bits_not_decoded) - 1U);
          |                 ^                                                   
          |                                                                      = 0
  • src/http/hpack_huffman.c:209:10: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      209 |                 ASSERT(false && "global map is not initialized");
          |                        ^
  • src/http/hpack_huffman.c:218:62: warning: [misc-misplaced-const]

    'data' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

      218 |                                            const GenericData data, const size_t max_size,
          |                                                              ^
    ../src/utils/utils.h:171:15: note: typedef declared here
      171 | typedef void* GenericData;
          |               ^
  • src/http/hpack_huffman.c:218:81: error: [totto-use-fixed-width-types-var]

    variable 'max_size' has type 'int', which should be rewritten into using a fixed type

      218 |                                            const GenericData data, const size_t max_size,
          |                                                                                 ^
  • src/http/hpack_huffman.c:280:36: warning: [misc-use-internal-linkage]

    function 'hpack_huffman_encode_value_fixed_size' can be made static to enforce internal linkage

      280 | NODISCARD HuffmanEncodeFixedResult hpack_huffman_encode_value_fixed_size(const GenericData data,
          |                                    ^
          |           static 
  • src/http/hpack_huffman.c:280:92: warning: [misc-misplaced-const]

    'data' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

      280 | NODISCARD HuffmanEncodeFixedResult hpack_huffman_encode_value_fixed_size(const GenericData data,
          |                                                                                            ^
    ../src/utils/utils.h:171:15: note: typedef declared here
      171 | typedef void* GenericData;
          |               ^
  • src/http/parser.c:501:10: error: [totto-use-fixed-width-types-var]

    var decl '_' - type ''auto'' is not recognized by our type processor

      501 |                                 auto _ = TVEC_PUSH(CompressionEntry, &(compression_settings.entries), entry);
          |                                      ^
  • src/http/routes.c:63:2: error: [totto-const-correctness-c]

    pointee of variable 'collector' of type 'LogCollector *' (aka 'struct (unnamed at ../src/http/./common_log.h:25:9) *') can be declared 'const'

       63 |         LogCollector* collector = TRTTI_ANNOTATED_PTR_CAST(LogCollector, data);
          |         ^           
          |                      const
  • src/http/routes.c:116:2: error: [totto-const-correctness-c]

    variable 'json_string' of type 'tstr' can be declared 'const'

      116 |         tstr json_string =
          |         ^
          |              const 
  • src/http/routes.c:168:2: error: [totto-const-correctness-c]

    variable 'bool_val' of type 'JsonBoolean' can be declared 'const'

      168 |         JsonBoolean bool_val = { .value = number % 2 != 0 };
          |         ^
          |                     const 
  • src/http/routes.c:202:45: error: [totto-const-correctness-c]

    pointee of variable 'object' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      202 | static void add_random_object_key_and_value(JsonObject* const object) {
          |                                             ^         
          |                                                        const
  • src/http/routes.c:203:2: error: [totto-const-correctness-c]

    pointee of variable 'key_moved' of type 'JsonString *' (aka 'struct JsonStringImpl *') can be declared 'const'

      203 |         JsonString* key_moved = json_get_random_key();
          |         ^         
          |                    const
  • src/http/routes.c:212:45: error: [totto-const-correctness-c]

    pointee of variable 'array' of type 'JsonArray *const' (aka 'struct JsonArrayImpl *const') can be declared 'const'

      212 | static void add_random_json_object_to_array(JsonArray* const array) {
          |                                             ^        
          |                                                       const
  • src/http/routes.c:217:2: error: [totto-const-correctness-c]

    pointee of variable 'object' of type 'JsonObject *const' (aka 'struct JsonObjectImpl *const') can be declared 'const'

      217 |         JsonObject* const object = get_empty_json_object();
          |         ^         
          |                    const
  • src/http/routes.c:240:10: error: [totto-use-fixed-width-types-var]

    var decl 'temp' - type ''auto'' is not recognized by our type processor

      240 |                                 auto temp = new_json_value_array(array);
          |                                      ^
  • src/http/send.c:42:2: error: [totto-const-correctness-c]

    variable 'result' of type 'LibCInt' (aka 'int') can be declared 'const'

       42 |         LibCInt result =
          |         ^
          |                 const 
  • src/http/send.c:585:2: error: [totto-const-correctness-c]

    variable 'result' of type 'HTTPResponseBody' (aka 'struct (unnamed at ../src/http/./send.h:9:9)') can be declared 'const'

      585 |         HTTPResponseBody result = http_response_body_from_tstr(&string_builder_buffer, send_body);
          |         ^
          |                          const 
  • src/http/send.c:589:28: warning: [misc-use-internal-linkage]

    function 'http_response_body_from_data' can be made static to enforce internal linkage

      589 | NODISCARD HTTPResponseBody http_response_body_from_data(GenericData data, size_t size,
          |                            ^
          |           static 
  • src/http/send.c:589:82: error: [totto-use-fixed-width-types-var]

    variable 'size' has type 'int', which should be rewritten into using a fixed type

      589 | NODISCARD HTTPResponseBody http_response_body_from_data(GenericData data, size_t size,
          |                                                                                  ^
  • src/http/send.h:36:82: error: [totto-use-fixed-width-types-var]

    variable 'size' has type 'int', which should be rewritten into using a fixed type

       36 | NODISCARD HTTPResponseBody http_response_body_from_data(GenericData data, size_t size,
          |                                                                                  ^
  • src/http/v2.c:3233:8: error: [totto-use-fixed-width-types-var]

    var decl '_' - type ''auto'' is not recognized by our type processor

     3233 |                 auto _ = TVEC_PUSH(Http2SettingSingleValue, &settings_frame.entries, dynamic_table_value);
          |                      ^
  • src/main.c:577:10: warning: [readability-magic-numbers]

    42 is a magic number; consider replacing it with a named constant

      577 |                 return 42;
          |                        ^
  • src/utils/buffered_reader.c:70:20: warning: [misc-misplaced-const]

    'new_buffer' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

       70 |         const GenericData new_buffer =
          |                           ^
    ../src/utils/./././utils.h:171:15: note: typedef declared here
      171 | typedef void* GenericData;
          |               ^
  • src/utils/buffered_reader.c:78:20: warning: [misc-misplaced-const]

    'buffer' declared with a const-qualified typedef; results in the type being 'void *const' instead of 'const void *'

       78 |         const GenericData buffer = (Byte*)new_buffer + reader->data.buffer.size;
          |                           ^
    ../src/utils/./././utils.h:171:15: note: typedef declared here
      171 | typedef void* GenericData;
          |               ^
  • src/utils/clock.c:162:6: error: [totto-use-fixed-width-types-var]

    cast to type 'long', should be rewritten into using a fixed type

      162 |             (long)(diff_ns - (uint64_t)(diff_s_part * ((time_t)(S_TO_NS_RATE))));
          |             ^
  • src/utils/path.c:54:1: warning: [google-readability-todo]

    missing username/bug in TODO

       54 | // TODO: replace with stat and open instead of fopen and ftell with fseek
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          | // TODO: runner - replace with stat and open instead of fopen and ftell with fseek
  • src/utils/path.c:82:3: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

       82 |                 LOG_MESSAGE(LogLevelError, "File size is negative: '%s': %ld\n", file_path, file_size);
          |                 ^
    ../src/utils/log.h:69:24: note: expanded from macro 'LOG_MESSAGE'
       69 |                         FILE* file_stream = should_log_to_stderr ? stderr : stdout; \
          |                                             ^
  • src/utils/path.c:98:23: warning: [misc-use-internal-linkage]

    function 'read_entire_file' can be made static to enforce internal linkage

       98 | NODISCARD GenericData read_entire_file(const char* file_path, OUT_PARAM(size_t) out_len) {
          |                       ^
          |           static 
  • src/utils/path.c:98:81: error: [totto-use-fixed-width-types-var]

    variable 'out_len' has type 'int*', which should be rewritten into using a fixed type

       98 | NODISCARD GenericData read_entire_file(const char* file_path, OUT_PARAM(size_t) out_len) {
          |                                                                                 ^
  • src/utils/path.c:125:3: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      125 |                 LOG_MESSAGE(LogLevelError, "File size is negative: '%s': %ld\n", file_path, file_size);
          |                 ^
    ../src/utils/log.h:69:24: note: expanded from macro 'LOG_MESSAGE'
       69 |                         FILE* file_stream = should_log_to_stderr ? stderr : stdout; \
          |                                             ^
  • src/utils/path.c:147:15: error: [totto-use-fixed-width-types-var]

    variable 'fread_result' has type 'int', which should be rewritten into using a fixed type

      147 |         const size_t fread_result = fread(file_data, 1, (size_t)file_size, file);
          |                      ^
  • src/utils/path.h:13:81: error: [totto-use-fixed-width-types-var]

    variable 'out_len' has type 'int*', which should be rewritten into using a fixed type

       13 | NODISCARD GenericData read_entire_file(const char* file_path, OUT_PARAM(size_t) out_len);
          |                                                                                 ^
  • src/utils/sized_buffer.c:27:81: error: [totto-use-fixed-width-types-var]

    variable 'size1' has type 'int', which should be rewritten into using a fixed type

       27 | NODISCARD static bool buffer_eq_impl(const GenericDataConst data1, const size_t size1,
          |                                                                                 ^
  • src/utils/sized_buffer.c:28:81: error: [totto-use-fixed-width-types-var]

    variable 'size2' has type 'int', which should be rewritten into using a fixed type

       28 |                                      const GenericDataConst data2, const size_t size2) {
          |                                                                                 ^
  • src/utils/sized_buffer.c:44:94: error: [totto-use-fixed-width-types-var]

    variable 'size' has type 'int', which should be rewritten into using a fixed type

       44 | NODISCARD static SizedBuffer sized_buffer_dup_impl(const GenericDataConst data, const size_t size) {
          |                                                                                              ^
  • src/utils/thread_pool.c:271:2: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      271 |         OOM_ASSERT(job_description != (GenericData)THREAD_SHUTDOWN_JOB_INTERNAL, "error description");
          |         ^
    ../src/utils/utils.h:119:10: note: expanded from macro 'OOM_ASSERT'
      119 |                                 exit(ExitCodeFailure); \
          |                                      ^
  • src/utils/tqueue.h:4:10: error: [clang-diagnostic-error]

    'stdbool.h' file not found

        4 | #include <stdbool.h>
          |          ^~~~~~~~~~~
  • src/utils/utf8_helper.c:7:26: warning: [misc-use-internal-linkage]

    function 'get_utf8_string' can be made static to enforce internal linkage

        7 | NODISCARD Utf8DataResult get_utf8_string(const GenericDataConst data, const size_t size) {
          |                          ^
          |           static 
  • src/utils/utf8_helper.c:7:84: error: [totto-use-fixed-width-types-var]

    variable 'size' has type 'int', which should be rewritten into using a fixed type

        7 | NODISCARD Utf8DataResult get_utf8_string(const GenericDataConst data, const size_t size) {
          |                                                                                    ^
  • src/utils/utf8_helper.h:16:72: error: [totto-use-fixed-width-types-var]

    variable 'size' has type 'int', which should be rewritten into using a fixed type

       16 | NODISCARD Utf8DataResult get_utf8_string(GenericDataConst data, size_t size);
          |                                                                        ^
  • src/utils/utils.c:24:16: error: [totto-use-fixed-width-types-var]

    variable 'seed' has type 'unsigned int', which should be rewritten into using a fixed type

       24 |                 unsigned int seed = (unsigned int)time(NULL);
          |                              ^
  • src/utils/utils.c:24:23: error: [totto-use-fixed-width-types-var]

    cast to type 'unsigned int', should be rewritten into using a fixed type

       24 |                 unsigned int seed = (unsigned int)time(NULL);
          |                                     ^
  • src/utils/utils.h:5:10: error: [clang-diagnostic-error]

    'stdbool.h' file not found

        5 | #include <stdbool.h>
          |          ^~~~~~~~~~~
  • src/ws/thread_manager.c:285:2: error: [totto-const-correctness-c]

    variable 'header_one' of type 'uint8_t' (aka 'unsigned char') can be declared 'const'

      285 |         uint8_t header_one =
          |         ^
          |                 const 
  • src/ws/thread_manager.c:286:18: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      286 |             (uint8_t)(((raw_message.fin & 0b1) // NOLINT(readability-implicit-bool-conversion)
          |                         ^
  • src/ws/thread_manager.c:288:20: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      288 |                       | ((raw_message.rsv_bytes & 0b111) << 4U) |
          |                           ^
  • src/ws/thread_manager.c:288:44: warning: [readability-magic-numbers]

    0b111 is a magic number; consider replacing it with a named constant

      288 |                       | ((raw_message.rsv_bytes & 0b111) << 4U) |
          |                                                   ^
  • src/ws/thread_manager.c:289:17: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      289 |                       (raw_message.op_code & 0b1111)); // NOLINT(readability-magic-numbers)
          |                        ^
  • src/ws/thread_manager.c:295:6: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      295 |             payload_additional_len == 0 ? (uint8_t)raw_message.payload.size : additional_payload_len_2;
          |             ^
  • src/ws/thread_manager.c:295:36: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      295 |             payload_additional_len == 0 ? (uint8_t)raw_message.payload.size : additional_payload_len_2;
          |                                           ^
  • src/ws/thread_manager.c:295:72: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      295 |             payload_additional_len == 0 ? (uint8_t)raw_message.payload.size : additional_payload_len_2;
          |                                                                               ^
  • src/ws/thread_manager.c:297:2: error: [totto-const-correctness-c]

    variable 'header_two' of type 'uint8_t' (aka 'unsigned char') can be declared 'const'

      297 |         uint8_t header_two = (uint8_t)(((has_mask & 0b1) // NOLINT(readability-implicit-bool-conversion)
          |         ^
          |                 const 
  • src/ws/thread_manager.c:297:35: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      297 |         uint8_t header_two = (uint8_t)(((has_mask & 0b1) // NOLINT(readability-implicit-bool-conversion)
          |                                          ^
  • src/ws/thread_manager.c:299:34: error: [totto-use-fixed-width-types-var]

    cast to type 'int', should be rewritten into using a fixed type

      299 |                                        (payload_len_1 & 0x7F)); // NOLINT(readability-magic-numbers)
          |                                         ^
  • src/ws/ws.c:200:1: error: [totto-const-correctness-c]

    pointee of variable 'value' of type '__impl_struct_typename_rtti_WsHeaderProcessArg *' (aka 'struct (unnamed at ../src/ws/ws.c:200:1) *') can be declared 'const'

      200 | TRTTI_DEFINE_TYPE_AS_SUPPORTED(WsHeaderProcessArg)
          | ^
    ../subprojects/trtti/src/trtti.h:235:2: note: expanded from macro 'TRTTI_DEFINE_TYPE_AS_SUPPORTED'
      235 |         TRTTI_DECLARE_TYPE_AS_SUPPORTED(Type) \
          |         ^
    ../subprojects/trtti/src/trtti.h:185:66: note: expanded from macro 'TRTTI_DECLARE_TYPE_AS_SUPPORTED'
      185 |         TRTTI_NODISCARD TRTTI_FUN_ATTRIBUTES Type* TRTTI_GET_DATA(Type)(TRTTI_VALUE_TYPENAME(Type) * \
          |                                                                         ^
    ../subprojects/trtti/src/trtti.h:67:33: note: expanded from macro 'TRTTI_VALUE_TYPENAME'
    note: expanded from here
       67 | #define TRTTI_VALUE_TYPENAME(T) __impl_struct_typename_rtti_##T
          |                                 ^
  • src/ws/ws.c:200:32: error: [totto-const-correctness-c]

    pointee of variable 'ptr' of type 'WsHeaderProcessArg *' (aka 'struct (unnamed at ../src/ws/ws.c:196:9) *') can be declared 'const'

      200 | TRTTI_DEFINE_TYPE_AS_SUPPORTED(WsHeaderProcessArg)
          |                                ^
  • src/ws/ws.c:353:3: error: [totto-const-correctness-c]

    variable 'accepted_extensions' of type 'tstr' can be declared 'const'

      353 |                 tstr accepted_extensions = get_accepted_ws_extensions_as_string(*extensions);
          |                 ^
          |                      const 

Have any feedback or feature suggestions? Share it here.

…ta, or RTTIAnnotatedPtr if we should use trtti with them
Totto16 added 4 commits May 12, 2026 04:07
- refactor all error defines into enums
- use trtti in every thread related function
- also use trtti in generic functions for e.g. ws extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant