From 2ff6b64efd7f3d1a06650fce402f9cdc2e0df2b4 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 10 Mar 2025 11:44:43 +0000 Subject: [PATCH] media: camera: Fix declaration-after-statement The camera driver fails to build if the compiler option -Werror=declaration-after-statement is enabled and the following error is seen ... drivers/media/platform/tegra/camera/tegracam_ctrls.c:1120:17: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 1120 | int index = tegracam_get_ctrl_index(cid); | ^~~ JIRA CAMERASW-32529 Fix this by moving the declaration of the 'index' and 'size' variables to the start of the for-loop code block. Change-Id: I69590c147e8effd031b962606a077856ad4f8d07 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3316537 GVS: buildbot_gerritrpt Reviewed-by: Frank Chen Reviewed-by: svcacv Reviewed-by: Mike Jia --- drivers/media/platform/tegra/camera/tegracam_ctrls.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/tegra/camera/tegracam_ctrls.c b/drivers/media/platform/tegra/camera/tegracam_ctrls.c index 4d72c140..56082a9c 100644 --- a/drivers/media/platform/tegra/camera/tegracam_ctrls.c +++ b/drivers/media/platform/tegra/camera/tegracam_ctrls.c @@ -1108,6 +1108,9 @@ int tegracam_ctrl_handler_init(struct tegracam_ctrl_handler *handler) err = v4l2_ctrl_handler_init(&handler->ctrl_handler, numctrls); for (i = 0, j = 0; i < numctrls; i++) { + int index; + int size = 0; + if (i < ops->numctrls) { cid = cids[i]; } else { @@ -1117,8 +1120,8 @@ int tegracam_ctrl_handler_init(struct tegracam_ctrl_handler *handler) return -EINVAL; } } - int index = tegracam_get_ctrl_index(cid); - int size = 0; + + index = tegracam_get_ctrl_index(cid); if (index >= ARRAY_SIZE(ctrl_cfg_list)) { dev_err(dev, "unsupported control in the list\n"); return -ENOTTY;