Skip to content

Refactors error handling with errors codes, improves docs and benchmark CLI#103

Merged
hellobertrand merged 19 commits intomainfrom
candidate
Feb 26, 2026
Merged

Refactors error handling with errors codes, improves docs and benchmark CLI#103
hellobertrand merged 19 commits intomainfrom
candidate

Conversation

@hellobertrand
Copy link
Copy Markdown
Owner

Improves documentation by adopting Doxygen style and enhances error handling by providing more consistent and descriptive error codes.

  • Updates the API documentation for better clarity
  • Refactors function return values for consistency in error reporting
  • Introduces comprehensive error code tests to ensure proper error handling
  • Implements improvements to the CLI benchmark mode, including specifying the benchmark duration

@hellobertrand hellobertrand marked this pull request as draft February 19, 2026 13:24
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/zxc_driver.c 71.42% 4 Missing ⚠️
src/lib/zxc_dispatch.c 96.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

* Improves CLI benchmark mode

Updates the benchmark mode to run for a specified duration
instead of a fixed number of iterations. It now measures and
reports the best (fastest) compression and decompression speeds achieved during the test. Also prints number of iterations
performed.

This change provides more consistent and reliable benchmark
results, as it accounts for variations in system performance
and allows for longer test runs to capture peak speeds.

* Refines benchmark output and speed calculation

Updates benchmark to use MB/s
Removes warm-up iterations as they do not significantly impact results. Simplifies JSON output and standard output messages.

* Adds progress updates for benchmark runs

Improves the benchmark tool's user experience by adding progress updates during compression and decompression.

The updates display the number of iterations and the elapsed time, giving the user a better indication of the tool's progress.

This change only affects the CLI tool when JSON output is disabled and the quiet mode is not enabled.

* Improves benchmark mode output and const correctness

Fix test_cli.sh in JSON benchmark mode.

Also, adds `const` to several variables within the benchmark
function to reflect that they are not modified after initialization,
improving code readability and preventing accidental modification.
Introduces a comprehensive set of error codes to the ZXC library,
enhancing error reporting and handling.

Functions now return negative zxc_error_t codes on failure,
allowing for more precise error diagnosis.

Includes a utility function, zxc_error_name(), to retrieve
human-readable error messages for debugging.
Adds a new unit test to verify the functionality of the error code name lookup.
This test suite covers a wide range of error conditions, including null pointers, zero-sized buffers, insufficient buffer capacity, corrupted headers, truncated data, size mismatches, checksum failures, and other potential issues.

It ensures the functions correctly identify and report these errors by returning appropriate error codes or negative values.
Adds unit tests to validate stream-based compression and decompression error codes.

These tests cover scenarios such as null input, small files, bad magic numbers, corrupted footers and checksums, and truncated files.
Improves error code testing by reducing the destination buffer size to trigger specific error conditions more reliably and consistently.
Updates the `zxc_error_name` function to accept a constant integer to prevent potential unintended modifications of the error code.
Ensures all functions return the ZXC_OK macro upon successful completion, improving code readability and consistency across the codebase.
Addresses inconsistencies in documentation regarding code formatting and parameter ranges across various header and source files.
Specifically, it replaces en-dashes with hyphens in numeric ranges
and ensures consistent use of symbols.
Refines documentation by correcting minor inaccuracies and improving clarity.

Replaces `@typedef` with `@struct` for struct documentation.

Simplifies code by removing redundant `#ifndef` guards around `ZXC_DEPRECATED` macro.

Adds branch prediction hints and memory alignment/optimization macros to improve performance.
Introduces a Doxyfile to automate the generation of API documentation.

This configuration file sets up Doxygen to extract documentation from the source code, improving maintainability and usability of the library.
Introduces comprehensive error handling for the zxc library.
Defines specific error codes and maps them to Rust `Error` enum variants, allowing for more precise error reporting and handling in Rust code. Also includes descriptive error messages for better debugging and user experience.
Ensures that the `fread` calls in the error handling tests
are successful. If `fread` fails, the function now prints an error message, frees allocated memory, closes the file, and returns, preventing potential issues with subsequent operations on incomplete data.
Corrects the numeric block probing logic to accurately handle
block sizes that are multiples of `uint32_t`, ensuring
proper detection of numeric arrays.
@hellobertrand hellobertrand marked this pull request as ready for review February 25, 2026 15:59
Integrates Doxygen into the CMake build system.
Provides a `doc` target for generating API documentation (e.g., `make doc`).
Templates the Doxyfile to dynamically use CMake project variables for project name, version, and description.
@hellobertrand hellobertrand merged commit 861d4c8 into main Feb 26, 2026
65 of 66 checks passed
@hellobertrand hellobertrand deleted the candidate branch February 26, 2026 07:03
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