linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer
@ 2022-10-08  9:39 XU pengfei
  2022-10-08 12:21 ` Miaohe Lin
  2022-10-08 13:14 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: XU pengfei @ 2022-10-08  9:39 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, XU pengfei

Pointer variables allocate memory first, and then judge. There is no
need to initialize the assignment.

Signed-off-by: XU pengfei <xupengfei@nfschina.com>
---
 mm/mmap_lock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
index 1854850b4b89..65a57731aa15 100644
--- a/mm/mmap_lock.c
+++ b/mm/mmap_lock.c
@@ -198,7 +198,7 @@ void trace_mmap_lock_unreg(void)
  */
 static const char *get_mm_memcg_path(struct mm_struct *mm)
 {
-	char *buf = NULL;
+	char *buf;
 	struct mem_cgroup *memcg = get_mem_cgroup_from_mm(mm);
 
 	if (memcg == NULL)
-- 
2.18.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH 1/1] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer
@ 2022-10-09  3:41 XU pengfei
  0 siblings, 0 replies; 4+ messages in thread
From: XU pengfei @ 2022-10-09  3:41 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, XU pengfei

Remove unnecessary 'NULL' values from Pointer and goto statement

Signed-off-by: XU pengfei <xupengfei@nfschina.com>
---
 mm/mmap_lock.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
index 1854850b4b89..d0c2a5eae341 100644
--- a/mm/mmap_lock.c
+++ b/mm/mmap_lock.c
@@ -198,23 +198,24 @@ void trace_mmap_lock_unreg(void)
  */
 static const char *get_mm_memcg_path(struct mm_struct *mm)
 {
-	char *buf = NULL;
+	char *buf;
 	struct mem_cgroup *memcg = get_mem_cgroup_from_mm(mm);
 
 	if (memcg == NULL)
-		goto out;
-	if (unlikely(memcg->css.cgroup == NULL))
-		goto out_put;
+		return NULL;
+	if (unlikely(memcg->css.cgroup == NULL)) {
+		css_put(&memcg->css);
+		return NULL;
+	}
 
 	buf = get_memcg_path_buf();
-	if (buf == NULL)
-		goto out_put;
+	if (buf == NULL) {
+		css_put(&memcg->css);
+		return NULL;
+	}
 
 	cgroup_path(memcg->css.cgroup, buf, MEMCG_PATH_BUF_SIZE);
 
-out_put:
-	css_put(&memcg->css);
-out:
 	return buf;
 }
 
-- 
2.18.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-09  3:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-08  9:39 [PATCH 1/1] mm/mmap_lock: Remove unnecessary 'NULL' values from Pointer XU pengfei
2022-10-08 12:21 ` Miaohe Lin
2022-10-08 13:14 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-10-09  3:41 XU pengfei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).