Skip to contentSkip to conversation

Staging: lustre: Convert array index from the loop bound to the loop index.

PATCH Superseded Sandhya Bankar 1 participant 1 message Sep 17, 2016 Staging

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Staging: lustre: Convert array index from the loop bound to the loop index.

Convert array index from the loop bound to the loop index.

The structure cl_env_percpu[NR_CPUS] has been initializing for each possible cpu (i.e 0 to i). During initialization if any error will occurred, the error handling code should uninitialize cl_env_percpu upto i. But currently unitialization is repeatedly done for the same cl_env_percpu[i] element. This does not seems to be correct.

Used below semantic patch to identify this issue:

@@
expression e1,e2,ar;
@@

for(e1 = 0; e1 < e2; e1++) { <...
ar[
- e2
+ e1
]
...> }

---
Changes in v3:
* Incorporating suggestion regarding commit message.

 drivers/staging/lustre/lustre/obdclass/cl_object.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/lustre/lustre/obdclass/cl_object.c +1 -1
index 91a5806..eeccd30 100755
@@ -1000,7 +1000,7 @@ static int cl_env_percpu_init(void)
 		 * thus we must uninitialize up to i, the rest are undefined.
 		 */
 		for (j = 0; j < i; j++) {
-			cle = &cl_env_percpu[i];
+			cle = &cl_env_percpu[j];
 			lu_context_exit(&cle->ce_ses);
 			lu_context_fini(&cle->ce_ses);
 			lu_env_fini(&cle->ce_lu);
Signature · 1 line
1.7.1