mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 11:14:39 +00:00
Refactor variable declarations for improved scope and clarity in multiple source files
This commit is contained in:
@@ -80,9 +80,7 @@ int32_t process_data_block(aaruformatContext *ctx, IndexEntry *entry)
|
||||
mediaTagEntry *old_media_tag = NULL;
|
||||
mediaTagEntry *media_tag = NULL;
|
||||
uint8_t *data = NULL;
|
||||
int error_no = 0;
|
||||
uint8_t lzma_properties[LZMA_PROPERTIES_LENGTH];
|
||||
uint64_t crc64 = 0;
|
||||
|
||||
// Check if the context and image stream are valid
|
||||
if(ctx == NULL || ctx->imageStream == NULL)
|
||||
@@ -154,6 +152,7 @@ int32_t process_data_block(aaruformatContext *ctx, IndexEntry *entry)
|
||||
|
||||
if(block_header.compression == Lzma || block_header.compression == LzmaClauniaSubchannelTransform)
|
||||
{
|
||||
int error_no = 0;
|
||||
if(block_header.compression == LzmaClauniaSubchannelTransform && block_header.type != CdSectorSubchannel)
|
||||
{
|
||||
TRACE("Invalid compression type %d for block with data type %d, continuing...", block_header.compression,
|
||||
@@ -283,7 +282,7 @@ int32_t process_data_block(aaruformatContext *ctx, IndexEntry *entry)
|
||||
|
||||
if(block_header.length > 0)
|
||||
{
|
||||
crc64 = aaruf_crc64_data(data, block_header.length);
|
||||
uint64_t crc64 = aaruf_crc64_data(data, block_header.length);
|
||||
|
||||
// Due to how C# wrote it, it is effectively reversed
|
||||
if(ctx->header.imageMajorVersion <= AARUF_VERSION_V1) crc64 = bswap_64(crc64);
|
||||
|
||||
@@ -37,7 +37,6 @@ void process_dumphw_block(aaruformatContext *ctx, const IndexEntry *entry)
|
||||
TRACE("Entering process_dumphw_block(%p, %p)", ctx, entry);
|
||||
int pos = 0;
|
||||
size_t read_bytes = 0;
|
||||
uint64_t crc64 = 0;
|
||||
uint16_t e = 0;
|
||||
uint8_t *data = NULL;
|
||||
|
||||
@@ -93,7 +92,7 @@ void process_dumphw_block(aaruformatContext *ctx, const IndexEntry *entry)
|
||||
|
||||
if(read_bytes == ctx->dumpHardwareHeader.length)
|
||||
{
|
||||
crc64 = aaruf_crc64_data(data, ctx->dumpHardwareHeader.length);
|
||||
uint64_t crc64 = aaruf_crc64_data(data, ctx->dumpHardwareHeader.length);
|
||||
|
||||
// Due to how C# wrote it, it is effectively reversed
|
||||
if(ctx->header.imageMajorVersion <= AARUF_VERSION_V1) crc64 = bswap_64(crc64);
|
||||
|
||||
@@ -126,7 +126,6 @@ int aaruf_close(void *context)
|
||||
{
|
||||
TRACE("Entering aaruf_close(%p)", context);
|
||||
|
||||
int i = 0;
|
||||
mediaTagEntry *media_tag = NULL;
|
||||
mediaTagEntry *tmp_media_tag = NULL;
|
||||
|
||||
@@ -661,7 +660,7 @@ int aaruf_close(void *context)
|
||||
|
||||
if(ctx->dumpHardwareEntriesWithData != NULL)
|
||||
{
|
||||
for(i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
||||
for(int i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
||||
{
|
||||
free(ctx->dumpHardwareEntriesWithData[i].extents);
|
||||
ctx->dumpHardwareEntriesWithData[i].extents = NULL;
|
||||
|
||||
@@ -763,7 +763,6 @@ int32_t decode_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sector_addres
|
||||
size_t lzma_size = 0;
|
||||
uint8_t *cmp_data = NULL;
|
||||
uint8_t *buffer = NULL;
|
||||
int32_t error_no = 0;
|
||||
crc64_ctx *crc64_context = NULL;
|
||||
uint64_t crc64 = 0;
|
||||
int items_per_ddt_entry = 0;
|
||||
@@ -810,6 +809,7 @@ int32_t decode_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sector_addres
|
||||
// Is the one we have cached the same as the one we need to read?
|
||||
if(ctx->cachedDdtOffset != secondary_ddt_offset)
|
||||
{
|
||||
int32_t error_no = 0;
|
||||
fseek(ctx->imageStream, secondary_ddt_offset, SEEK_SET);
|
||||
DdtHeader2 ddt_header;
|
||||
size_t read_bytes = fread(&ddt_header, 1, sizeof(DdtHeader2), ctx->imageStream);
|
||||
|
||||
@@ -46,7 +46,7 @@ void *find_in_cache(struct CacheHeader *cache, const char *key)
|
||||
*/
|
||||
void add_to_cache(struct CacheHeader *cache, const char *key, void *value)
|
||||
{
|
||||
struct CacheEntry *entry, *tmp_entry;
|
||||
struct CacheEntry *entry;
|
||||
// TODO: Is this needed or we're just losing cycles? uthash does not free the entry
|
||||
entry = malloc(sizeof(struct CacheEntry));
|
||||
entry->key = strdup(key);
|
||||
@@ -56,6 +56,7 @@ void add_to_cache(struct CacheHeader *cache, const char *key, void *value)
|
||||
// prune the cache to MAX_CACHE_SIZE
|
||||
if(HASH_COUNT(cache->cache) >= cache->max_items)
|
||||
{
|
||||
struct CacheEntry *tmp_entry;
|
||||
HASH_ITER(hh, cache->cache, entry, tmp_entry)
|
||||
{
|
||||
// prune the first entry (loop is based on insertion order so this deletes the oldest item)
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unknown, bool *has_edc, bool *edc_correct,
|
||||
bool *has_ecc_p, bool *ecc_p_correct, bool *has_ecc_q, bool *ecc_q_correct)
|
||||
{
|
||||
int i = 0;
|
||||
uint32_t storedEdc = 0, edc = 0, calculatedEdc = 0;
|
||||
int size = 0, pos = 0;
|
||||
uint8_t zeroaddress[4];
|
||||
@@ -48,7 +47,7 @@ bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unkno
|
||||
|
||||
if((sector[0x00F] & 0x03) == 0x00) // Mode 0
|
||||
{
|
||||
for(i = 0x010; i < 0x930; i++)
|
||||
for(int i = 0x010; i < 0x930; i++)
|
||||
if(sector[i] != 0x00)
|
||||
{
|
||||
fprintf(stderr, "Mode 0 sector with error at address: %2X:%2X:%2X.\n", sector[0x00C], sector[0x00D],
|
||||
|
||||
@@ -32,7 +32,7 @@ int info(const char *path)
|
||||
aaruformatContext *ctx = NULL;
|
||||
char *strBuffer = NULL;
|
||||
UErrorCode u_error_code = U_ZERO_ERROR;
|
||||
uint i = 0, j = 0;
|
||||
uint i = 0;
|
||||
mediaTagEntry const *mediaTag = NULL;
|
||||
mediaTagEntry const *tmpMediaTag = NULL;
|
||||
UChar ustr[128];
|
||||
@@ -372,7 +372,7 @@ int info(const char *path)
|
||||
free(strBuffer);
|
||||
}
|
||||
|
||||
for(j = 0; j < ctx->dumpHardwareEntriesWithData[i].entry.extents; j++)
|
||||
for(uint j = 0; j < ctx->dumpHardwareEntriesWithData[i].entry.extents; j++)
|
||||
{
|
||||
printf("\t\tExtent %d:\n", j);
|
||||
printf("\t\t\tStart: %llu\n", ctx->dumpHardwareEntriesWithData[i].extents[j].start);
|
||||
|
||||
Reference in New Issue
Block a user