-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
badblocks.c from rufus #17
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is autogenerated code-style review, new suggestions: 6
{ | ||
if (bb_u64_list_find(bb, blk) < 0) | ||
return 0; | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else | |
This comment was generated with the following checker: ClangTidy
return got; | ||
} | ||
|
||
static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is too long
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes)
now spans 140 lines.
Corresponding modifications started here.
Keep your functions' length within 50 lines to improve readability.
This comment was generated with the following checker: long_method
/* | ||
* This procedure adds a block to a badblocks list. | ||
*/ | ||
static errcode_t bb_u64_list_add(bb_u64_list bb, uint64_t blk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is too complicated
bb_u64_list_add( bb_u64_list bb , uint64_t blk)
now has cyclomatic complexity of 11.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.
This comment was generated with the following checker: high_cyclomatic_complexity
return got; | ||
} | ||
|
||
static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is too complicated
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes)
now has cyclomatic complexity of 46.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.
This comment was generated with the following checker: high_cyclomatic_complexity
return got; | ||
} | ||
|
||
static unsigned int test_rw(HANDLE hDrive, blk64_t last_block, size_t block_size, blk64_t first_block, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function has too many parameters
test_rw( HANDLE hDrive , blk64_t last_block , size_t block_size , blk64_t first_block , size_t blocks_at_once , int pattern_type , int nb_passes)
now has 7 parameters.
Functions with parameter list length above 5 are mostly hard to understand and use.
To reduce the number of arguments, you can isolate arguments used together into an object, or split the function
This comment was generated with the following checker: long_parameter_list
return bb_count; | ||
} | ||
|
||
BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int nb_passes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function has too many parameters
BadBlocks( HANDLE hPhysicalDrive , ULONGLONG disk_size , int nb_passes , int flash_type , badblocks_report * report , FILE * fd)
now has 6 parameters.
Functions with parameter list length above 5 are mostly hard to understand and use.
To reduce the number of arguments, you can isolate arguments used together into an object, or split the function
This comment was generated with the following checker: long_parameter_list
src/badblocks.c from https://github.com/pbatard/rufus/blob/cda716c/src/badblocks.c