mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-27 04:54:14 +01:00
Integer type fixes (#145)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> Improve integer type under certain conditions. ## Motivation and Context <!--- What does this sample do? What problem does it solve? --> <!--- If it fixes/closes/resolves an open issue, please link to the issue here --> When running the flags `-Wall -Wextra`. ## How Has This Been Tested? <!-- (if applicable) --> <!--- Please describe in detail how you tested your sample/changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Screenshots <!-- (if appropriate): --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Improvement (non-breaking change that adds a new feature) - [ ] Bug fix (fixes an issue) - [ ] Breaking change (breaking change) - [ ] Documentation Improvement - [ ] Config and build (change in the configuration and build system, has no impact on code or features) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed. <!--- It would be nice if you could sign off your contribution by replacing the name with your GitHub user name and GitHub email contact. --> Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved handling of loop variables to prevent negative overflow in various functions, enhancing stability and reliability when processing larger values. - **Refactor** - Updated loop variable types to `unsigned int` for better performance and accuracy in ROM data handling across multiple components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
c49b9ed330
commit
49ea127dd7
@ -95,7 +95,7 @@ void boot (boot_params_t *params) {
|
|||||||
io32_t *reboot_dst = SP_MEM->IMEM;
|
io32_t *reboot_dst = SP_MEM->IMEM;
|
||||||
size_t reboot_instructions = (size_t) (&reboot_size) / sizeof(uint32_t);
|
size_t reboot_instructions = (size_t) (&reboot_size) / sizeof(uint32_t);
|
||||||
|
|
||||||
for (int i = 0; i < reboot_instructions; i++) {
|
for (unsigned int i = 0; i < reboot_instructions; i++) {
|
||||||
cpu_io_write(&reboot_dst[i], reboot_src[i]);
|
cpu_io_write(&reboot_dst[i], reboot_src[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ static flashcart_err_t d64_load_rom (char *rom_path, flashcart_progress_callback
|
|||||||
size_t sdram_size = MiB(64);
|
size_t sdram_size = MiB(64);
|
||||||
|
|
||||||
size_t chunk_size = KiB(128);
|
size_t chunk_size = KiB(128);
|
||||||
for (int offset = 0; offset < sdram_size; offset += chunk_size) {
|
for (unsigned int offset = 0; offset < sdram_size; offset += chunk_size) {
|
||||||
size_t block_size = MIN(sdram_size - offset, chunk_size);
|
size_t block_size = MIN(sdram_size - offset, chunk_size);
|
||||||
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
|
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
|
@ -232,7 +232,7 @@ static flashcart_err_t sc64_init (void) {
|
|||||||
{ CFG_ID_ROM_EXTENDED_ENABLE, false },
|
{ CFG_ID_ROM_EXTENDED_ENABLE, false },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(default_config) / sizeof(default_config[0]); i++) {
|
for (unsigned int i = 0; i < sizeof(default_config) / sizeof(default_config[0]); i++) {
|
||||||
if (sc64_ll_set_config(default_config[i].id, default_config[i].value) != SC64_OK) {
|
if (sc64_ll_set_config(default_config[i].id, default_config[i].value) != SC64_OK) {
|
||||||
return FLASHCART_ERR_INT;
|
return FLASHCART_ERR_INT;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ static flashcart_err_t sc64_load_rom (char *rom_path, flashcart_progress_callbac
|
|||||||
size_t extended_size = extended_enabled ? rom_size - MiB(64) : 0;
|
size_t extended_size = extended_enabled ? rom_size - MiB(64) : 0;
|
||||||
|
|
||||||
size_t chunk_size = KiB(128);
|
size_t chunk_size = KiB(128);
|
||||||
for (int offset = 0; offset < sdram_size; offset += chunk_size) {
|
for (unsigned int offset = 0; offset < sdram_size; offset += chunk_size) {
|
||||||
size_t block_size = MIN(sdram_size - offset, chunk_size);
|
size_t block_size = MIN(sdram_size - offset, chunk_size);
|
||||||
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
|
if (f_read(&fil, (void *) (ROM_ADDRESS + offset), block_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
@ -445,7 +445,7 @@ static flashcart_err_t sc64_load_64dd_ipl (char *ipl_path, flashcart_progress_ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t chunk_size = KiB(128);
|
size_t chunk_size = KiB(128);
|
||||||
for (int offset = 0; offset < ipl_size; offset += chunk_size) {
|
for (unsigned int offset = 0; offset < ipl_size; offset += chunk_size) {
|
||||||
size_t block_size = MIN(ipl_size - offset, chunk_size);
|
size_t block_size = MIN(ipl_size - offset, chunk_size);
|
||||||
if (f_read(&fil, (void *) (IPL_ADDRESS + offset), block_size, &br) != FR_OK) {
|
if (f_read(&fil, (void *) (IPL_ADDRESS + offset), block_size, &br) != FR_OK) {
|
||||||
f_close(&fil);
|
f_close(&fil);
|
||||||
@ -499,7 +499,7 @@ static flashcart_err_t sc64_load_64dd_disk (char *disk_path, flashcart_disk_para
|
|||||||
{ CFG_ID_BUTTON_MODE, BUTTON_MODE_DD_DISK_SWAP },
|
{ CFG_ID_BUTTON_MODE, BUTTON_MODE_DD_DISK_SWAP },
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(config) / sizeof(config[0]); i++) {
|
for (unsigned int i = 0; i < sizeof(config) / sizeof(config[0]); i++) {
|
||||||
if (sc64_ll_set_config(config[i].id, config[i].value) != SC64_OK) {
|
if (sc64_ll_set_config(config[i].id, config[i].value) != SC64_OK) {
|
||||||
return FLASHCART_ERR_INT;
|
return FLASHCART_ERR_INT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user