mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Cast sector status values to uint64_t for correct bitwise operations in write.c
This commit is contained in:
18
src/write.c
18
src/write.c
@@ -811,13 +811,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
const bool suffix_correct = aaruf_ecc_cd_is_suffix_correct(context, data);
|
const bool suffix_correct = aaruf_ecc_cd_is_suffix_correct(context, data);
|
||||||
|
|
||||||
if(suffix_correct)
|
if(suffix_correct)
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode1Correct << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)SectorStatusMode1Correct << 60;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2064, 288);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2064, 288);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] |= (uint64_t)SectorStatusErrored << 60;
|
||||||
ctx->sector_suffix_offset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
@@ -942,7 +942,7 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
|
|
||||||
if(prefix_correct)
|
if(prefix_correct)
|
||||||
ctx->sector_prefix_ddt2[corrected_sector_address] =
|
ctx->sector_prefix_ddt2[corrected_sector_address] =
|
||||||
(form2 ? SectorStatusMode2Form2Ok : SectorStatusMode2Form1Ok) << 60;
|
(uint64_t)(form2 ? SectorStatusMode2Form2Ok : SectorStatusMode2Form1Ok) << 60;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD prefix from data buffer to prefix buffer
|
// Copy CD prefix from data buffer to prefix buffer
|
||||||
@@ -990,16 +990,18 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
const bool correct_edc = computed_edc == edc;
|
const bool correct_edc = computed_edc == edc;
|
||||||
|
|
||||||
if(correct_edc)
|
if(correct_edc)
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2Ok << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)SectorStatusMode2Form2Ok
|
||||||
|
<< 60;
|
||||||
else if(edc == 0)
|
else if(edc == 0)
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form2NoCrc << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)SectorStatusMode2Form2NoCrc
|
||||||
|
<< 60;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2348, 4);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2348, 4);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] =
|
ctx->sector_suffix_ddt2[corrected_sector_address] =
|
||||||
(uint64_t)(ctx->sector_suffix_offset / 288);
|
(uint64_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] |= (uint64_t)SectorStatusErrored << 60;
|
||||||
ctx->sector_suffix_offset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
@@ -1034,13 +1036,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
|
|||||||
const bool correct_edc = computed_edc == edc;
|
const bool correct_edc = computed_edc == edc;
|
||||||
|
|
||||||
if(correct_ecc && correct_edc)
|
if(correct_ecc && correct_edc)
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = SectorStatusMode2Form1Ok << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)SectorStatusMode2Form1Ok << 60;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy CD suffix from data buffer to suffix buffer
|
// Copy CD suffix from data buffer to suffix buffer
|
||||||
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2072, 280);
|
memcpy(ctx->sector_suffix + ctx->sector_suffix_offset, data + 2072, 280);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
|
ctx->sector_suffix_ddt2[corrected_sector_address] = (uint64_t)(ctx->sector_suffix_offset / 288);
|
||||||
ctx->sector_suffix_ddt2[corrected_sector_address] |= SectorStatusErrored << 60;
|
ctx->sector_suffix_ddt2[corrected_sector_address] |= (uint64_t)SectorStatusErrored << 60;
|
||||||
ctx->sector_suffix_offset += 288;
|
ctx->sector_suffix_offset += 288;
|
||||||
|
|
||||||
// Grow suffix buffer if needed
|
// Grow suffix buffer if needed
|
||||||
|
|||||||
Reference in New Issue
Block a user