Refactor constants for clarity and maintainability#1
Conversation
There was a problem hiding this comment.
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
printferror messages with standardizedBFCFS_ERRlogging 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.
- Use defined constants for magic strings. - Simplify data parsing with helper macros.
There was a problem hiding this comment.
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.
- Use defined constants for index parsing and I/O operations - Enhance clarity by replacing magic numbers with named constants
There was a problem hiding this comment.
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.
- 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
This pull request improves error handling and code maintainability in the BFCFS filesystem implementation by replacing direct
printfstatements 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:
printferror and warning messages inbfc_format.c,bfc_io.c, andbfcfs_vfs.cwith the newBFCFS_ERRmacro for consistent error logging. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Sanity limits and constants:
bfcfs.hfor 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]NSEC_PER_SECand block rounding constantBFC_BLOCK_ROUNDinbfcfs.h, updating time and size calculations inbfcfs_vnops.cto use these for improved clarity and correctness. [1] [2]Debug and warning macros:
BFCFS_ERR,BFCFS_WARN, and improvedBFCFS_DEBUGinbfcfs.hfor consistent logging at different verbosity levels. [1] [2]Code maintainability:
bfcfs_vnops.cto 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.