Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialised array in VL53L1_RdDWord #5

Open
eugen-vusak opened this issue Sep 16, 2019 · 2 comments
Open

Uninitialised array in VL53L1_RdDWord #5

eugen-vusak opened this issue Sep 16, 2019 · 2 comments

Comments

@eugen-vusak
Copy link

In function

VL53L1_Error VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data) {
    uint8_t buf[4];
    VL53L1_ReadMulti(Dev, index, (uint8_t *)data, 4);
    *data = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
    VL53L1_Error Status = VL53L1_ERROR_NONE;
    return Status;
}

I think that instead of

VL53L1_ReadMulti(Dev, index, (uint8_t *)data, 4);

it should be

VL53L1_ReadMulti(Dev, index, (uint8_t *)buf, 4);

because that is only thing that makes sense.

@eugen-vusak eugen-vusak changed the title Possible typo Uninitialised array in VL53L1_RdDWord Sep 16, 2019
@braincore
Copy link
Owner

Good find! VL53L1_RdDWord must not be called by anything I've used. How did you discover this?

@eugen-vusak
Copy link
Author

I was writing my version of C++ port for VL53L1x API, so I borrowed some of the code and cppcheck pointed this out as warning saying that buf array was uninitialised. But yes this function is not used anywhere in rest of the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants