mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 11:14:39 +00:00
Refactor variable declarations and expressions for improved readability and consistency across multiple source files
This commit is contained in:
@@ -110,8 +110,8 @@ int cli_compare(const char *path1, const char *path2)
|
||||
read_result2 = aaruf_read_sector(ctx2, sector, buffer2, &buffer2_length);
|
||||
|
||||
// Handle read errors or missing sectors
|
||||
const bool sector1_available = (read_result1 == AARUF_STATUS_OK);
|
||||
const bool sector2_available = (read_result2 == AARUF_STATUS_OK);
|
||||
const bool sector1_available = read_result1 == AARUF_STATUS_OK;
|
||||
const bool sector2_available = read_result2 == AARUF_STATUS_OK;
|
||||
bool sectors_different = false;
|
||||
|
||||
if(!sector1_available && !sector2_available)
|
||||
@@ -149,7 +149,7 @@ int cli_compare(const char *path1, const char *path2)
|
||||
// Update progress every 1000 sectors or at the end
|
||||
if(sectors_processed % 1000 == 0 || sector == total_sectors - 1)
|
||||
{
|
||||
const int progress = (int)((sectors_processed * 100) / total_sectors);
|
||||
const int progress = (int)(sectors_processed * 100 / total_sectors);
|
||||
printf("Progress: %d%% (%llu/%llu sectors)\r", progress, (unsigned long long)sectors_processed,
|
||||
(unsigned long long)total_sectors);
|
||||
fflush(stdout);
|
||||
|
||||
@@ -30,7 +30,7 @@ void draw_progress_bar(int row, int percent)
|
||||
{
|
||||
const int width = tb_width() / 2;
|
||||
const int bar_width = width - 4; // leave space for borders
|
||||
const int filled = (bar_width * percent) / 100;
|
||||
const int filled = bar_width * percent / 100;
|
||||
|
||||
// Draw progress bar outline
|
||||
tb_printf(2, row, TB_YELLOW | TB_BOLD, TB_BLUE, "[");
|
||||
|
||||
@@ -88,7 +88,7 @@ int convert(const char *input_path, const char *output_path)
|
||||
if(sector % 1000 == 0 || sector == total_sectors - 1)
|
||||
{
|
||||
printf("\rProgress: %llu/%llu sectors (%.1f%%)", (unsigned long long)sector + 1,
|
||||
(unsigned long long)total_sectors, ((double)(sector + 1) / total_sectors) * 100.0);
|
||||
(unsigned long long)total_sectors, (double)(sector + 1) / total_sectors * 100.0);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ bool check_cd_sector_channel(CdEccContext *context, const uint8_t *sector, bool
|
||||
edc = 0;
|
||||
size = 0x810;
|
||||
pos = 0;
|
||||
for(; size > 0; size--) edc = (edc >> 8) ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
for(; size > 0; size--) edc = edc >> 8 ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
calculatedEdc = edc;
|
||||
|
||||
*edc_correct = calculatedEdc == storedEdc;
|
||||
@@ -128,7 +128,7 @@ bool check_cd_sector_channel(CdEccContext *context, const uint8_t *sector, bool
|
||||
edc = 0;
|
||||
size = 0x808;
|
||||
pos = 0x10;
|
||||
for(; size > 0; size--) edc = (edc >> 8) ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
for(; size > 0; size--) edc = edc >> 8 ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
calculatedEdc = edc;
|
||||
|
||||
*edc_correct = calculatedEdc == storedEdc;
|
||||
@@ -151,7 +151,7 @@ bool check_cd_sector_channel(CdEccContext *context, const uint8_t *sector, bool
|
||||
edc = 0;
|
||||
size = 0x808;
|
||||
pos = 0x10;
|
||||
for(; size > 0; size--) edc = (edc >> 8) ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
for(; size > 0; size--) edc = edc >> 8 ^ context->edc_table[(edc ^ sector[pos++]) & 0xFF];
|
||||
calculatedEdc = edc;
|
||||
|
||||
*edc_correct = calculatedEdc == storedEdc;
|
||||
|
||||
25
tool/info.c
25
tool/info.c
@@ -32,10 +32,9 @@ int info(const char *path)
|
||||
aaruformatContext *ctx = NULL;
|
||||
char *strBuffer = NULL;
|
||||
UErrorCode u_error_code = U_ZERO_ERROR;
|
||||
uint i = 0;
|
||||
mediaTagEntry const *mediaTag = NULL;
|
||||
mediaTagEntry const *tmpMediaTag = NULL;
|
||||
UChar ustr[128];
|
||||
uint i = 0;
|
||||
mediaTagEntry const *mediaTag = NULL;
|
||||
mediaTagEntry const *tmpMediaTag = NULL;
|
||||
|
||||
ctx = aaruf_open(path);
|
||||
|
||||
@@ -53,7 +52,7 @@ int info(const char *path)
|
||||
|
||||
strBuffer = malloc(65);
|
||||
memset(strBuffer, 0, 65);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, (const char *)ctx->header.application, 64, &u_error_code);
|
||||
ucnv_convert(NULL, "UTF-16LE", strBuffer, 64, ctx->header.application, 64, &u_error_code);
|
||||
if(u_error_code == U_ZERO_ERROR) printf("\tApplication: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
|
||||
@@ -285,7 +284,7 @@ int info(const char *path)
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].manufacturer),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].manufacturer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.manufacturerLength, &u_error_code);
|
||||
printf("\t\tManufacturer: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -296,7 +295,7 @@ int info(const char *path)
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.modelLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.modelLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].model),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].model,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.modelLength, &u_error_code);
|
||||
printf("\t\tModel: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -307,7 +306,7 @@ int info(const char *path)
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.revisionLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.revisionLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].revision),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].revision,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.revisionLength, &u_error_code);
|
||||
printf("\t\tRevision: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -318,7 +317,7 @@ int info(const char *path)
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].firmware),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].firmware,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.firmwareLength, &u_error_code);
|
||||
printf("\t\tFirmware version: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -329,7 +328,7 @@ int info(const char *path)
|
||||
strBuffer = malloc(ctx->dumpHardwareEntriesWithData[i].entry.serialLength + 1);
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.serialLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer, (int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].serial),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].serial,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.serialLength, &u_error_code);
|
||||
printf("\t\tSerial number: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -341,7 +340,7 @@ int info(const char *path)
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareName),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].softwareName,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareNameLength, &u_error_code);
|
||||
printf("\t\tSoftware name: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -353,7 +352,7 @@ int info(const char *path)
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareVersion),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].softwareVersion,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareVersionLength, &u_error_code);
|
||||
printf("\t\tSoftware version: %s\n", strBuffer);
|
||||
free(strBuffer);
|
||||
@@ -365,7 +364,7 @@ int info(const char *path)
|
||||
memset(strBuffer, 0, ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength + 1);
|
||||
ucnv_convert(NULL, "UTF-8", strBuffer,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength,
|
||||
(char *)(ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem),
|
||||
(char *)ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem,
|
||||
(int)ctx->dumpHardwareEntriesWithData[i].entry.softwareOperatingSystemLength,
|
||||
&u_error_code);
|
||||
printf("\t\tSoftware operating system: %s\n", strBuffer);
|
||||
|
||||
Reference in New Issue
Block a user