[libcamera-devel] [PATCH 09/10] android: metadata: Prevent variable aliasing
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Oct 14 14:42:07 CEST 2020
Hi Kieran,
On 2020-10-13 16:12:40 +0100, Kieran Bingham wrote:
> The validate_camera_metadata_structure() call uses two instances of a
> variable named aligned_ptr().
>
> Reuse the first instance which is not otherwise re-used for the second
> scoped usage.
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> *** This is in android metadata library code ***
>
> This is only here as a temporary repair. Ideally we shouldn't make changes to this code base.
> disabling the warning on this library component is likely a better choice.
>
> src/android/metadata/camera_metadata.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/android/metadata/camera_metadata.c b/src/android/metadata/camera_metadata.c
> index b86586a7e685..129d1e92ece1 100644
> --- a/src/android/metadata/camera_metadata.c
> +++ b/src/android/metadata/camera_metadata.c
> @@ -433,7 +433,7 @@ int validate_camera_metadata_structure(const camera_metadata_t *metadata,
> };
>
> for (size_t i = 0; i < sizeof(alignments)/sizeof(alignments[0]); ++i) {
> - uintptr_t aligned_ptr = ALIGN_TO((uintptr_t) metadata + alignmentOffset,
> + aligned_ptr = ALIGN_TO((uintptr_t) metadata + alignmentOffset,
This is a tricky one. As you say ideally we should fix this upstream and
backport it. But being able to enable the build time warning of our own
code base would be really nice. As we already inject a SPDX header to
this file I see no real harm, with a patch submitted for upstream,
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> alignments[i].alignment);
>
> if ((uintptr_t)metadata + alignmentOffset != aligned_ptr) {
> --
> 2.25.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list