Skip to contentSkip to conversation

Remove wrapper function and clean up the code

PATCH In review Shivani Bhardwaj 2 participants 6 messages Nov 2, 2015 – Nov 4, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Remove wrapper function and clean up the code

This patchset removes a wrapper function, its prototype and replace its calls in different files with a standard function.
After applying this patch, code becomes cleaner.

Shivani Bhardwaj (3):
Staging: lustre: tracefile: Remove wrapper function
Staging: lustre: tracefile: Remove function prototype
Staging: lustre: module: Replace function calls

 drivers/staging/lustre/lustre/libcfs/module.c    | 4 ++--
 drivers/staging/lustre/lustre/libcfs/tracefile.c | 9 ++-------
 drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
 3 files changed, 4 insertions(+), 10 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/3 Staging: lustre: tracefile: Remove wrapper function

Remove the function cfs_trace_free_string_buffer() as it can be replaced with the standard function kfree().

---
 drivers/staging/lustre/lustre/libcfs/tracefile.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/libcfs/tracefile.c +2 -7
index 973c7c2..54835fc 100644
@@ -817,11 +817,6 @@ int cfs_trace_allocate_string_buffer(char **str, int nob)
 	return 0;
 }
 
-void cfs_trace_free_string_buffer(char *str, int nob)
-{
-	kfree(str);
-}
-
 int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob)
 {
 	char	 *str;
@@ -842,7 +837,7 @@ int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob)
 	}
 	rc = cfs_tracefile_dump_all_pages(str);
 out:
-	cfs_trace_free_string_buffer(str, usr_str_nob + 1);
+	kfree(str);
 	return rc;
 }
 
@@ -898,7 +893,7 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob)
 	if (rc == 0)
 		rc = cfs_trace_daemon_command(str);
 
-	cfs_trace_free_string_buffer(str, usr_str_nob + 1);
+	kfree(str);
 	return rc;
 }
 
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/3 Staging: lustre: tracefile: Remove function prototype

In reply to Shivani Bhardwaj

Remove the prototype of function cfs_trace_free_string_buffer() as it is no longer needed.

---
 drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/lustre/lustre/libcfs/tracefile.h +0 -1
index cb7a396..4d5fdaf 100644
@@ -70,7 +70,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
 int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,
 			     const char *knl_str, char *append);
 int cfs_trace_allocate_string_buffer(char **str, int nob);
-void cfs_trace_free_string_buffer(char *str, int nob);
 int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob);
 int cfs_trace_daemon_command(char *str);
 int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob);
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/3 Staging: lustre: module: Replace function calls

In reply to Shivani Bhardwaj

Replace the calls of function cfs_trace_free_string_buffer() with kfree() as the former function is not required.

---
 drivers/staging/lustre/lustre/libcfs/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +2 -2
index 50e8fd2..516a9e7 100644
@@ -392,7 +392,7 @@ static int __proc_dobitmasks(void *data, int write,
 	} else {
 		rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
 		if (rc < 0) {
-			cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+			kfree(tmpstr);
 			return rc;
 		}
 
@@ -402,7 +402,7 @@ static int __proc_dobitmasks(void *data, int write,
 			*mask |= D_EMERG;
 	}
 
-	cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+	kfree(tmpstr);
 	return rc;
 }
 
Signature · 1 line
2.1.0
maintainer
#4 lore raw

Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: module: Replace function calls

Quoted 22 lines · Shivani Bhardwaj

Replace the calls of function cfs_trace_free_string_buffer() with kfree() as the former function is not required.

---
 drivers/staging/lustre/lustre/libcfs/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
index 50e8fd2..516a9e7 100644
@@ -392,7 +392,7 @@ static int __proc_dobitmasks(void *data, int write,
 	} else {
 		rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
 		if (rc < 0) {
-			cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+			kfree(tmpstr);
 			return rc;
 		}
 

drivers/staging/lustre/lustre/libcfs/module.c static int __proc_dobitmasks(void *data, int write, · line 408

Quoted 8 lines
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
@@ -402,7 +402,7 @@ static int __proc_dobitmasks(void *data, int write,
 			*mask |= D_EMERG;
 	}
 
-	cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+	kfree(tmpstr);
 	return rc;
 }
 

Don't you need this to be earlier in the series? You just deleted the function from the kernel in the first patch :(

Never break the build for any patch in a series. Please reorder and resend.

thanks,

greg k-h

#5 lore raw

Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: module: Replace function calls

Quoted 35 lines · Greg KH
Quoted 22 lines · Shivani Bhardwaj

Replace the calls of function cfs_trace_free_string_buffer() with kfree() as the former function is not required.

---
 drivers/staging/lustre/lustre/libcfs/module.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
index 50e8fd2..516a9e7 100644
@@ -392,7 +392,7 @@ static int __proc_dobitmasks(void *data, int write,
      } else {
              rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
              if (rc < 0) {
-                     cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+                     kfree(tmpstr);
                      return rc;
              }
 

drivers/staging/lustre/lustre/libcfs/module.c static int __proc_dobitmasks(void *data, int write, · line 408

Quoted 8 lines
drivers/staging/lustre/lustre/libcfs/module.c +1 -1
@@ -402,7 +402,7 @@ static int __proc_dobitmasks(void *data, int write,
                      *mask |= D_EMERG;
      }
 
-     cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+     kfree(tmpstr);
      return rc;
 }
 

Don't you need this to be earlier in the series? You just deleted the function from the kernel in the first patch :(

Quoted 3 lines

Never break the build for any patch in a series. Please reorder and resend.

I'm sorry for the mistake. I'm resending.
Thank you

Quoted 3 lines

thanks,

greg k-h