[libcamera-devel,v3,09/11] ipa: raspberrypi: Re-use iterator variable
diff mbox series

Message ID 20201016090014.64703-10-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • Shadowed Variables
Related show

Commit Message

Kieran Bingham Oct. 16, 2020, 9 a.m. UTC
The function gauss_seidel2_SOR() makes use of a function scoped iterator
'i', for several loops, and has a precedence of re-using the function
scoped iterator declaration in the majority of cases, except the first
where it is declared in the loop scope before the function scope, and
later which aliases a new declaration.

Re-use the existing iterator variable for consistency, and to prevent
variable aliasing.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/ipa/raspberrypi/controller/rpi/alsc.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
index 42fbc8a476ad..183a0c953b9f 100644
--- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp
@@ -606,9 +606,9 @@  static double gauss_seidel2_SOR(double const M[XY][4], double omega,
 				double lambda[XY])
 {
 	double old_lambda[XY];
-	for (int i = 0; i < XY; i++)
-		old_lambda[i] = lambda[i];
 	int i;
+	for (i = 0; i < XY; i++)
+		old_lambda[i] = lambda[i];
 	lambda[0] = compute_lambda_bottom_start(0, M, lambda);
 	for (i = 1; i < X; i++)
 		lambda[i] = compute_lambda_bottom(i, M, lambda);
@@ -628,7 +628,7 @@  static double gauss_seidel2_SOR(double const M[XY][4], double omega,
 		lambda[i] = compute_lambda_bottom(i, M, lambda);
 	lambda[0] = compute_lambda_bottom_start(0, M, lambda);
 	double max_diff = 0;
-	for (int i = 0; i < XY; i++) {
+	for (i = 0; i < XY; i++) {
 		lambda[i] = old_lambda[i] + (lambda[i] - old_lambda[i]) * omega;
 		if (fabs(lambda[i] - old_lambda[i]) > fabs(max_diff))
 			max_diff = lambda[i] - old_lambda[i];