Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Is there a bug in bool is_locked (int fd, enum DATA_ZONE zone) fucntion #43

Description

@leomatrix

hi jbdatko:

maybe sentence : if (read4 (fd, CONFIG_ZONE, config_addr, &buf)) did'nt handle the case that read4() execution false, if read4() return false, however is_locked() return result still is true!!!! Am right?

bool is_locked (int fd, enum DATA_ZONE zone)
{
uint32_t buf = 0;
const uint8_t config_addr = 0x15;
uint8_t *ptr = (uint8_t *)&buf;
const uint8_t UNLOCKED = 0x55;
bool result = true;
const unsigned int CONFIG_ZONE_OFFSET = 3;
const unsigned int DATA_ZONE_OFFSET = 2;
unsigned int offset = 0;

switch (zone)
{
case CONFIG_ZONE:
offset = CONFIG_ZONE_OFFSET;
break;
case DATA_ZONE:
case OTP_ZONE:
offset = DATA_ZONE_OFFSET;
break;
default:
assert (false);
}

if (read4 (fd, CONFIG_ZONE, config_addr, &buf))
{
ptr = ptr + offset;
if (UNLOCKED == *ptr)
result = false;
else
result = true;
}

return result;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions