Skip to content

Refactor constants for clarity and maintainability#1

Merged
zombocoder merged 7 commits into
mainfrom
feature/refacroing
Oct 9, 2025
Merged

Refactor constants for clarity and maintainability#1
zombocoder merged 7 commits into
mainfrom
feature/refacroing

Conversation

@zombocoder
Copy link
Copy Markdown
Owner

This pull request improves error handling and code maintainability in the BFCFS filesystem implementation by replacing direct printf statements with standardized logging macros, and by introducing constants for sanity limits and time conversions. The changes also update several sanity checks and calculations to use these new constants, making the code easier to configure and maintain.

Logging and error handling improvements:

Sanity limits and constants:

  • Added new constants in bfcfs.h for maximum block size (BFC_MAX_BLOCK_SIZE), index size (BFC_MAX_INDEX_SIZE), and entry count (BFC_MAX_ENTRIES), and updated all relevant sanity checks to use these constants instead of hardcoded values. [1] [2] [3] [4]
  • Introduced time conversion constant NSEC_PER_SEC and block rounding constant BFC_BLOCK_ROUND in bfcfs.h, updating time and size calculations in bfcfs_vnops.c to use these for improved clarity and correctness. [1] [2]

Debug and warning macros:

  • Defined new macros BFCFS_ERR, BFCFS_WARN, and improved BFCFS_DEBUG in bfcfs.h for consistent logging at different verbosity levels. [1] [2]

Code maintainability:

  • Updated debug output in bfcfs_vnops.c to use the new debug macro and avoid unused variable warnings when debugging is disabled.

These changes collectively make error reporting more consistent, improve code readability, and make configuration and maintenance easier.

@zombocoder zombocoder requested a review from Copilot October 8, 2025 21:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the BFCFS filesystem implementation to improve error handling consistency and code maintainability by standardizing logging and introducing configuration constants.

  • Replaced all direct printf error messages with standardized BFCFS_ERR logging macros
  • Introduced constants for sanity limits (block size, index size, entry count) and time/size conversions
  • Updated debug output to properly handle conditional compilation and avoid unused variable warnings

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
bfcfs.h Added logging macros and configuration constants for limits and conversions
bfc_format.c Replaced printf statements with BFCFS_ERR macro and updated sanity checks to use new constants
bfc_io.c Converted error messages to use standardized BFCFS_ERR logging macro
bfcfs_vfs.c Updated error logging to use BFCFS_ERR macro for consistency
bfcfs_vnops.c Updated time/size calculations to use constants and improved debug output handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread bfcfs_vnops.c Outdated
Comment thread bfcfs_vnops.c
@zombocoder zombocoder requested a review from Copilot October 8, 2025 22:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread bfcfs_vnops.c
@zombocoder zombocoder changed the title Refactoring Refactor constants for clarity and maintainability Oct 8, 2025
- Use defined constants for index parsing and I/O operations
- Enhance clarity by replacing magic numbers with named constants
@zombocoder zombocoder requested a review from Copilot October 8, 2025 22:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread bfcfs_vnops.c
Comment thread bfcfs_vnops.c
Comment thread bfcfs.h Outdated
- Install kyua and use it in FreeBSD CI workflow
- Enhance test verification with kernel module checks
- Integrate automated test container setup in CI
- Expand README with detailed test instructions
- Add comprehensive ATF test cases for file operations
@zombocoder zombocoder merged commit 042ef2c into main Oct 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants