Skip to content

Use semantically correct integer types for counts and line numbers#88

Merged
thetic merged 12 commits into
mainfrom
type-cast
Apr 25, 2026
Merged

Use semantically correct integer types for counts and line numbers#88
thetic merged 12 commits into
mainfrom
type-cast

Conversation

@thetic
Copy link
Copy Markdown
Owner

@thetic thetic commented Apr 23, 2026

Description

Replace size_t with semantically appropriate integer types throughout the framework:

  • Line numbers: size_tint (prior PR) → int_least32_t. size_t is for object sizes/memory offsets. int is the type of __LINE__, but is only guaranteed 16 bits — __LINE__ can reach INT_MAX (2147483647), requiring 32 bits. int_least32_t is the smallest signed type guaranteed to hold any valid line number.
  • Test/check/skip/run counts: size_tunsigned int. These are plain counts, not memory quantities.
  • String substring counts in StringCollection: size_tunsigned int.
  • CircularBuffer example: intsize_t for capacity and index fields, which are genuine sizes/offsets into an allocated buffer.

Adds #include <stdint.h> to public headers that now expose int_least32_t.

Related Issues

Fixes # (issue number)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Manual Verification (Optional)

If you have verified this change on hardware or a simulator not covered by CI (e.g., a specific ARM target), please describe it here:

  • Target:
  • Result:

Checklist

  • I have written/updated documentation in docs/ for any user-facing changes.
  • My code follows the project's naming conventions (mu::tiny namespace, INCLUDED_MU_TINY_ guards, mutiny_ C-prefix).
  • For new features, I have considered if a C-interface adapter (.h and .c.cpp) is required for parity.
  • I have reviewed the CONTRIBUTING.md file to ensure compliance with architectural guidelines.

thetic added 3 commits April 22, 2026 23:15
… tests

Replace size_t{N} with NU in test assertions for clarity. Update
CircularBuffer to use size_t for capacity and index types. Use
unsigned int instead of size_t for string substring counts.
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 23, 2026

Coverage Status

coverage: 98.904%. remained the same — type-cast into main

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

TestsPassed ✅Skipped ⚠️Failed
JUnit Tests1059 ran1050 passed9 skipped0 failed

thetic added 3 commits April 23, 2026 09:25
size_t is for object sizes and memory offsets; test/check counts are
plain unsigned integers.
int is only guaranteed 16 bits; __LINE__ can reach INT_MAX (2147483647),
which requires 32 bits. int_least32_t is the smallest signed type
guaranteed to hold any valid line number.
- Update get_line_number(), get_failure_line_number(), and
  get_test_line_number() return types from int to int_least32_t
- Fix int /*line_number*/ and int line parameter types missed by
  the earlier sed pass
- Use PRIdLEAST32 from <inttypes.h> in printf-style format strings
  instead of %d, which is only correct when int is 32 bits
thetic added 6 commits April 23, 2026 22:58
repeat_ and shuffle_seed_ changed from size_t to unsigned int.
The repeat_ parse sites were still using strtol (signed); switch
them to strtoul to match the unsigned type and the existing
shuffle_seed_ parsing. strtol had no remaining call sites, so
remove the declaration, implementation, and tests.
@thetic thetic merged commit 746fdbd into main Apr 25, 2026
41 checks passed
@thetic thetic deleted the type-cast branch April 25, 2026 02:58
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.

2 participants