Skip to contentSkip to conversation

dlm: replace one-element array with fixed size array

PATCH In review Paulo Miguel Almeida 2 participants 5 messages Oct 11, 2022 Distributed lock manager (DLM)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlm: replace one-element array with fixed size array

One-element arrays are deprecated. So, replace one-element array with fixed size array member in struct dlm_ls, and refactor the rest of the code, accordingly.

---
 fs/dlm/dlm_internal.h | 2 +-
 fs/dlm/lockspace.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/dlm/dlm_internal.h +1 -1
index e34c3d2639a5..94fadb619ba0 100644
@@ -670,7 +670,7 @@ struct dlm_ls {
 	void			*ls_ops_arg;
 
 	int			ls_namelen;
-	char			ls_name[1];
+	char			ls_name[DLM_LOCKSPACE_LEN + 1];
 };
 
 /*
fs/dlm/lockspace.c +1 -1
index bae050df7abf..23de0d47cbc1 100644
@@ -473,7 +473,7 @@ static int new_lockspace(const char *name, const char *cluster,
 
 	error = -ENOMEM;
 
-	ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS);
+	ls = kzalloc(sizeof(struct dlm_ls), GFP_NOFS);
 	if (!ls)
 		goto out;
 	memcpy(ls->ls_name, name, namelen);
Signature · 1 line
2.37.3
#1 lore raw
Quoted 10 lines · Paulo Miguel Almeida

One-element arrays are deprecated. So, replace one-element array with fixed size array member in struct dlm_ls, and refactor the rest of the code, accordingly.

I think this should be versioned as v3.

Quoted 23 lines
---
 fs/dlm/dlm_internal.h | 2 +-
 fs/dlm/lockspace.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/dlm/dlm_internal.h +1 -1
index e34c3d2639a5..94fadb619ba0 100644
@@ -670,7 +670,7 @@ struct dlm_ls {
 	void			*ls_ops_arg;
 
 	int			ls_namelen;
-	char			ls_name[1];
+	char			ls_name[DLM_LOCKSPACE_LEN + 1];
 };
 
 /*
fs/dlm/lockspace.c +0 -0
index bae050df7abf..23de0d47cbc1 100644

fs/dlm/lockspace.c static int new_lockspace(const char *name, const char *cluster, · line 476

Quoted 5 lines
fs/dlm/lockspace.c +1 -1
@@ -473,7 +473,7 @@ static int new_lockspace(const char *name, const char *cluster,
 
 	error = -ENOMEM;
 
-	ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS);
+	ls = kzalloc(sizeof(struct dlm_ls), GFP_NOFS);

sizeof(*ls) is preferred here....^^^

--
Gustavo

#2 lore raw
Quoted 5 lines · Gustavo A. R. Silva
Quoted 4 lines · Paulo Miguel Almeida

One-element arrays are deprecated. So, replace one-element array with fixed size array member in struct dlm_ls, and refactor the rest of the code, accordingly.

Quoted 9 lines
Quoted 6 lines

I think this should be versioned as v3.

I didn't add v3 here because the the patch got changed from 'replacing [1]-array with flex-array' to 'replacing [1]-array to fixed-size array'.

Let me know if you still want me to send it as v3 instead.

Paulo A.

#3 lore raw
Quoted 11 lines · Paulo Miguel Almeida
Quoted 10 lines · Gustavo A. R. Silva
Quoted 9 lines · Paulo Miguel Almeida

One-element arrays are deprecated. So, replace one-element array with fixed size array member in struct dlm_ls, and refactor the rest of the code, accordingly.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I think this should be versioned as v3.

I didn't add v3 here because the the patch got changed from 'replacing [1]-array with flex-array' to 'replacing [1]-array to fixed-size array'.

The issue remains the same, and there have been comments and feedback on previous patches. So, yep, v3 seems appropiate for this patch. :)

Quoted 2 lines

Let me know if you still want me to send it as v3 instead.

I think next one would be v4.

Also, when versioning patches it is also necessary to include a version change log.

Thanks
--
Gustavo

#4 lore raw
Quoted 9 lines · Gustavo A. R. Silva
Quoted 3 lines · Paulo Miguel Almeida
Quoted 1 line

I didn't add v3 here because the the patch got changed from 'replacing [1]-array with flex-array' to 'replacing [1]-array to fixed-size array'.

The issue remains the same, and there have been comments and feedback on previous patches. So, yep, v3 seems appropiate for this patch. :)

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Let me know if you still want me to send it as v3 instead.

I think next one would be v4.

Also, when versioning patches it is also necessary to include a version change log.

Fair enough. Will send a v4

Paulo A.