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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3316537
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mike Jia <mijia@nvidia.com>
This commit is contained in:
Jon Hunter
2025-03-10 11:44:43 +00:00
parent 8895bf14e8
commit 2ff6b64efd

View File

@@ -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;