[libcamera-devel] [PATCH 09/10] android: metadata: Prevent variable aliasing

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Oct 13 17:12:40 CEST 2020


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,
                     alignments[i].alignment);
 
             if ((uintptr_t)metadata + alignmentOffset != aligned_ptr) {
-- 
2.25.1



More information about the libcamera-devel mailing list