Skip to contentSkip to conversation

Remove unnecessary null pointer checks?

Cocci Applied SF Markus Elfring 178 participants 1,551 messages Feb 21, 2014 – Apr 12, 2017 3 messages not in the archive Page 2 of 6

Subsystems (270)
lore
Share & tools
lore
Applied
#234 lore raw

Re: [PATCH 1/1] ALSA: ice17xx: Deletion of unnecessary checks before the function call "snd_ac97_resume"

In reply to SF Markus Elfring

At Mon, 17 Nov 2014 11:34:22 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 11:28:02 +0100

The snd_ac97_resume() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 37 lines
---
 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/ice1724.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
sound/pci/ice1712/ice1712.c +1 -2
index 87f7fc4..e1e18b5 100644
@@ -2905,8 +2905,7 @@ static int snd_ice1712_resume(struct device *dev)
 	outw(ice->pm_saved_spdif_ctrl, ICEMT(ice, ROUTE_SPDOUT));
 	outw(ice->pm_saved_route, ICEMT(ice, ROUTE_PSDOUT03));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
sound/pci/ice1712/ice1724.c +1 -2
index 08cb08a..0e56835 100644
@@ -2884,8 +2884,7 @@ static int snd_vt1724_resume(struct device *dev)
 	outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG));
 	outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK));
 
-	if (ice->ac97)
-		snd_ac97_resume(ice->ac97);
+	snd_ac97_resume(ice->ac97);
 
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
Signature · 1 line
2.1.3
#235 lore raw

PATCH 1/1 ALSA: lola: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/lola/lola_mixer.c +1 -2
index 782f4d8..e7fe15d 100644
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
Signature · 1 line
2.1.3
Applied
#236 lore raw

Re: [PATCH 1/1] ALSA: lola: Deletion of an unnecessary check before the function call "vfree"

At Mon, 17 Nov 2014 12:48:44 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 12:42:16 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 22 lines
---
 sound/pci/lola/lola_mixer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/lola/lola_mixer.c +1 -2
index 782f4d8..e7fe15d 100644
@@ -108,8 +108,7 @@ int lola_init_pins(struct lola *chip, int dir, int *nidp)
 
 void lola_free_mixer(struct lola *chip)
 {
-	if (chip->mixer.array_saved)
-		vfree(chip->mixer.array_saved);
+	vfree(chip->mixer.array_saved);
 }
 
 int lola_init_mixer_widget(struct lola *chip, int nid)
Signature · 1 line
2.1.3
#237 lore raw

PATCH 1/1 ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/rme9652/hdsp.c +1 -2
index 7646ba1..0ae568d 100644
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
Signature · 1 line
2.1.3
Applied
#238 lore raw

Re: [PATCH 1/1] ALSA: hdsp: Deletion of an unnecessary check before the function call "release_firmware"

At Mon, 17 Nov 2014 13:12:15 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 13:04:14 +0100

The release_firmware() function tests whether its argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 22 lines
---
 sound/pci/rme9652/hdsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/rme9652/hdsp.c +1 -2
index 7646ba1..0ae568d 100644
@@ -5368,8 +5368,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
 	snd_hdsp_free_buffers(hdsp);
 
-	if (hdsp->firmware)
-		release_firmware(hdsp->firmware);
+	release_firmware(hdsp->firmware);
 	vfree(hdsp->fw_uploaded);
 
 	if (hdsp->iobase)
Signature · 1 line
2.1.3
#239 lore raw

PATCH 1/1 ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/ppc/pmac.c +1 -2
index 8a431bc..5a13b22 100644
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
Signature · 1 line
2.1.3
Applied
#240 lore raw

Re: [PATCH 1/1] ALSA: powermac: Deletion of an unnecessary check before the function call "pci_dev_put"

At Mon, 17 Nov 2014 13:41:19 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 13:35:54 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 22 lines
---
 sound/ppc/pmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/ppc/pmac.c +1 -2
index 8a431bc..5a13b22 100644
@@ -887,8 +887,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
 		}
 	}
 
-	if (chip->pdev)
-		pci_dev_put(chip->pdev);
+	pci_dev_put(chip->pdev);
 	of_node_put(chip->node);
 	kfree(chip);
 	return 0;
Signature · 1 line
2.1.3
#241 lore raw

ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/soc/omap/mcbsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/omap/mcbsp.c +1 -2
index 86c7538..68a1252 100644
@@ -621,8 +621,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
 	mcbsp->reg_cache = NULL;
 	spin_unlock(&mcbsp->lock);
 
-	if (reg_cache)
-		kfree(reg_cache);
+	kfree(reg_cache);
 }
 
 /*
Signature · 1 line
2.1.3
Acked-by
#242 lore raw

Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

Quoted 7 lines

This issue was detected by using the Coccinelle software.

---
 sound/soc/omap/mcbsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
maintainer Applied
#243 lore raw

Re: ASoC: omap-mcbsp: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 14:05:27 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

Applied, thanks.

#244 lore raw

PATCH 1/1 tools lib traceevent: Deletion of an unnecessary check before the function call "free_arg"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 14:38:14 +0100

The free_arg() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/lib/traceevent/parse-filter.c +1 -2
index b502344..78debaf 100644
@@ -1237,8 +1237,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type == NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
Signature · 1 line
2.1.3
#245 lore raw

PATCH 1/1 tools lib traceevent: Delete an unnecessary check before the function call "free_arg"

From: Markus Elfring <[email protected]>
Date: Thu, 25 Jun 2015 16:13:47 +0200

The free_arg() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 tools/lib/traceevent/parse-filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/lib/traceevent/parse-filter.c +1 -2
index 0144b3d..724a3be 100644
@@ -1239,8 +1239,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
 	if (filter_type = NULL)
 		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 
-	if (filter_type->filter)
-		free_arg(filter_type->filter);
+	free_arg(filter_type->filter);
 	filter_type->filter = arg;
 
 	return 0;
Signature · 1 line
2.4.4
#246 lore raw

PATCH 1/1 perf tools: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 18:05:57 +0100

The functions free_event_desc() and strfilter__delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 tools/perf/builtin-probe.c | 6 ++----
 tools/perf/util/header.c   | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
tools/perf/builtin-probe.c +2 -4
index c63fa29..1b72bf2 100644
@@ -254,8 +254,7 @@ static int opt_set_filter(const struct option *opt __maybe_unused,
 
 	if (str) {
 		pr_debug2("Set filter: %s\n", str);
-		if (params.filter)
-			strfilter__delete(params.filter);
+		strfilter__delete(params.filter);
 		params.filter = strfilter__new(str, &err);
 		if (!params.filter) {
 			pr_err("Filter parse error at %td.\n", err - str + 1);
@@ -283,8 +282,7 @@ static void cleanup_params(void)
 		strlist__delete(params.dellist);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
tools/perf/util/header.c +1 -2
index 158c787..a62fbc6 100644
@@ -1367,8 +1367,7 @@ out:
 	free(buf);
 	return events;
 error:
-	if (events)
-		free_event_desc(events);
+	free_event_desc(events);
 	events = NULL;
 	goto out;
 }
Signature · 1 line
2.1.3
#247 lore raw

PATCH 1/1 perf probe: Delete an unnecessary check before the function call "strfilter__delete"

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200

The strfilter__delete() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
Signature · 1 line
2.4.5
Acked-by on v1 1/1
#248 lore raw

Re: [PATCH] perf probe: Delete an unnecessary check before the function call "strfilter__delete"

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 07:44:22 +0200

The strfilter__delete() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

This looks OK for me.

Quoted 20 lines
---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
Signature · 5 lines
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: [email protected]
#249 lore raw

[tip:perf/core] perf probe: Delete an unnecessary check before the function call "strfilter__delete"

In reply to SF Markus Elfring
perf probe: Delete an unnecessary check before the function call "strfilter__delete"
Commit-ID:  200802a4a79b3a7a1cf924ad870d3265023d0787
Gitweb:     http://git.kernel.org/tip/200802a4a79b3a7a1cf924ad870d3265023d0787
Author:     Markus Elfring <[email protected]>
AuthorDate: Sat, 4 Jul 2015 07:44:22 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 6 Jul 2015 08:58:36 -0300

perf probe: Delete an unnecessary check before the function call "strfilter__delete"

The strfilter__delete() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 tools/perf/builtin-probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/builtin-probe.c +1 -2
index 1272559..b81cec3 100644
@@ -297,8 +297,7 @@ static void cleanup_params(void)
 		clear_perf_probe_event(params.events + i);
 	line_range__clear(&params.line_range);
 	free(params.target);
-	if (params.filter)
-		strfilter__delete(params.filter);
+	strfilter__delete(params.filter);
 	memset(&params, 0, sizeof(params));
 }
 
#250 lore raw

PATCH 1/1 mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/zswap.c +1 -2
index ea064c1..35629f0 100644
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
Signature · 1 line
2.1.3
Acked-by on v1 1/1
#251 lore raw

Re: [PATCH 1/1] mm/zswap: Deletion of an unnecessary check before the function call "free_percpu"

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 18:33:33 +0100

The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks for the cleanup!

Quoted 23 lines
---
 mm/zswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/zswap.c +1 -2
index ea064c1..35629f0 100644
@@ -152,8 +152,7 @@ static int __init zswap_comp_init(void)
 static void zswap_comp_exit(void)
 {
 	/* free percpu transforms */
-	if (zswap_comp_pcpu_tfms)
-		free_percpu(zswap_comp_pcpu_tfms);
+	free_percpu(zswap_comp_pcpu_tfms);
 }
 
 /*********************************
Signature · 1 line
2.1.3
#252 lore raw

PATCH 1/1 hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
fs/hfs/bfind.c +1 -2
index de69d8a..0e26523 100644
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfs/brec.c +1 -2
index 9f4ee7f..3a52b2c 100644
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
fs/hfsplus/bfind.c +1 -2
index c1422d9..7be88e3 100644
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfsplus/brec.c +1 -2
index 6e560d5..59bab47 100644
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
Signature · 1 line
2.1.3
maintainer Reviewed-by on v1 1/1
#253 lore raw

Re: [PATCH 1/1] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thank you. It's the reasonable correction. Looks good for me.

Thanks,
Vyacheslav Dubeyko.

Quoted 64 lines
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
fs/hfs/bfind.c +1 -2
index de69d8a..0e26523 100644
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfs/brec.c +1 -2
index 9f4ee7f..3a52b2c 100644
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
fs/hfsplus/bfind.c +1 -2
index c1422d9..7be88e3 100644
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfsplus/brec.c +1 -2
index 6e560d5..59bab47 100644
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
#254 lore raw

Re: [PATCH] hfs/hfs+: Deletion of unnecessary checks before the function call "hfs_bnode_put"

Quoted 72 lines
Quoted 8 lines

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:13:56 +0100

The hfs_bnode_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thank you. It's the reasonable correction. Looks good for me.

Thanks,
Vyacheslav Dubeyko.

Quoted 56 lines
---
 fs/hfs/bfind.c     | 3 +--
 fs/hfs/brec.c      | 3 +--
 fs/hfsplus/bfind.c | 3 +--
 fs/hfsplus/brec.c  | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
fs/hfs/bfind.c +1 -2
index de69d8a..0e26523 100644
@@ -100,8 +100,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfs/brec.c +1 -2
index 9f4ee7f..3a52b2c 100644
@@ -272,8 +272,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 
fs/hfsplus/bfind.c +1 -2
index c1422d9..7be88e3 100644
@@ -171,8 +171,7 @@ int hfs_brec_find(struct hfs_find_data *fd, search_strategy_t do_key_compare)
 	int height, res;
 
 	tree = fd->tree;
-	if (fd->bnode)
-		hfs_bnode_put(fd->bnode);
+	hfs_bnode_put(fd->bnode);
 	fd->bnode = NULL;
 	nidx = tree->root;
 	if (!nidx)
fs/hfsplus/brec.c +0 -0
index 6e560d5..59bab47 100644
@@ -276,8 +276,7 @@ static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
 		/* panic? */
Quoted 10 lines

fs/hfsplus/brec.c static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd) · line 282

Quoted 8 lines
fs/hfsplus/brec.c +1 -2
 		hfs_bnode_put(node);
 		hfs_bnode_put(new_node);
-		if (next_node)
-			hfs_bnode_put(next_node);
+		hfs_bnode_put(next_node);
 		return ERR_PTR(-ENOSPC);
 	}
 

Can this update suggestion be still integrated
into another source code repository?

Regards,
Markus

#255 lore raw

PATCH 1/1 configfs: Deletion of unnecessary checks before the function call "config_item_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 17 Nov 2014 19:37:03 +0100

The config_item_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/configfs/file.c | 3 +--
 fs/configfs/item.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/configfs/file.c +1 -2
index 1d1c41f..48f36e7 100644
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
fs/configfs/item.c +1 -2
index e65f9ff..891b20e 100644
@@ -153,8 +153,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
Signature · 1 line
2.1.3
#256 lore raw

PATCH 1/1 configfs: Delete unnecessary checks before the function call "config_item_put"

From: Markus Elfring <[email protected]>
Date: Fri, 26 Jun 2015 15:20:43 +0200

The config_item_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/configfs/file.c | 5 ++---
 fs/configfs/item.c | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
fs/configfs/file.c +2 -3
index 403269f..c70997f 100644
@@ -274,7 +274,7 @@ static int check_perm(struct inode * inode, struct file * file)
  Enomem:
 	module_put(attr->ca_owner);
  Done:
-	if (error && item)
+	if (error)
 		config_item_put(item);
 	return error;
 }
@@ -291,8 +291,7 @@ static int configfs_release(struct inode * inode, struct file * filp)
 	struct module * owner = attr->ca_owner;
 	struct configfs_buffer * buffer = filp->private_data;
 
-	if (item)
-		config_item_put(item);
+	config_item_put(item);
 	/* After this point, attr should not be accessed. */
 	module_put(owner);
 
fs/configfs/item.c +1 -2
index 4d6a30e..6173fa7 100644
@@ -152,8 +152,7 @@ static void config_item_cleanup(struct config_item *item)
 		t->ct_item_ops->release(item);
 	if (s)
 		config_group_put(s);
-	if (parent)
-		config_item_put(parent);
+	config_item_put(parent);
 }
 
 static void config_item_release(struct kref *kref)
Signature · 1 line
2.4.4
#257 lore raw

PATCH 1/1 fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/eventpoll.c +2 -4
index 7bcfff9..eec2e85 100644
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 
Signature · 1 line
2.1.3
#258 lore raw

Re: [PATCH] fs-eventpoll: Deletion of unnecessary checks before the function call "__pm_stay_awake"

Quoted 29 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 09:27:16 +0100

The __pm_stay_awake() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/eventpoll.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/eventpoll.c +1 -2
index 7bcfff9..eec2e85 100644
@@ -555,8 +555,7 @@ static inline void ep_pm_stay_awake(struct epitem *epi)
 {
 	struct wakeup_source *ws = ep_wakeup_source(epi);
 
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 }
 
 static inline bool ep_has_wakeup_source(struct epitem *epi)

fs/eventpoll.c static inline void ep_pm_stay_awake_rcu(struct epitem *epi) · line 576

Quoted 9 lines
fs/eventpoll.c +1 -2
@@ -571,8 +570,7 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
 
 	rcu_read_lock();
 	ws = rcu_dereference(epi->ws);
-	if (ws)
-		__pm_stay_awake(ws);
+	__pm_stay_awake(ws);
 	rcu_read_unlock();
 }
 

How are the chances to integrate this update suggestion into another source code repository?

Regards,
Markus

#259 lore raw

PATCH 1/1 exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/exofs/ore_raid.c +1 -2
index 84529b8..5dc7c4c 100644
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }
Signature · 1 line
2.1.3
#260 lore raw

Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"

Quoted 19 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/exofs/ore_raid.c +0 -0
index 84529b8..5dc7c4c 100644

fs/exofs/ore_raid.c void _ore_free_raid_stuff(struct ore_io_state *ios) · line 720

Quoted 7 lines
fs/exofs/ore_raid.c +1 -2
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }

Thanks will submit for next Kernel
Boaz

#261 lore raw

Re: [osd-dev] [PATCH 1/1] exofs: Deletion of an unnecessary check before the function call "ore_put_io_state"

Quoted 13 lines
Quoted 13 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 10:05:19 +0100

The ore_put_io_state() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/exofs/ore_raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 15 lines

fs/exofs/ore_raid.c void _ore_free_raid_stuff(struct ore_io_state *ios) · line 720

Quoted 13 lines
fs/exofs/ore_raid.c +1 -2
index 84529b8..5dc7c4c 100644
@@ -716,6 +716,5 @@ void _ore_free_raid_stuff(struct ore_io_state *ios)
 		if (ios->extra_part_alloc)
 			kfree(ios->per_dev[0].sglist);
 	}
-	if (ios->ios_read_4_write)
-		ore_put_io_state(ios->ios_read_4_write);
+	ore_put_io_state(ios->ios_read_4_write);
 }

Thanks will submit for next Kernel

Is this small update suggestion still in the waiting queue for further software improvements?

Regards,
Markus

#262 lore raw

PATCH 1/1 GFS2: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/gfs2/glock.c      | 3 +--
 fs/gfs2/ops_fstype.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
fs/gfs2/glock.c +1 -2
index 7f513b1..f4aa085 100644
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
 	gh->gh_flags = flags;
 	gh->gh_iflags = 0;
 	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
 	gh->gh_owner_pid = get_pid(task_pid(current));
 }
 
fs/gfs2/ops_fstype.c +1 -2
index d3eae24..272ff81 100644
@@ -918,8 +918,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
Signature · 1 line
2.1.3
#263 lore raw

Re: [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

Quoted 42 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
  fs/gfs2/glock.c      | 3 +--
  fs/gfs2/ops_fstype.c | 3 +--
  2 files changed, 2 insertions(+), 4 deletions(-)
fs/gfs2/glock.c +1 -2
index 7f513b1..f4aa085 100644
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
  	gh->gh_flags = flags;
  	gh->gh_iflags = 0;
  	gh->gh_ip = (unsigned long)__builtin_return_address(0);
-	if (gh->gh_owner_pid)
-		put_pid(gh->gh_owner_pid);
+	put_pid(gh->gh_owner_pid);
  	gh->gh_owner_pid = get_pid(task_pid(current));
  }
 
fs/gfs2/ops_fstype.c +1 -2
index d3eae24..272ff81 100644
@@ -918,8 +918,7 @@ fail_qc_i:
  fail_ut_i:
  	iput(sdp->sd_sc_inode);
  fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
  	return error;
  }
 
#264 lore raw

PATCH 1/1 GFS2: Delete an unnecessary check before the function call "iput"

From: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 21:23:43 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/gfs2/ops_fstype.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/ops_fstype.c +1 -2
index baab99b..1f9de17 100644
@@ -910,8 +910,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
Signature · 1 line
2.6.2
#265 lore raw

Re: [PATCH] GFS2: Delete an unnecessary check before the function call "iput"

----- Original Message -----

Quoted 28 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 21:23:43 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/gfs2/ops_fstype.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/ops_fstype.c +1 -3
index baab99b..1f9de17 100644
@@ -910,8 +910,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
--
Quoted 3 lines

2.6.2

Hi Markus,

ACK,

I'll save this patch and push it after the current merge window closed.

Regards,

Bob Peterson
Red Hat File Systems

#266 lore raw

Re: [PATCH] GFS2: Delete an unnecessary check before the function call "iput"

In reply to SF Markus Elfring

----- Original Message -----

Quoted 30 lines

From: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 21:23:43 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/gfs2/ops_fstype.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/ops_fstype.c +1 -3
index baab99b..1f9de17 100644
@@ -910,8 +910,7 @@ fail_qc_i:
 fail_ut_i:
 	iput(sdp->sd_sc_inode);
 fail:
-	if (pn)
-		iput(pn);
+	iput(pn);
 	return error;
 }
 
--

2.6.2

Quoted 1 line

--

Hi,

Thanks. This is now applied to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=6fde22426be6af261816db5941744b8d3c4c7f96

Regards,

Bob Peterson
Red Hat File Systems

#267 lore raw

PATCH 1/1 fs-namespace: Deletion of unnecessary checks before the function call "mntput"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 12:10:43 +0100

The mntput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/namespace.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/namespace.c +2 -4
index 550dbff..3b3710e 100644
@@ -2615,10 +2615,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 	}
 	namespace_unlock();
 
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
+	mntput(rootmnt);
+	mntput(pwdmnt);
 
 	return new_ns;
 }
Signature · 1 line
2.1.3
#268 lore raw

PATCH 1/1 fs-namespace: Delete unnecessary checks before the function call "mntput"

From: Markus Elfring <[email protected]>
Date: Sat, 4 Jul 2015 11:21:17 +0200

The mntput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/namespace.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
fs/namespace.c +2 -6
index e0b2f36..bc689bd 100644
@@ -2809,12 +2809,8 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
 			p = next_mnt(p, old);
 	}
 	namespace_unlock();
-
-	if (rootmnt)
-		mntput(rootmnt);
-	if (pwdmnt)
-		mntput(pwdmnt);
-
+	mntput(rootmnt);
+	mntput(pwdmnt);
 	return new_ns;
 }
 
Signature · 1 line
2.4.5
#269 lore raw

PATCH 1/1 NFS: Deletion of unnecessary checks before the function call "nfs_put_client"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 13:23:43 +0100

The nfs_put_client() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/nfs/filelayout/filelayoutdev.c |  3 +--
 fs/nfs/nfs4client.c               | 15 +++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)
fs/nfs/filelayout/filelayoutdev.c +1 -2
index 8540516..cc5e7d6 100644
@@ -204,8 +204,7 @@ destroy_ds(struct nfs4_pnfs_ds *ds)
 	ifdebug(FACILITY)
 		print_ds(ds);
 
-	if (ds->ds_clp)
-		nfs_put_client(ds->ds_clp);
+	nfs_put_client(ds->ds_clp);
 
 	while (!list_empty(&ds->ds_addrs)) {
 		da = list_first_entry(&ds->ds_addrs,
fs/nfs/nfs4client.c +5 -10
index ffdb28d..5f07a0e 100644
@@ -498,8 +498,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -517,8 +516,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 		atomic_inc(&pos->cl_count);
 		spin_unlock(&nn->nfs_client_lock);
 
-		if (prev)
-			nfs_put_client(prev);
+		nfs_put_client(prev);
 		prev = pos;
 
 		status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
@@ -549,8 +547,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
 
 	/* No match found. The server lost our clientid */
 out:
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
 	return status;
 }
@@ -641,8 +638,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 			atomic_inc(&pos->cl_count);
 			spin_unlock(&nn->nfs_client_lock);
 
-			if (prev)
-				nfs_put_client(prev);
+			nfs_put_client(prev);
 			prev = pos;
 
 			status = nfs_wait_client_init_complete(pos);
@@ -675,8 +671,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
 	/* No matching nfs_client found. */
 	spin_unlock(&nn->nfs_client_lock);
 	dprintk("NFS: <-- %s status = %d\n", __func__, status);
-	if (prev)
-		nfs_put_client(prev);
+	nfs_put_client(prev);
 	return status;
 }
 #endif	/* CONFIG_NFS_V4_1 */
Signature · 1 line
2.1.3
#270 lore raw

PATCH 1/1 nilfs2: Deletion of an unnecessary check before the function call "iput"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nilfs2/the_nilfs.c +1 -2
index 9da25fe..69bd801 100644
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
Signature · 1 line
2.1.3
#271 lore raw

Re: [PATCH 1/1] nilfs2: Deletion of an unnecessary check before the function call "iput"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 14:41:27 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied to nilfs2 git tree. Thanks.

Ryusuke Konishi

Quoted 25 lines
---
 fs/nilfs2/the_nilfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nilfs2/the_nilfs.c +1 -2
index 9da25fe..69bd801 100644
@@ -808,8 +808,7 @@ void nilfs_put_root(struct nilfs_root *root)
 		spin_lock(&nilfs->ns_cptree_lock);
 		rb_erase(&root->rb_node, &nilfs->ns_cptree);
 		spin_unlock(&nilfs->ns_cptree_lock);
-		if (root->ifile)
-			iput(root->ifile);
+		iput(root->ifile);
 
 		kfree(root);
 	}
Signature · 6 lines
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#272 lore raw

PATCH 1/1 fs-proc: One function call less in proc_sys_lookup() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the implementation of the proc_sys_lookup() function in case of a lookup failure. The corresponding source code was improved by deletion of an unnecessary null pointer check and a few adjustments for jump labels.

---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/proc/proc_sysctl.c +4 -4
index f92d5dd..6606aaf 100644
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }
Signature · 1 line
2.1.3
#273 lore raw

Re: [PATCH] fs-proc: One function call less in proc_sys_lookup() after error detection

Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 15:42:43 +0100

The sysctl_head_finish() function was called in an inefficient way by the implementation of the proc_sys_lookup() function in case of a lookup failure. The corresponding source code was improved by deletion of an unnecessary null pointer check and a few adjustments for jump labels.

---
 fs/proc/proc_sysctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/proc/proc_sysctl.c +2 -2
index f92d5dd..6606aaf 100644
@@ -457,21 +457,21 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
 		ret = sysctl_follow_link(&h, &p, current->nsproxy);
 		err = ERR_PTR(ret);
 		if (ret)
-			goto out;
+			goto inode_failure;
 	}
 
 	err = ERR_PTR(-ENOMEM);
 	inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
 	if (!inode)
-		goto out;
+		goto inode_failure;
 
 	err = NULL;
 	d_set_d_op(dentry, &proc_sys_dentry_operations);

fs/proc/proc_sysctl.c static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, · line 477

Quoted 10 lines
fs/proc/proc_sysctl.c +2 -2
 	d_add(dentry, inode);
 
+inode_failure:
+	sysctl_head_finish(h);
 out:
-	if (h)
-		sysctl_head_finish(h);
 	sysctl_head_finish(head);
 	return err;
 }

Would anybody like to integrate this update suggestion into a source code repository?

Regards,
Markus

#274 lore raw

cover fs-udf: Deletion of two unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 18:33:08 +0100

Another update suggestion was taken into account after a patch was applied from static source code analysis.

Markus Elfring (2):
Deletion of unnecessary checks before the function call "iput" One function call less in udf_fill_super() after error detection

 fs/udf/super.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.1.3
#275 lore raw

PATCH 1/2 fs-udf: Deletion of unnecessary checks before the function call "iput"

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 17:17:46 +0100

The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 fs/udf/super.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/udf/super.c +2 -4
index e229315..f93c65d 100644
@@ -2237,8 +2237,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	return 0;
 
 error_out:
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
@@ -2291,8 +2290,7 @@ static void udf_put_super(struct super_block *sb)
 
 	sbi = UDF_SB(sb);
 
-	if (sbi->s_vat_inode)
-		iput(sbi->s_vat_inode);
+	iput(sbi->s_vat_inode);
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
Signature · 1 line
2.1.3
#276 lore raw

PATCH 2/2 fs-udf: One function call less in udf_fill_super() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 18:29:10 +0100

The iput() function was called in up to three cases by the udf_fill_super() function during error handling even if the passed data structure element contained still a null pointer. This implementation detail could be improved by the introduction of another jump label.

---
 fs/udf/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/udf/super.c +3 -2
index f93c65d..3ccb2f1 100644
@@ -2082,12 +2082,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	mutex_init(&sbi->s_alloc_mutex);
 
 	if (!udf_parse_options((char *)options, &uopt, false))
-		goto error_out;
+		goto parse_options_failure;
 
 	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
 	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
 		udf_err(sb, "utf8 cannot be combined with iocharset\n");
-		goto error_out;
+		goto parse_options_failure;
 	}
 #ifdef CONFIG_UDF_NLS
 	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
@@ -2238,6 +2238,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
 
 error_out:
 	iput(sbi->s_vat_inode);
+parse_options_failure:
 #ifdef CONFIG_UDF_NLS
 	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
 		unload_nls(sbi->s_nls_map);
Signature · 1 line
2.1.3
maintainer Applied
#277 lore raw

Re: [PATCH 0/2] fs-udf: Deletion of two unnecessary checks

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 18:33:08 +0100

Another update suggestion was taken into account after a patch was applied from static source code analysis.

I've merged both patches. Thanks.

Honza

Quoted 11 lines

Markus Elfring (2):
Deletion of unnecessary checks before the function call "iput" One function call less in udf_fill_super() after error detection

 fs/udf/super.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.1.3
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#278 lore raw

PATCH 1/1 net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/pktgen.c +1 -2
index 8b849dd..35046a8 100644
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
Signature · 1 line
2.1.3
maintainer Applied
#279 lore raw

Re: [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"

From: SF Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:16:05 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

#280 lore raw

PATCH 1/1 netfilter: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +1 -2
index fd3f444..7c5e40a 100644
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
net/netfilter/ipvs/ip_vs_pe.c +1 -2
index 1a82b29..0df17ca 100644
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
net/netfilter/ipvs/ip_vs_sched.c +1 -2
index 4dbcda6..199760c 100644
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
net/netfilter/ipvs/ip_vs_sync.c +1 -2
index eadffb2..cafe28d 100644
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
net/netfilter/nf_tables_api.c +1 -2
index deeb95f..b115f54 100644
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
Signature · 1 line
2.1.3
#281 lore raw

Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

@IPVS folks: Since this involves a nf_tables specific chunk, ack your chunks and I'll put this into nf-next to speed up things.

Thanks.

Quoted 84 lines

This issue was detected by using the Coccinelle software.

---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +1 -2
index fd3f444..7c5e40a 100644
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
net/netfilter/ipvs/ip_vs_pe.c +1 -2
index 1a82b29..0df17ca 100644
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
net/netfilter/ipvs/ip_vs_sched.c +1 -2
index 4dbcda6..199760c 100644
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
net/netfilter/ipvs/ip_vs_sync.c +1 -2
index eadffb2..cafe28d 100644
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
net/netfilter/nf_tables_api.c +1 -2
index deeb95f..b115f54 100644
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
Signature · 1 line
2.1.3
#282 lore raw

PATCH 1/1 net-ipvs: Delete an unnecessary check before the function call "module_put"

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:00:14 +0200

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/netfilter/ipvs/ip_vs_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_sched.c +1 -1
index 199760c..e50221b 100644
@@ -137,7 +137,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name)
 
 void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
 {
-	if (scheduler && scheduler->module)
+	if (scheduler)
 		module_put(scheduler->module);
 }
 
Signature · 1 line
2.4.5
maintainer Applied
#283 lore raw

Re: [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put"

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 2 Jul 2015 17:00:14 +0200

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks, applied to ipvs-next for v4.3.

maintainer Acked-by on v1 1/1
#284 lore raw

Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

Hello,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Pablo, the IPVS parts look ok to me,

Quoted 80 lines
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +1 -2
index fd3f444..7c5e40a 100644
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
net/netfilter/ipvs/ip_vs_pe.c +1 -2
index 1a82b29..0df17ca 100644
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
net/netfilter/ipvs/ip_vs_sched.c +1 -2
index 4dbcda6..199760c 100644
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
net/netfilter/ipvs/ip_vs_sync.c +1 -2
index eadffb2..cafe28d 100644
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
net/netfilter/nf_tables_api.c +1 -2
index deeb95f..b115f54 100644
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
Signature · 1 line
2.1.3

Regards

--
Julian Anastasov <[email protected]>

maintainer Acked-by
#285 lore raw

Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls

Quoted 12 lines · Julian Anastasov

Hello,

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

Quoted 7 lines
Quoted 3 lines

This issue was detected by using the Coccinelle software.

Pablo, the IPVS parts look ok to me,

Quoted 87 lines
Quoted 81 lines
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +1 -2
index fd3f444..7c5e40a 100644
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
net/netfilter/ipvs/ip_vs_pe.c +1 -2
index 1a82b29..0df17ca 100644
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
net/netfilter/ipvs/ip_vs_sched.c +1 -2
index 4dbcda6..199760c 100644
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
net/netfilter/ipvs/ip_vs_sync.c +1 -2
index eadffb2..cafe28d 100644
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
net/netfilter/nf_tables_api.c +1 -2
index deeb95f..b115f54 100644
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
Signature · 1 line
2.1.3

Regards

--
Julian Anastasov <[email protected]>

maintainer Applied
#286 lore raw

Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls

Quoted 15 lines · Simon Horman
Quoted 14 lines · Julian Anastasov

Hello,

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Pablo, the IPVS parts look ok to me,

Applied, thanks.

#287 lore raw

PATCH 1/1 netlink: Deletion of an unnecessary check before the function call "__module_get"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/netlink/af_netlink.c +1 -2
index f1de72d..0317b91 100644
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
Signature · 1 line
2.1.3
maintainer Applied
#288 lore raw

Re: [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"

From: SF Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:08:39 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

#289 lore raw

PATCH 1/1 net: sched: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/sched/cls_bpf.c +1 -2
index 0e30d58..f323944 100644
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
Signature · 1 line
2.1.3
#290 lore raw

Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"

Quoted 19 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
  net/sched/cls_bpf.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
net/sched/cls_bpf.c +0 -0
index 0e30d58..f323944 100644

net/sched/cls_bpf.c static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp, · line 218

Quoted 9 lines
net/sched/cls_bpf.c +1 -2
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
  	if (fp_old)
  		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
  	return 0;
 

Maybe I need some coffee but I can't figure out what this patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

Signature · 1 line
John Fastabend         Intel Corporation
#291 lore raw

Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"

Quoted 2 lines · John Fastabend
Quoted 1 line · SF Markus Elfring

From: Markus Elfring <[email protected]>

...

Quoted 6 lines
Quoted 6 lines
      if (fp_old)
          bpf_prog_destroy(fp_old);
net/sched/cls_bpf.c +1 -2
-    if (bpf_old)
-        kfree(bpf_old);
+    kfree(bpf_old);
Quoted 8 lines
Quoted 2 lines
      return 0;

Maybe I need some coffee but I can't figure out what this patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not up to date ...

#293 lore raw

Re: net: sched: Deletion of an unnecessary check before the function call "kfree"

Quoted 6 lines · SF Markus Elfring
Quoted 1 line

Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files for Linux 3.17.3. Are newer software developments relevant here?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Pointing to linux-next and saying you based your changes on 3.17.3 is confusing, please look correctly when you provide a link ...

Again, John's commit 1f947bf151e90ec0b removed the relevant part in cls_bpf_modify_existing() that you're trying to modify:

$ git grep -n bpf_old net/sched/cls_bpf.c
$

Therefore, this patch is not needed.

Thanks !

#294 lore raw

Re: net: sched: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files for Linux 3.17.3. Are newer software developments relevant here?

You should always use linux-next. You should update it every day.

julia

Quoted 10 lines

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Regards,
Markus

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#295 lore raw

Re: net: sched: Deletion of an unnecessary check before the function call "kfree"

Quoted 8 lines · Julia Lawall
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files for Linux 3.17.3. Are newer software developments relevant here?

You should always use linux-next. You should update it every day.

Well, if you send in cleanups to netdev, you should always target the net-next tree:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

#296 lore raw

PATCH 1/1 net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/xfrm/xfrm_ipcomp.c +1 -2
index ccfdc71..47863cd 100644
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
Signature · 1 line
2.1.3
#297 lore raw

Re: [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

It doesn't though...

regards,
dan carpenter

#298 lore raw

Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

Quoted 4 lines
Quoted 2 lines

The ipcomp_free_tfms() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

It doesn't though...

You are right that this function implementation does a bit more before returning because of a detected null pointer.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id94efd19d5fcae936261bd48e5b33b21897aacf8#n247

Can you agree that input parameter validation is also performed there? Do you want that I resend my patch with a corrected commit message?

Regards,
Markus

#299 lore raw

Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

The ipcomp_free_tfms() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

It doesn't though...

You are right that this function implementation does a bit more before returning because of a detected null pointer.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id94efd19d5fcae936261bd48e5b33b21897aacf8#n247

Can you agree that input parameter validation is also performed there? Do you want that I resend my patch with a corrected commit message?

This is completely crazy. The function performs a side effect on a data structure. If the call site doesn't want that done in a certain case, then it should not be done.

julia

#300 lore raw

Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

In reply to SF Markus Elfring

I have come to view you as a very clever troll. You will say infuriating things like "That is an interesting background information but the function implementation update suggestion is correct" and pretend to not see the bug for nine emails. Then you'll say something "Ha ha, I audited all the call trees and it can't actually be NULL so you were getting angry for no reason." Except you'll say it in a more obfuscated way than that. This is what you did last time.

regards,
dan carpenter

maintainer
#301 lore raw

Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"

From: Dan Carpenter <[email protected]>
Date: Wed, 19 Nov 2014 13:10:03 +0300

Quoted 1 line

I have come to view you as a very clever troll.

+1

#302 lore raw

PATCH 1/1 keys: Deletion of an unnecessary check before the function call "key_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 21:57:14 +0100

The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 security/keys/process_keys.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
security/keys/process_keys.c +1 -2
index 0cf8a13..ce00e11 100644
@@ -242,8 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
+	key_put(old);
 
 	return 0;
 }
Signature · 1 line
2.1.3
#303 lore raw

PATCH 1/1 keys: Delete an unnecessary check before the function call "key_put"

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 15:16:35 +0200

The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 security/keys/process_keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/process_keys.c +1 -3
index bd536cb..225dd08 100644
@@ -242,9 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
-
+	key_put(old);
 	return 0;
 }
 
Signature · 1 line
2.4.4
maintainer Acked-by Serge Hallyn on v1 1/1
#304 lore raw

Re: [PATCH] keys: Delete an unnecessary check before the function call "key_put"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 15:16:35 +0200

The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Quoted 21 lines
---
 security/keys/process_keys.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/process_keys.c +1 -3
index bd536cb..225dd08 100644
@@ -242,9 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring)
 	old = cred->session_keyring;
 	rcu_assign_pointer(cred->session_keyring, keyring);
 
-	if (old)
-		key_put(old);
-
+	key_put(old);
 	return 0;
 }
 
Signature · 1 line
2.4.4
#305 lore raw

PATCH 1/1 crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 10:11:04 +0100

The kzfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 crypto/drbg.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
crypto/drbg.c +6 -12
index a53ee09..b6f22d4 100644
@@ -1151,8 +1151,7 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
 	drbg->reseed_ctr = 1;
 
 out:
-	if (entropy)
-		kzfree(entropy);
+	kzfree(entropy);
 	return ret;
 }
 
@@ -1161,19 +1160,15 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg)
 {
 	if (!drbg)
 		return;
-	if (drbg->V)
-		kzfree(drbg->V);
+	kzfree(drbg->V);
 	drbg->V = NULL;
-	if (drbg->C)
-		kzfree(drbg->C);
+	kzfree(drbg->C);
 	drbg->C = NULL;
-	if (drbg->scratchpad)
-		kzfree(drbg->scratchpad);
+	kzfree(drbg->scratchpad);
 	drbg->scratchpad = NULL;
 	drbg->reseed_ctr = 0;
 #ifdef CONFIG_CRYPTO_FIPS
-	if (drbg->prev)
-		kzfree(drbg->prev);
+	kzfree(drbg->prev);
 	drbg->prev = NULL;
 	drbg->fips_primed = false;
 #endif
@@ -1293,8 +1288,7 @@ static int drbg_make_shadow(struct drbg_state *drbg, struct drbg_state **shadow)
 	return 0;
 
 err:
-	if (tmp)
-		kzfree(tmp);
+	kzfree(tmp);
 	return ret;
 }
 
Signature · 1 line
2.1.3
maintainer
#306 lore raw

Re: [PATCH 1/1] crypto-drbg: Deletion of unnecessary checks before the function call "kzfree"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 10:11:04 +0100

The kzfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Sorry but you're too late as someone else has already fixed this :)

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#308 lore raw

PATCH 1/1 firmware class: Deletion of an unnecessary check before the function call "vunmap"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 11:38:38 +0100

The vunmap() function performes also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/firmware_class.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/firmware_class.c +1 -2
index 3d785eb..532662c 100644
@@ -591,8 +591,7 @@ static int fw_map_pages_buf(struct firmware_buf *buf)
 	if (!buf->is_paged_buf)
 		return 0;
 
-	if (buf->data)
-		vunmap(buf->data);
+	vunmap(buf->data);
 	buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
 	if (!buf->data)
 		return -ENOMEM;
Signature · 1 line
2.1.3
#309 lore raw

PATCH 1/1 PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 12:21:24 +0100

The wakeup_source_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/base/power/wakeup.c +1 -2
index eb1bd2e..87dfc1d 100644
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);
 
 	return 0;
 }
Signature · 1 line
2.1.3
#310 lore raw

Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"

drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 270

Quoted 9 lines · SF Markus Elfring
drivers/base/power/wakeup.c +1 -2
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);

In the original code, it's clear that the programmer thought about what happens when the device_wakeup_detach() returns NULL but in the new code that's not clear.

I guess the information is still there in the git archive, but why hide the good code by covering it with confusing code?

regards,
dan carpenter

#311 lore raw

Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"

Am 19.11.2014 13:09, schrieb Dan Carpenter:

Quoted 15 lines · SF Markus Elfring

drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 270

Quoted 9 lines
drivers/base/power/wakeup.c +1 -2
@@ -267,8 +267,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
+	wakeup_source_unregister(ws);

In the original code, it's clear that the programmer thought about what happens when the device_wakeup_detach() returns NULL but in the new code that's not clear.

Quoted 3 lines

I guess the information is still there in the git archive, but why hide the good code by covering it with confusing code?

hi,
just to add an other point of view ...

device_wakeup_detach returns dev->power.wakeup what is never NULL in this case. (not visible here but a few line before exactly this is checked)

so this code can be compacted to:
wakeup_source_unregister(device_wakeup_detach(dev));

--readability

let the maintainer decide this byte-saving vs readability

re,
wh

#312 lore raw

Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"

Quoted 2 lines · walter harms

device_wakeup_detach returns dev->power.wakeup what is never NULL in this case. (not visible here but a few line before exactly this is checked)

Huh? I don't see a NULL check.

I think you may be confusing "dev->power.can_wakeup" with "dev->power.wakeup"?

regards,
dan carpenter

#313 lore raw

Re: [PATCH 1/1] PM-wakeup: Deletion of an unnecessary check before the function call "wakeup_source_unregister"

Am 19.11.2014 14:05, schrieb Dan Carpenter:

Quoted 10 lines · walter harms
Quoted 2 lines

device_wakeup_detach returns dev->power.wakeup what is never NULL in this case. (not visible here but a few line before exactly this is checked)

Huh? I don't see a NULL check.

I think you may be confusing "dev->power.can_wakeup" with "dev->power.wakeup"?

mea culpa,
you are right dev->power.can_wakeup != dev->power.wakeup

therefore device_wakeup_detach(dev) CAN return NULL

re,
wh

#314 lore raw

PATCH 1/1 PM-wakeup: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200

The functions dev_pm_disarm_wake_irq() and wakeup_source_unregister() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/base/power/wakeup.c +3 -7
index 40f7160..3741bc2 100644
@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);
Signature · 1 line
2.4.4
#315 lore raw

Re: [PATCH] PM-wakeup: Delete unnecessary checks before two function calls

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200

The functions dev_pm_disarm_wake_irq() and wakeup_source_unregister() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

ACK.

Quoted 41 lines
---
 drivers/base/power/wakeup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/base/power/wakeup.c +3 -7
index 40f7160..3741bc2 100644
@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);
Signature · 1 line
2.4.4
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#316 lore raw

Re: [PATCH] PM-wakeup: Delete unnecessary checks before two function calls

In reply to SF Markus Elfring

Am 28.06.2015 um 12:21 schrieb SF Markus Elfring:

Quoted 40 lines

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200

The functions dev_pm_disarm_wake_irq() and wakeup_source_unregister() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/base/power/wakeup.c +2 -4
index 40f7160..3741bc2 100644
@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }

drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 400

Quoted 10 lines
drivers/base/power/wakeup.c +1 -3
@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);

How do you think about to integrate this update suggestion into another source code repository?

Regards,
Markus

#317 lore raw

Re: [PATCH] PM-wakeup: Delete unnecessary checks before two function calls

Quoted 42 lines · SF Markus Elfring

Am 28.06.2015 um 12:21 schrieb SF Markus Elfring:

Quoted 41 lines

From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200

The functions dev_pm_disarm_wake_irq() and wakeup_source_unregister() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/base/power/wakeup.c +2 -4
index 40f7160..3741bc2 100644
@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	}
 	rcu_read_unlock();
 }
@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
Quoted 12 lines

drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 400

Quoted 9 lines
drivers/base/power/wakeup.c +1 -3
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);

How do you think about to integrate this update suggestion into another source code repository?

I'm not really sure what you mean.

Thanks,
Rafael

#319 lore raw

Re: PM-wakeup: Delete unnecessary checks before two function calls

Quoted 9 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

How do you think about to integrate this update suggestion into another source code repository?

I'm not really sure what you mean.

Do you find the suggested source code change acceptable?

http://article.gmane.org/gmane.linux.power-management.general/61766
https://lkml.org/lkml/2015/6/28/21

Yes, it is acceptable, but you also should remove some braces that aren't necessary any more.

Thanks,
Rafael

#320 lore raw

PATCH 1/1 PM-wakeup: Delete unnecessary checks before three function calls

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 17:04:00 +0200

The following functions test whether their argument is NULL and then return immediately.
* dev_pm_arm_wake_irq
* dev_pm_disarm_wake_irq
* wakeup_source_unregister

Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/base/power/wakeup.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/base/power/wakeup.c +5 -11
index 5fb7718..c35d3f5 100644
@@ -334,10 +334,8 @@ void device_wakeup_arm_wake_irqs(void)
 	struct wakeup_source *ws;
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_arm_wake_irq(ws->wakeirq);
-	}
+	list_for_each_entry_rcu(ws, &wakeup_sources, entry)
+		dev_pm_arm_wake_irq(ws->wakeirq);
 	rcu_read_unlock();
 }
 
@@ -351,10 +349,8 @@ void device_wakeup_disarm_wake_irqs(void)
 	struct wakeup_source *ws;
 
 	rcu_read_lock();
-	list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
-		if (ws->wakeirq)
-			dev_pm_disarm_wake_irq(ws->wakeirq);
-	}
+	list_for_each_entry_rcu(ws, &wakeup_sources, entry)
+		dev_pm_disarm_wake_irq(ws->wakeirq);
 	rcu_read_unlock();
 }
 
@@ -390,9 +386,7 @@ int device_wakeup_disable(struct device *dev)
 		return -EINVAL;
 
 	ws = device_wakeup_detach(dev);
-	if (ws)
-		wakeup_source_unregister(ws);
-
+	wakeup_source_unregister(ws);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(device_wakeup_disable);
Signature · 1 line
2.9.2
Acked-by on v1 1/1
#321 lore raw

Re: [PATCH] PM-wakeup: Delete unnecessary checks before three function calls

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 17:04:00 +0200

The following functions test whether their argument is NULL and then return immediately.
* dev_pm_arm_wake_irq
* dev_pm_disarm_wake_irq
* wakeup_source_unregister

Quoted 5 lines

Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#322 lore raw

PATCH 1/1 drbd: Deletion of an unnecessary check before the function call "lc_destroy"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 13:33:32 +0100

The lc_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/block/drbd/drbd_nl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/drbd/drbd_nl.c +1 -2
index 1cd47df..0bcb3e0 100644
@@ -1115,8 +1115,7 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
 		lc_destroy(n);
 		return -EBUSY;
 	} else {
-		if (t)
-			lc_destroy(t);
+		lc_destroy(t);
 	}
 	drbd_md_mark_dirty(device); /* we changed device->act_log->nr_elemens */
 	return 0;
Signature · 1 line
2.1.3
#323 lore raw

Re: [PATCH] drbd: Deletion of an unnecessary check before the function call "lc_destroy"

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 13:33:32 +0100

The lc_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/block/drbd/drbd_nl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/drbd/drbd_nl.c +0 -0
index 1cd47df..0bcb3e0 100644

drivers/block/drbd/drbd_nl.c static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc) · line 1121

Quoted 9 lines
drivers/block/drbd/drbd_nl.c +1 -2
@@ -1115,8 +1115,7 @@ static int drbd_check_al_size(struct drbd_device *device, struct disk_conf *dc)
 		lc_destroy(n);
 		return -EBUSY;
 	} else {
-		if (t)
-			lc_destroy(t);
+		lc_destroy(t);
 	}
 	drbd_md_mark_dirty(device); /* we changed device->act_log->nr_elemens */
 	return 0;

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#324 lore raw

PATCH 1/1 agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 14:24:20 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/char/agp/intel-gtt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/char/agp/intel-gtt.c +2 -4
index 9a024f8..db5877e 100644
@@ -1434,10 +1434,8 @@ void intel_gmch_remove(void)
 	if (--intel_private.refcount)
 		return;
 
-	if (intel_private.pcidev)
-		pci_dev_put(intel_private.pcidev);
-	if (intel_private.bridge_dev)
-		pci_dev_put(intel_private.bridge_dev);
+	pci_dev_put(intel_private.pcidev);
+	pci_dev_put(intel_private.bridge_dev);
 	intel_private.driver = NULL;
 }
 EXPORT_SYMBOL(intel_gmch_remove);
Signature · 1 line
2.1.3
#325 lore raw

Re: [PATCH] agp/intel-gtt: Deletion of unnecessary checks before the function call "pci_dev_put"

Quoted 21 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 14:24:20 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/char/agp/intel-gtt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/char/agp/intel-gtt.c +0 -0
index 9a024f8..db5877e 100644
@@ -1434,10 +1434,8 @@ void intel_gmch_remove(void)
 	if (--intel_private.refcount)
 		return;

drivers/char/agp/intel-gtt.c void intel_gmch_remove(void) · line 1441

Quoted 10 lines
drivers/char/agp/intel-gtt.c +2 -4
 
-	if (intel_private.pcidev)
-		pci_dev_put(intel_private.pcidev);
-	if (intel_private.bridge_dev)
-		pci_dev_put(intel_private.bridge_dev);
+	pci_dev_put(intel_private.pcidev);
+	pci_dev_put(intel_private.bridge_dev);
 	intel_private.driver = NULL;
 }
 EXPORT_SYMBOL(intel_gmch_remove);

Would you like to integrate this update suggestion into a source code repository?

Regards,
Markus

#326 lore raw

PATCH 1/1 char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_release"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 14:44:15 +0100

The tpm_dev_vendor_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/char/tpm/tpm_i2c_atmel.c   | 3 +--
 drivers/char/tpm/tpm_i2c_nuvoton.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/char/tpm/tpm_i2c_atmel.c +1 -2
index 7727292..19c3a7b 100644
@@ -202,8 +202,7 @@ static int i2c_atmel_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
drivers/char/tpm/tpm_i2c_nuvoton.c +1 -2
index 7b158ef..8d09628 100644
@@ -625,8 +625,7 @@ static int i2c_nuvoton_remove(struct i2c_client *client)
 	struct device *dev = &(client->dev);
 	struct tpm_chip *chip = dev_get_drvdata(dev);
 
-	if (chip)
-		tpm_dev_vendor_release(chip);
+	tpm_dev_vendor_release(chip);
 	tpm_remove_hardware(dev);
 	kfree(chip);
 	return 0;
Signature · 1 line
2.1.3
#327 lore raw

PATCH 1/1 EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 16:00:13 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/edac/i3000_edac.c      | 3 +--
 drivers/edac/i3200_edac.c      | 3 +--
 drivers/edac/i82443bxgx_edac.c | 3 +--
 drivers/edac/x38_edac.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/edac/i3000_edac.c +1 -2
index cd28b96..5cb36a6 100644
@@ -542,8 +542,7 @@ fail1:
 	pci_unregister_driver(&i3000_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
drivers/edac/i3200_edac.c +1 -2
index aa98b13..4ad062b 100644
@@ -523,8 +523,7 @@ fail1:
 	pci_unregister_driver(&i3200_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
drivers/edac/i82443bxgx_edac.c +1 -2
index d730e276..b4705d9 100644
@@ -458,8 +458,7 @@ static void __exit i82443bxgx_edacmc_exit(void)
 	if (!i82443bxgx_registered)
 		i82443bxgx_edacmc_remove_one(mci_pdev);
 
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 }
 
 module_init(i82443bxgx_edacmc_init);
drivers/edac/x38_edac.c +1 -2
index e644b52..7c5cdc6 100644
@@ -500,8 +500,7 @@ fail1:
 	pci_unregister_driver(&x38_driver);
 
 fail0:
-	if (mci_pdev)
-		pci_dev_put(mci_pdev);
+	pci_dev_put(mci_pdev);
 
 	return pci_rc;
 }
Signature · 1 line
2.1.3
maintainer Applied
#328 lore raw

Re: [PATCH 1/1] EDAC: Deletion of unnecessary checks before the function call "pci_dev_put"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 16:00:13 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#329 lore raw

PATCH 1/1 DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 16:33:17 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/drm_edid_load.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_edid_load.c +1 -2
index 0a235fe..732cb6f 100644
@@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
 	    name, connector_name);
 
 out:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	return edid;
 }
 
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#330 lore raw

Re: [PATCH 1/1] DRM-EDID: Deletion of an unnecessary check before the function call "release_firmware"

Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 16:33:17 +0100

The release_firmware() function tests whether its argument is NULL and

then

Review

Quoted 10 lines

returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/drm_edid_load.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_edid_load.c

drivers/gpu/drm/drm_edid_load.c static void *edid_load(struct drm_connector

Quoted 4 lines

index 0a235fe..732cb6f 100644

drivers/gpu/drm/drm_edid_load.c +0 -0
@@ -254,8 +254,7 @@ static void *edid_load(struct drm_connector

*connector, const char *name,

drivers/gpu/drm/drm_edid_load.c static void *edid_load(struct drm_connector *connector, const char *name, · line 260

Quoted 9 lines
drivers/gpu/drm/drm_edid_load.c +1 -2
            name, connector_name);
 
 out:
-       if (fw)
-               release_firmware(fw);
+       release_firmware(fw);
        return edid;
 }
 

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#331 lore raw

PATCH 1/1 DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:05:20 +0100

The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -2
index 000428e..335b1dc 100644
@@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev,
 static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 {
 	struct tilcdc_drm_private *priv = dev->dev_private;
-	if (priv->fbdev)
-		drm_fbdev_cma_hotplug_event(priv->fbdev);
+	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#332 lore raw

Re: [PATCH 1/1] DRM-tilcdc: Deletion of an unnecessary check before the function call "drm_fbdev_cma_hotplug_event"

Quoted 28 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:05:20 +0100

The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -2
index 000428e..335b1dc 100644
@@ -58,8 +58,7 @@ static struct drm_framebuffer *tilcdc_fb_create(struct 
 drm_device *dev,
 static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 {
 	struct tilcdc_drm_private *priv = dev->dev_private;
-	if (priv->fbdev)
-		drm_fbdev_cma_hotplug_event(priv->fbdev);
+	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
Quoted 1 line

static const struct drm_mode_config_funcs mode_config_funcs = {

#333 lore raw

PATCH 1/1 DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:33:32 +0100

The vunmap() function performes also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/udl/udl_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/udl/udl_gem.c +1 -2
index 8044f5f..2979625 100644
@@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
 		return;
 	}
 
-	if (obj->vmapping)
-		vunmap(obj->vmapping);
+	vunmap(obj->vmapping);
 
 	udl_gem_put_pages(obj);
 }
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#334 lore raw

Re: [PATCH 1/1] DRM-UDL: Deletion of an unnecessary check before the function call "vunmap"

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:33:32 +0100

The vunmap() function performes also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/udl/udl_gem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/udl/udl_gem.c +0 -0
index 8044f5f..2979625 100644

drivers/gpu/drm/udl/udl_gem.c void udl_gem_vunmap(struct udl_gem_object *obj) · line 170

Quoted 9 lines
drivers/gpu/drm/udl/udl_gem.c +1 -2
@@ -164,8 +164,7 @@ void udl_gem_vunmap(struct udl_gem_object *obj)
 		return;
 	}
 
-	if (obj->vmapping)
-		vunmap(obj->vmapping);
+	vunmap(obj->vmapping);
 
 	udl_gem_put_pages(obj);
 }
#335 lore raw

PATCH 1/1 DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:50:19 +0100

The vfree() function performes also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -2
index 14b2f50..f9a67b8 100644
@@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
 	if (dev_priv->ctx.res_ht_initialized)
 		drm_ht_remove(&dev_priv->ctx.res_ht);
-	if (dev_priv->ctx.cmd_bounce)
-		vfree(dev_priv->ctx.cmd_bounce);
+	vfree(dev_priv->ctx.cmd_bounce);
 	if (dev_priv->enable_fb) {
 		vmw_fb_close(dev_priv);
 		vmw_kms_restore_vga(dev_priv);
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#336 lore raw

Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

Quoted 19 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 17:50:19 +0100

The vfree() function performes also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -0
index 14b2f50..f9a67b8 100644

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_driver_unload(struct drm_device *dev) · line 895

Quoted 9 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -2
@@ -889,8 +889,7 @@ static int vmw_driver_unload(struct drm_device *dev)
 
 	if (dev_priv->ctx.res_ht_initialized)
 		drm_ht_remove(&dev_priv->ctx.res_ht);
-	if (dev_priv->ctx.cmd_bounce)
-		vfree(dev_priv->ctx.cmd_bounce);
+	vfree(dev_priv->ctx.cmd_bounce);
 	if (dev_priv->enable_fb) {
 		vmw_fb_close(dev_priv);
 		vmw_kms_restore_vga(dev_priv);
#337 lore raw

Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 6 Jul 2015 09:49:11 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 654c8da..f718a6d 100644
@@ -2292,9 +2292,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context,
 				   (sw_context->cmd_bounce_size >> 1));
 	}
 
-	if (sw_context->cmd_bounce != NULL)
-		vfree(sw_context->cmd_bounce);
-
+	vfree(sw_context->cmd_bounce);
 	sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
 	if (sw_context->cmd_bounce == NULL) {
Signature · 1 line
2.4.5
Reviewed-by
#338 lore raw

Re: [PATCH 1/1] DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 6 Jul 2015 09:49:11 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

kfree will check that.

Quoted 29 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 654c8da..f718a6d 100644
@@ -2292,9 +2292,7 @@ static int vmw_resize_cmd_bounce(struct
 vmw_sw_context *sw_context,
                                   (sw_context->cmd_bounce_size >> 1));
        }
 
-       if (sw_context->cmd_bounce != NULL)
-               vfree(sw_context->cmd_bounce);
-
+       vfree(sw_context->cmd_bounce);
        sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
        if (sw_context->cmd_bounce == NULL) {

--
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#339 lore raw

Re: DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

Quoted 3 lines

kfree will check that.

How does this feedback fit to a check before a call of the vfree() function?

Regards,
Markus

#340 lore raw

Re: DRM-vmwgfx: Deletion of an unnecessary check before the function call "vfree"

Quoted 8 lines · SF Markus Elfring
Quoted 3 lines

kfree will check that.

How does this feedback fit to a check before a call of the vfree() function?

I might have made a mistake, the ctl^] lead me to the vfree in mm/nommu.c,

there is also a vfree() function in mm/vmalloc.c.

Anyway, I think the catch is reasonable.

Quoted 3 lines

Regards,
Markus

Signature · 6 lines
Best regards
Junwang Zhao
Microprocessor Research and Develop Center
Department of Computer Science &Technology
Peking University
Beijing, 100871, PRC

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#341 lore raw

PATCH 1/1 drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 1a1a87c..dc5beff 100644
@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context,
 				   (sw_context->cmd_bounce_size >> 1));
 	}
 
-	if (sw_context->cmd_bounce != NULL)
-		vfree(sw_context->cmd_bounce);
-
+	vfree(sw_context->cmd_bounce);
 	sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
 	if (sw_context->cmd_bounce == NULL) {
Signature · 1 line
2.9.2
Applied
#342 lore raw

Re: [PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied to drm-misc

Quoted 26 lines
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -4
index 1a1a87c..dc5beff 100644
@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context,
                                   (sw_context->cmd_bounce_size >> 1));
        }
 
-       if (sw_context->cmd_bounce != NULL)
-               vfree(sw_context->cmd_bounce);
-
+       vfree(sw_context->cmd_bounce);
        sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
        if (sw_context->cmd_bounce == NULL) {
--

2.9.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/1
#343 lore raw

Re: [PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

Looks good. Thanks!

Quoted 31 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
index 1a1a87c..dc5beff 100644
@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context,
 				   (sw_context->cmd_bounce_size >> 1));
 	}
 
-	if (sw_context->cmd_bounce != NULL)
-		vfree(sw_context->cmd_bounce);
-
+	vfree(sw_context->cmd_bounce);
 	sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
 
 	if (sw_context->cmd_bounce == NULL) {
Signature · 1 line
2.9.2
#344 lore raw

PATCH 1/1 HID-picoLCD: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and rc_unregister_device() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/hid/hid-picolcd_backlight.c +1 -2
index a32c5f8..808807a 100644
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
drivers/hid/hid-picolcd_cir.c +1 -2
index 045f8eb..9628651 100644
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
drivers/hid/hid-picolcd_lcd.c +1 -2
index 89821c2..22dcbe1 100644
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)
Signature · 1 line
2.1.3
#345 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

Quoted 49 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and rc_unregister_device() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/hid/hid-picolcd_backlight.c +1 -2
index a32c5f8..808807a 100644
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
drivers/hid/hid-picolcd_cir.c +1 -2
index 045f8eb..9628651 100644
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
drivers/hid/hid-picolcd_lcd.c +0 -0
index 89821c2..22dcbe1 100644

drivers/hid/hid-picolcd_lcd.c void picolcd_exit_lcd(struct picolcd_data *data) · line 98

Quoted 9 lines
drivers/hid/hid-picolcd_lcd.c +1 -2
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
 int picolcd_resume_lcd(struct picolcd_data *data)

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

maintainer Reviewed-by
#346 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

Quoted 56 lines · On Sun, 28 Jun 2015 13:54:56 +0200 SF Markus Elfring wrote:
Quoted 56 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 18:30:22 +0100

The functions backlight_device_unregister(), lcd_device_unregister() and rc_unregister_device() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/hid/hid-picolcd_backlight.c | 3 +--
 drivers/hid/hid-picolcd_cir.c       | 3 +--
 drivers/hid/hid-picolcd_lcd.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/hid/hid-picolcd_backlight.c +1 -2
index a32c5f8..808807a 100644
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
 	struct backlight_device *bdev = data->backlight;
 
 	data->backlight = NULL;
-	if (bdev)
-		backlight_device_unregister(bdev);
+	backlight_device_unregister(bdev);
 }
 
 int picolcd_resume_backlight(struct picolcd_data *data)
drivers/hid/hid-picolcd_cir.c +1 -2
index 045f8eb..9628651 100644
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
 	struct rc_dev *rdev = data->rc_dev;
 
 	data->rc_dev = NULL;
-	if (rdev)
-		rc_unregister_device(rdev);
+	rc_unregister_device(rdev);
 }
 
drivers/hid/hid-picolcd_lcd.c +1 -2
index 89821c2..22dcbe1 100644
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
 	struct lcd_device *ldev = data->lcd;
 
 	data->lcd = NULL;
-	if (ldev)
-		lcd_device_unregister(ldev);
+	lcd_device_unregister(ldev);
 }
 
Quoted 5 lines

drivers/hid/hid-picolcd_lcd.c void picolcd_exit_lcd(struct picolcd_data *data) · line 98

Quoted 2 lines
drivers/hid/hid-picolcd_lcd.c +0 -0
 int picolcd_resume_lcd(struct picolcd_data *data)

Would you like to integrate this update suggestion into another source code repository?

Sorry for forgetting about this patch.

Looks good to me:

Jiri, can you take it?

Best regards,
Bruno

Quoted 2 lines

Regards,
Markus

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#347 lore raw

Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls

Quoted 6 lines · Bruno Prémont

Sorry for forgetting about this patch.

Looks good to me:

Jiri, can you take it?

Could either of you please bounce me the original patch? I don't think I've seen in in my mailbox (or it's too long time ago).

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#348 lore raw

PATCH 1/1 InfiniBand: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/main.c +1 -2
index 8b72cf3..50dee1a 100644
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
drivers/infiniband/hw/mthca/mthca_reset.c +1 -2
index 74c6a94..c521654 100644
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 
Signature · 1 line
2.1.3
#349 lore raw

Re: [PATCH] InfiniBand: Deletion of unnecessary checks before two function calls

Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/infiniband/hw/mlx4/main.c         | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx4/main.c +1 -2
index 8b72cf3..50dee1a 100644
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
 		if (!dm[i]) {
 			pr_err("failed to allocate memory for tunneling qp update work struct\n");
 			for (i = 0; i < dev->caps.num_ports; i++) {
-				if (dm[i])
-					kfree(dm[i]);
+				kfree(dm[i]);
 			}
 			goto out;
 		}
drivers/infiniband/hw/mthca/mthca_reset.c +0 -0
index 74c6a94..c521654 100644

drivers/infiniband/hw/mthca/mthca_reset.c good: · line 285

Quoted 9 lines
drivers/infiniband/hw/mthca/mthca_reset.c +1 -2
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 

More software developers became interested in similar source code improvements.

infiniband: Remove redundant NULL check before kfree
https://lkml.org/lkml/2015/6/26/45
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg919966.html

Regards,
Markus

#350 lore raw

cover IB/mthca: Fine-tuning for mthca_reset()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 12:50:12 +0200

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (3):
Delete an unnecessary check before the function call "pci_dev_put" Less function calls after error detection
Delete unnecessary variable initialisations

 drivers/infiniband/hw/mthca/mthca_reset.c | 48 +++++++++++++++----------------
 1 file changed, 23 insertions(+), 25 deletions(-)
Signature · 1 line
2.9.2
#351 lore raw

PATCH 1/3 IB/mthca: Delete an unnecessary check before the function call "pci_dev_put"

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 10:05:12 +0200

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +1 -2
index 74c6a94..c521654 100644
@@ -279,8 +279,7 @@ good:
 	}
 
 out:
-	if (bridge)
-		pci_dev_put(bridge);
+	pci_dev_put(bridge);
 	kfree(bridge_header);
 	kfree(hca_header);
 
Signature · 1 line
2.9.2
Reviewed-by on v1 1/3
#352 lore raw

Re: [PATCH 1/3] IB/mthca: Delete an unnecessary check before the function call "pci_dev_put"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 10:05:12 +0200

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks,

#353 lore raw

PATCH 2/3 IB/mthca: Less function calls in mthca_reset() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:28:30 +0200

The kfree() function was called in a few cases by the mthca_reset() function during error handling even if the passed variables "bridge_header" and "hca_header" contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

---
 drivers/infiniband/hw/mthca/mthca_reset.c | 41 +++++++++++++++----------------
 1 file changed, 20 insertions(+), 21 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +20 -21
index c521654..6727af2 100644
@@ -98,7 +98,7 @@ int mthca_reset(struct mthca_dev *mdev)
 		err = -ENOMEM;
 		mthca_err(mdev, "Couldn't allocate memory to save HCA "
 			  "PCI header, aborting.\n");
-		goto out;
+		goto put_dev;
 	}
 
 	for (i = 0; i < 64; ++i) {
@@ -108,7 +108,7 @@ int mthca_reset(struct mthca_dev *mdev)
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't save HCA "
 				  "PCI header, aborting.\n");
-			goto out;
+			goto free_hca;
 		}
 	}
 
@@ -121,7 +121,7 @@ int mthca_reset(struct mthca_dev *mdev)
 			err = -ENOMEM;
 			mthca_err(mdev, "Couldn't allocate memory to save HCA "
 				  "bridge PCI header, aborting.\n");
-			goto out;
+			goto free_hca;
 		}
 
 		for (i = 0; i < 64; ++i) {
@@ -131,7 +131,7 @@ int mthca_reset(struct mthca_dev *mdev)
 				err = -ENODEV;
 				mthca_err(mdev, "Couldn't save HCA bridge "
 					  "PCI header, aborting.\n");
-				goto out;
+				goto free_bh;
 			}
 		}
 		bridge_pcix_cap = pci_find_capability(bridge, PCI_CAP_ID_PCIX);
@@ -139,7 +139,7 @@ int mthca_reset(struct mthca_dev *mdev)
 				err = -ENODEV;
 				mthca_err(mdev, "Couldn't locate HCA bridge "
 					  "PCI-X capability, aborting.\n");
-				goto out;
+				goto free_bh;
 		}
 	}
 
@@ -152,7 +152,7 @@ int mthca_reset(struct mthca_dev *mdev)
 			err = -ENOMEM;
 			mthca_err(mdev, "Couldn't map HCA reset register, "
 				  "aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 
 		writel(MTHCA_RESET_VALUE, reset);
@@ -172,7 +172,7 @@ int mthca_reset(struct mthca_dev *mdev)
 				err = -ENODEV;
 				mthca_err(mdev, "Couldn't access HCA after reset, "
 					  "aborting.\n");
-				goto out;
+				goto free_bh;
 			}
 
 			if (v != 0xffffffff)
@@ -184,7 +184,7 @@ int mthca_reset(struct mthca_dev *mdev)
 		err = -ENODEV;
 		mthca_err(mdev, "PCI device did not come back after reset, "
 			  "aborting.\n");
-		goto out;
+		goto free_bh;
 	}
 
 good:
@@ -195,14 +195,14 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA bridge Upstream "
 				  "split transaction control, aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 		if (pci_write_config_dword(bridge, bridge_pcix_cap + 0xc,
 				 bridge_header[(bridge_pcix_cap + 0xc) / 4])) {
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA bridge Downstream "
 				  "split transaction control, aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 		/*
 		 * Bridge control register is at 0x3e, so we'll
@@ -216,7 +216,7 @@ good:
 				err = -ENODEV;
 				mthca_err(mdev, "Couldn't restore HCA bridge reg %x, "
 					  "aborting.\n", i);
-				goto out;
+				goto free_bh;
 			}
 		}
 
@@ -225,7 +225,7 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA bridge COMMAND, "
 				  "aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 	}
 
@@ -235,7 +235,7 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA PCI-X "
 				  "command register, aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 	}
 
@@ -246,7 +246,7 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA PCI Express "
 				  "Device Control register, aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 		linkctl = hca_header[(hca_pcie_cap + PCI_EXP_LNKCTL) / 4];
 		if (pcie_capability_write_word(mdev->pdev, PCI_EXP_LNKCTL,
@@ -254,7 +254,7 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA PCI Express "
 				  "Link control register, aborting.\n");
-			goto out;
+			goto free_bh;
 		}
 	}
 
@@ -266,7 +266,7 @@ good:
 			err = -ENODEV;
 			mthca_err(mdev, "Couldn't restore HCA reg %x, "
 				  "aborting.\n", i);
-			goto out;
+			goto free_bh;
 		}
 	}
 
@@ -275,13 +275,12 @@ good:
 		err = -ENODEV;
 		mthca_err(mdev, "Couldn't restore HCA COMMAND, "
 			  "aborting.\n");
-		goto out;
 	}
-
-out:
-	pci_dev_put(bridge);
+free_bh:
 	kfree(bridge_header);
+free_hca:
 	kfree(hca_header);
-
+put_dev:
+	pci_dev_put(bridge);
 	return err;
 }
Signature · 1 line
2.9.2
Reviewed-by on v1 2/3
#354 lore raw

Re: [PATCH 2/3] IB/mthca: Less function calls in mthca_reset() after error detection

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:28:30 +0200

The kfree() function was called in a few cases by the mthca_reset() function during error handling even if the passed variables "bridge_header" and "hca_header" contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Thanks,

#355 lore raw

PATCH 3/3 IB/mthca: Delete unnecessary variable initialisations in mthca_reset()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:54:06 +0200

Three local variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/infiniband/hw/mthca/mthca_reset.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +3 -3
index 6727af2..0a458c6 100644
@@ -42,12 +42,12 @@ int mthca_reset(struct mthca_dev *mdev)
 {
 	int i;
 	int err = 0;
-	u32 *hca_header    = NULL;
+	u32 *hca_header;
 	u32 *bridge_header = NULL;
 	struct pci_dev *bridge = NULL;
 	int bridge_pcix_cap = 0;
-	int hca_pcie_cap = 0;
-	int hca_pcix_cap = 0;
+	int hca_pcie_cap;
+	int hca_pcix_cap;
 
 	u16 devctl;
 	u16 linkctl;
Signature · 1 line
2.9.2
#356 lore raw

Re: [PATCH 0/3] IB/mthca: Fine-tuning for mthca_reset()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 12:50:12 +0200

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Quoted 9 lines

Markus Elfring (3):
  Delete an unnecessary check before the function call "pci_dev_put" Less function calls after error detection
  Delete unnecessary variable initialisations

 drivers/infiniband/hw/mthca/mthca_reset.c | 48 +++++++++++++++----
------------

 1 file changed, 23 insertions(+), 25 deletions(-)

I applied 1 and 2, but skipped 3.  My memory from long ago is that those variables didn't used to have initializers, but the compiler complained, so the initialization was added at some point.  This is a dead driver, only around for the few systems out there using out dated hardware.  I don't want to change this and then have to revert it because the old warnings came back, so I just dropped that patch.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD
#357 lore raw

PATCH 1/1 mISDN: Deletion of unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/isdn/mISDN/l1oip_codec.c +2 -4
index a601c84..9b033be 100644
@@ -312,10 +312,8 @@ l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
 void
 l1oip_4bit_free(void)
 {
-	if (table_dec)
-		vfree(table_dec);
-	if (table_com)
-		vfree(table_com);
+	vfree(table_dec);
+	vfree(table_com);
 	table_com = NULL;
 	table_dec = NULL;
 }
Signature · 1 line
2.1.3
maintainer Applied
#358 lore raw

Re: [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"

From: SF Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 20:55:18 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

#359 lore raw

PATCH 1/1 bcache: Deletion of an unnecessary check before the function call "kobject_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/bcache/super.c +1 -2
index d4713d0..1443c55 100644
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)
Signature · 1 line
2.1.3
#360 lore raw

Re: [PATCH] bcache: Deletion of an unnecessary check before the function call "kobject_put"

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 21:25:39 +0100

The kobject_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/md/bcache/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/bcache/super.c +0 -0
index d4713d0..1443c55 100644

drivers/md/bcache/super.c static void bcache_exit(void) · line 2082

Quoted 9 lines
drivers/md/bcache/super.c +1 -2
@@ -2076,8 +2076,7 @@ static void bcache_exit(void)
 {
 	bch_debug_exit();
 	bch_request_exit();
-	if (bcache_kobj)
-		kobject_put(bcache_kobj);
+	kobject_put(bcache_kobj);
 	if (bcache_wq)
 		destroy_workqueue(bcache_wq);
 	if (bcache_major)

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#361 lore raw

PATCH 1/1 dm: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 21:48:10 +0100

The functions dm_table_destroy() and vfree() perform also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/md/dm-ioctl.c           |  3 +--
 drivers/md/dm-snap-persistent.c | 12 ++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/md/dm-ioctl.c +1 -2
index 5152142..0b925a4 100644
@@ -1050,8 +1050,7 @@ static int do_resume(struct dm_ioctl *param)
 	 * Since dm_swap_table synchronizes RCU, nobody should be in
 	 * read-side critical section already.
 	 */
-	if (old_map)
-		dm_table_destroy(old_map);
+	dm_table_destroy(old_map);
 
 	if (!r)
 		__dev_status(md, param);
drivers/md/dm-snap-persistent.c +4 -8
index d6e8817..4b29bac 100644
@@ -200,16 +200,13 @@ err_area:
 
 static void free_area(struct pstore *ps)
 {
-	if (ps->area)
-		vfree(ps->area);
+	vfree(ps->area);
 	ps->area = NULL;
 
-	if (ps->zero_area)
-		vfree(ps->zero_area);
+	vfree(ps->zero_area);
 	ps->zero_area = NULL;
 
-	if (ps->header_area)
-		vfree(ps->header_area);
+	vfree(ps->header_area);
 	ps->header_area = NULL;
 }
 
@@ -605,8 +602,7 @@ static void persistent_dtr(struct dm_exception_store *store)
 	free_area(ps);
 
 	/* Allocated in persistent_read_metadata */
-	if (ps->callbacks)
-		vfree(ps->callbacks);
+	vfree(ps->callbacks);
 
 	kfree(ps);
 }
Signature · 1 line
2.1.3
#362 lore raw

cover DVB-frontends: Deletion of a few unnecessary checks

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 23:30:37 +0100

Another update suggestion was taken into account after a patch was applied from static source code analysis.

Markus Elfring (3):
DVB-frontends: Deletion of unnecessary checks before the function
call "release_firmware"
m88ds3103: One function call less in m88ds3103_init() after error detection
si2168: One function call less in si2168_init() after error detection

 drivers/media/dvb-frontends/drx39xyj/drxj.c |  3 +--
 drivers/media/dvb-frontends/drxk_hard.c     |  3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 12 ++++++------
 drivers/media/dvb-frontends/si2168.c        | 10 +++++-----
 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 1 line
2.1.3
#363 lore raw

PATCH 1/3 DVB-frontends: Deletion of unnecessary checks before the function call "release_firmware"

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 22:27:24 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 3 +--
 drivers/media/dvb-frontends/drxk_hard.c     | 3 +--
 drivers/media/dvb-frontends/m88ds3103.c     | 3 +--
 drivers/media/dvb-frontends/si2168.c        | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/media/dvb-frontends/drx39xyj/drxj.c +1 -2
index 7ca7a21..08e6ca5 100644
@@ -12255,8 +12255,7 @@ static void drx39xxj_release(struct dvb_frontend *fe)
 	kfree(demod->my_ext_attr);
 	kfree(demod->my_common_attr);
 	kfree(demod->my_i2c_dev_addr);
-	if (demod->firmware)
-		release_firmware(demod->firmware);
+	release_firmware(demod->firmware);
 	kfree(demod);
 	kfree(state);
 }
drivers/media/dvb-frontends/drxk_hard.c +1 -2
index cce94a7..f871478 100644
@@ -6309,8 +6309,7 @@ static void drxk_release(struct dvb_frontend *fe)
 	struct drxk_state *state = fe->demodulator_priv;
 
 	dprintk(1, "\n");
-	if (state->fw)
-		release_firmware(state->fw);
+	release_firmware(state->fw);
 
 	kfree(state);
 }
drivers/media/dvb-frontends/m88ds3103.c +1 -2
index dfe0c2f..e88f0f6 100644
@@ -637,8 +637,7 @@ skip_fw_download:
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
drivers/media/dvb-frontends/si2168.c +1 -2
index 8f81d97..6a455f9 100644
@@ -469,8 +469,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
 	return 0;
 err:
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
Signature · 1 line
2.1.3
#364 lore raw

PATCH 2/3 m88ds3103: One function call less in m88ds3103_init() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 23:20:51 +0100

The release_firmware() function was called in some cases by the m88ds3103_init() function during error handling even if the passed variable contained still a null pointer. This implementation detail could be improved by the introduction of another jump label.

---
 drivers/media/dvb-frontends/m88ds3103.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/media/dvb-frontends/m88ds3103.c +6 -5
index e88f0f6..82da715 100644
@@ -590,7 +590,7 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x01);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	for (remaining = fw->size; remaining > 0;
 			remaining -= (priv->cfg->i2c_wr_max - 1)) {
@@ -604,13 +604,13 @@ static int m88ds3103_init(struct dvb_frontend *fe)
 			dev_err(&priv->i2c->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
 	ret = m88ds3103_wr_reg(priv, 0xb2, 0x00);
 	if (ret)
-		goto err;
+		goto error_fw_release;
 
 	release_firmware(fw);
 	fw = NULL;
@@ -636,9 +636,10 @@ skip_fw_download:
 	priv->warm = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
Signature · 1 line
2.1.3
#365 lore raw

PATCH 3/3 si2168: One function call less in si2168_init() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 19 Nov 2014 23:23:15 +0100

The release_firmware() function was called in some cases by the si2168_init() function during error handling even if the passed variable contained still a null pointer. This implementation detail could be improved by the introduction of another jump label.

---
 drivers/media/dvb-frontends/si2168.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/dvb-frontends/si2168.c +5 -4
index 6a455f9..b8c6372 100644
@@ -428,7 +428,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware file '%s' not found\n",
 					KBUILD_MODNAME, fw_file);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -448,7 +448,7 @@ static int si2168_init(struct dvb_frontend *fe)
 			dev_err(&s->client->dev,
 					"%s: firmware download failed=%d\n",
 					KBUILD_MODNAME, ret);
-			goto err;
+			goto error_fw_release;
 		}
 	}
 
@@ -468,9 +468,10 @@ static int si2168_init(struct dvb_frontend *fe)
 	s->active = true;
 
 	return 0;
-err:
-	release_firmware(fw);
 
+error_fw_release:
+	release_firmware(fw);
+err:
 	dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
 	return ret;
 }
Signature · 1 line
2.1.3
#366 lore raw

PATCH 1/1 firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/firewire/firedtv-ci.c +1 -2
index e5ebdbf..e63f582 100644
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-	if (fdtv->cadev)
-		dvb_unregister_device(fdtv->cadev);
+	dvb_unregister_device(fdtv->cadev);
 }
Signature · 1 line
2.1.3
maintainer Reviewed-by on v1 1/1
#367 lore raw

Re: [PATCH 1/1] [media] firewire: Deletion of an unnecessary check before the function call "dvb_unregister_device"

Quoted 9 lines · On Nov 20 SF Markus Elfring wrote:

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 10:49:07 +0100

The dvb_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Quoted 16 lines
---
 drivers/media/firewire/firedtv-ci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/firewire/firedtv-ci.c +1 -2
index e5ebdbf..e63f582 100644
@@ -253,6 +253,5 @@ int fdtv_ca_register(struct firedtv *fdtv)
 
 void fdtv_ca_release(struct firedtv *fdtv)
 {
-	if (fdtv->cadev)
-		dvb_unregister_device(fdtv->cadev);
+	dvb_unregister_device(fdtv->cadev);
 }
Signature · 3 lines
Stefan Richter
-===-==- =-= =-=--
http://arcgraph.de/sr/
#368 lore raw

PATCH 1/1 i2c: Deletion of an unnecessary check before the function call "rc_unregister_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 11:13:16 +0100

The rc_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/i2c/ir-kbd-i2c.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ir-kbd-i2c.c +1 -2
index 8311f1a..175a761 100644
@@ -464,8 +464,7 @@ static int ir_remove(struct i2c_client *client)
 	cancel_delayed_work_sync(&ir->work);
 
 	/* unregister device */
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* free memory */
 	return 0;
Signature · 1 line
2.1.3
#369 lore raw

PATCH 1/1 platform: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 11:44:20 +0100

The functions i2c_put_adapter() and release_firmware() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/platform/exynos4-is/fimc-is.c   | 6 ++----
 drivers/media/platform/s3c-camif/camif-core.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/media/platform/exynos4-is/fimc-is.c +2 -4
index 5476dce..a1db27b 100644
@@ -428,8 +428,7 @@ static void fimc_is_load_firmware(const struct firmware *fw, void *context)
 	 * needed around for copying to the IS working memory every
 	 * time before the Cortex-A5 is restarted.
 	 */
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	is->fw.f_w = fw;
 done:
 	mutex_unlock(&is->lock);
@@ -937,8 +936,7 @@ static int fimc_is_remove(struct platform_device *pdev)
 	vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 	fimc_is_put_clocks(is);
 	fimc_is_debugfs_remove(is);
-	if (is->fw.f_w)
-		release_firmware(is->fw.f_w);
+	release_firmware(is->fw.f_w);
 	fimc_is_free_cpu_memory(is);
 
 	return 0;
drivers/media/platform/s3c-camif/camif-core.c +1 -2
index b385747..3b09b5b 100644
@@ -256,8 +256,7 @@ static void camif_unregister_sensor(struct camif_dev *camif)
 	v4l2_device_unregister_subdev(sd);
 	camif->sensor.sd = NULL;
 	i2c_unregister_device(client);
-	if (adapter)
-		i2c_put_adapter(adapter);
+	i2c_put_adapter(adapter);
 }
 
 static int camif_create_media_links(struct camif_dev *camif)
Signature · 1 line
2.1.3
#370 lore raw

PATCH 1/1 rc: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 13:01:32 +0100

The functions input_free_device() and rc_close() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/rc/lirc_dev.c | 3 +--
 drivers/media/rc/rc-main.c  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/media/rc/lirc_dev.c +1 -2
index dc5cbff..5c232e6 100644
@@ -518,8 +518,7 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file)
 
 	WARN_ON(mutex_lock_killable(&lirc_dev_lock));
 
-	if (ir->d.rdev)
-		rc_close(ir->d.rdev);
+	rc_close(ir->d.rdev);
 
 	ir->open--;
 	if (ir->attached) {
drivers/media/rc/rc-main.c +1 -2
index 8d3b74c..66df9fb 100644
@@ -1298,8 +1298,7 @@ void rc_free_device(struct rc_dev *dev)
 	if (!dev)
 		return;
 
-	if (dev->input_dev)
-		input_free_device(dev->input_dev);
+	input_free_device(dev->input_dev);
 
 	put_device(&dev->dev);
 
Signature · 1 line
2.1.3
#371 lore raw

PATCH 1/1 USB: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 13:26:36 +0100

The functions pvr2_hdw_destroy(), rc_unregister_device() and vfree() perform also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/media/usb/au0828/au0828-input.c     | 3 +--
 drivers/media/usb/em28xx/em28xx-input.c     | 3 +--
 drivers/media/usb/pvrusb2/pvrusb2-context.c | 2 +-
 drivers/media/usb/s2255/s2255drv.c          | 3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)
drivers/media/usb/au0828/au0828-input.c +1 -2
index fd0d3a90..3357141 100644
@@ -353,8 +353,7 @@ void au0828_rc_unregister(struct au0828_dev *dev)
 	if (!ir)
 		return;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
drivers/media/usb/em28xx/em28xx-input.c +1 -2
index ed843bd..67a22f4 100644
@@ -838,8 +838,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
 	if (!ir)
 		goto ref_put;
 
-	if (ir->rc)
-		rc_unregister_device(ir->rc);
+	rc_unregister_device(ir->rc);
 
 	/* done */
 	kfree(ir);
drivers/media/usb/pvrusb2/pvrusb2-context.c +1 -1
index 7c19ff7..c8761c7 100644
@@ -80,7 +80,7 @@ static void pvr2_context_set_notify(struct pvr2_context *mp, int fl)
 static void pvr2_context_destroy(struct pvr2_context *mp)
 {
 	pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp);
-	if (mp->hdw) pvr2_hdw_destroy(mp->hdw);
+	pvr2_hdw_destroy(mp->hdw);
 	pvr2_context_set_notify(mp, 0);
 	mutex_lock(&pvr2_context_mutex);
 	if (mp->exist_next) {
drivers/media/usb/s2255/s2255drv.c +1 -2
index 2c90186..3cab886 100644
@@ -1976,8 +1976,7 @@ static int s2255_release_sys_buffers(struct s2255_vc *vc)
 {
 	unsigned long i;
 	for (i = 0; i < SYS_FRAMES; i++) {
-		if (vc->buffer.frame[i].lpvbits)
-			vfree(vc->buffer.frame[i].lpvbits);
+		vfree(vc->buffer.frame[i].lpvbits);
 		vc->buffer.frame[i].lpvbits = NULL;
 	}
 	return 0;
Signature · 1 line
2.1.3
#372 lore raw

PATCH 1/1 MTD: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 13:50:43 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/mtd/chips/cfi_cmdset_0001.c | 3 +--
 drivers/mtd/devices/pmc551.c        | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/chips/cfi_cmdset_0001.c +1 -2
index 3096f3d..286b97a 100644
@@ -2654,8 +2654,7 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
 	kfree(cfi);
 	for (i = 0; i < mtd->numeraseregions; i++) {
 		region = &mtd->eraseregions[i];
-		if (region->lockmap)
-			kfree(region->lockmap);
+		kfree(region->lockmap);
 	}
 	kfree(mtd->eraseregions);
 }
drivers/mtd/devices/pmc551.c +1 -2
index f02603e..708b7e8 100644
@@ -812,8 +812,7 @@ static int __init init_pmc551(void)
 	}
 
 	/* Exited early, reference left over */
-	if (PCI_Device)
-		pci_dev_put(PCI_Device);
+	pci_dev_put(PCI_Device);
 
 	if (!pmc551list) {
 		printk(KERN_NOTICE "pmc551: not detected\n");
Signature · 1 line
2.1.3
Applied
#373 lore raw

Re: [PATCH 1/1] MTD: Deletion of unnecessary checks before two function calls

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 13:50:43 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied to l2-mtd.git.

Brian

#374 lore raw

PATCH 1/1 IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/ibm/emac/core.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +8 -16
index 87bd953..3f3fba9 100644
@@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev,
 
 static void emac_put_deps(struct emac_instance *dev)
 {
-	if (dev->mal_dev)
-		of_dev_put(dev->mal_dev);
-	if (dev->zmii_dev)
-		of_dev_put(dev->zmii_dev);
-	if (dev->rgmii_dev)
-		of_dev_put(dev->rgmii_dev);
-	if (dev->mdio_dev)
-		of_dev_put(dev->mdio_dev);
-	if (dev->tah_dev)
-		of_dev_put(dev->tah_dev);
+	of_dev_put(dev->mal_dev);
+	of_dev_put(dev->zmii_dev);
+	of_dev_put(dev->rgmii_dev);
+	of_dev_put(dev->mdio_dev);
+	of_dev_put(dev->tah_dev);
 }
 
 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
-		if (deps[i].node)
-			of_node_put(deps[i].node);
+		of_node_put(deps[i].node);
 		if (err && deps[i].ofdev)
 			of_dev_put(deps[i].ofdev);
 	}
@@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
 		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
 	}
-	if (deps[EMAC_DEP_PREV_IDX].ofdev)
-		of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
+	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
 	return err;
 }
 
@@ -3113,8 +3106,7 @@ static void __exit emac_exit(void)
 
 	/* Destroy EMAC boot list */
 	for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
-		if (emac_boot_list[i])
-			of_node_put(emac_boot_list[i]);
+		of_node_put(emac_boot_list[i]);
 }
 
 module_init(emac_init);
Signature · 1 line
2.1.3
maintainer Applied
#375 lore raw

Re: [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"

From: SF Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:28:25 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied.

#376 lore raw

PATCH 1/1 net: Xilinx: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +1 -2
index fda5891..af60867 100644
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
drivers/net/ethernet/xilinx/xilinx_emaclite.c +1 -2
index 28dbbdc..2485879 100644
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
Signature · 1 line
2.1.3
Reviewed-by on v1 1/1
#377 lore raw

Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Sören
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#378 lore raw

Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:50:26 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied.

#379 lore raw

PATCH 1/1 net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/hyperv/netvsc.c +1 -2
index da2d346..ffe7481 100644
@@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
+	vfree(net_device->sub_cb_buf);
 
 	kfree(net_device);
 	return 0;
Signature · 1 line
2.1.3
maintainer
#380 lore raw

RE: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogU0YgTWFya3VzIEVsZnJp bmcgW21haWx0bzplbGZyaW5nQHVzZXJzLnNvdXJjZWZvcmdlLm5ldF0NCj4gU2VudDogVGh1cnNk YXksIE5vdmVtYmVyIDIwLCAyMDE0IDk6MjUgQU0NCj4gVG86IEhhaXlhbmcgWmhhbmc7IEtZIFNy aW5pdmFzYW47IGRldmVsQGxpbnV4ZHJpdmVycHJvamVjdC5vcmc7DQo+IG5ldGRldkB2Z2VyLmtl cm5lbC5vcmcNCj4gQ2M6IExLTUw7IGtlcm5lbC1qYW5pdG9yc0B2Z2VyLmtlcm5lbC5vcmc7IEp1 bGlhIExhd2FsbA0KPiBTdWJqZWN0OiBbUEFUQ0ggMS8xXSBuZXQ6IEh5cGVyLVY6IERlbGV0aW9u IG9mIGFuIHVubmVjZXNzYXJ5IGNoZWNrDQo+IGJlZm9yZSB0aGUgZnVuY3Rpb24gY2FsbCAidmZy ZWUiDQo+IA0KPiBGcm9tOiBNYXJrdXMgRWxmcmluZyA8ZWxmcmluZ0B1c2Vycy5zb3VyY2Vmb3Jn ZS5uZXQ+DQo+IERhdGU6IFRodSwgMjAgTm92IDIwMTQgMTU6MTU6MjEgKzAxMDANCj4gDQo+IFRo ZSB2ZnJlZSgpIGZ1bmN0aW9uIHBlcmZvcm1zIGFsc28gaW5wdXQgcGFyYW1ldGVyIHZhbGlkYXRp b24uIFRodXMgdGhlDQo+IHRlc3QNCj4gYXJvdW5kIHRoZSBjYWxsIGlzIG5vdCBuZWVkZWQuDQo+ IA0KPiBUaGlzIGlzc3VlIHdhcyBkZXRlY3RlZCBieSB1c2luZyB0aGUgQ29jY2luZWxsZSBzb2Z0 d2FyZS4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IE1hcmt1cyBFbGZyaW5nIDxlbGZyaW5nQHVzZXJz LnNvdXJjZWZvcmdlLm5ldD4NCg0KU2lnbmVkLW9mZi1ieTogSGFpeWFuZyBaaGFuZyA8aGFpeWFu Z3pAbWljcm9zb2Z0LmNvbT4NCg0KVGhhbmtzIQ0KDQo

maintainer
#381 lore raw

Re: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 15:25:27 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

This does not apply to the net-next tree, please respin.

#382 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

Quoted 1 line

This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published in March to get more constructive feedback?
Will they run faster for another analysis on current Linux source files with your test systems (than my computer)?

Regards,
Markus

maintainer
#383 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

From: SF Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 23:15:42 +0100

Quoted 6 lines
Quoted 1 line

This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches against the correct tree.

If I had time to investigate automation of changes using such tools, I would participate in such discussions, but I don't.

#384 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

Quoted 2 lines

This has nothing to do with me asking you to frame your patches against the correct tree.

I imagine than someone other can also pick up this update suggestion (a simple change of two lines) quicker before I might try another software build again from a different commit as a base.

Regards,
Markus

#385 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

Quoted 6 lines · SF Markus Elfring
Quoted 2 lines

This has nothing to do with me asking you to frame your patches against the correct tree.

I imagine than someone other can also pick up this update suggestion (a simple change of two lines) quicker before I might try another software build again from a different commit as a base.

I have no idea why someone would do that.

If you don't bother resubmit, nobody will.

#386 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

Quoted 5 lines
Quoted 3 lines

I imagine than someone other can also pick up this update suggestion (a simple change of two lines) quicker before I might try another software build again from a different commit as a base.

I have no idea why someone would do that.

I imagine that other software users (besides me) like developers and testers might also become curious to try the proposed changes out.

How much will they eventually help to run Linux components a bit faster?

Quoted 1 line

If you don't bother resubmit, nobody will.

I hope that there are more possibilities for anticipation and acceptance of source code improvement potentials.
Would you also like to contribute a bit more fine-tuning for the affected software versions?

Regards,
Markus

maintainer
#387 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 01:51:24 +0100

Quoted 6 lines
Quoted 2 lines

This has nothing to do with me asking you to frame your patches against the correct tree.

I imagine than someone other can also pick up this update suggestion (a simple change of two lines) quicker before I might try another software build again from a different commit as a base.

Whereas if you learn how to base your changes cleanly on the correct base now, all of your future submissions will go quickly and smoothly into my tree.

#388 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

Quoted 3 lines

Whereas if you learn how to base your changes cleanly on the correct base now, all of your future submissions will go quickly and smoothly into my tree.

My reluctance to work with more Linux repositories will evolve over time. The faster affected software versions can be rebuilt the more it will become interesting to try even more source code improvements out, won't it?

I find it nice that you could accept update suggestions for a few other Linux components already.

Regards,
Markus

maintainer
#389 lore raw

Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

From: SF Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 08:18:31 +0100

Quoted 11 lines
Quoted 3 lines

Whereas if you learn how to base your changes cleanly on the correct base now, all of your future submissions will go quickly and smoothly into my tree.

My reluctance to work with more Linux repositories will evolve over time. The faster affected software versions can be rebuilt the more it will become interesting to try even more source code improvements out, won't it?

I find it nice that you could accept update suggestions for a few other Linux components already.

You are seriously starting to waste our time.

Either resubmit your changes against a clean base, or more on.

Seriously, all I am purely interested in is seeing properly submitted patches, reviewing them, and then integrating them. Anything else is pure noise to me.

Thanks.

#390 lore raw

PATCH v2 1/1 net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

In reply to David Miller

From: Markus Elfring <[email protected]>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/hyperv/netvsc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/hyperv/netvsc.c +1 -3
index 6b46311..6fc834e 100644
@@ -561,9 +561,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
-
+	vfree(net_device->sub_cb_buf);
 	free_netvsc_device(net_device);
 	return 0;
 }
Signature · 1 line
2.1.3
maintainer Applied
#391 lore raw

Re: [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"

From: SF Markus Elfring <[email protected]>
Date: Tue, 25 Nov 2014 22:55:34 +0100

Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

#392 lore raw

PATCH 1/1 net: USB: Deletion of unnecessary checks before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/usb/asix_devices.c | 3 +--
 drivers/net/usb/hso.c          | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/usb/asix_devices.c +1 -2
index 5d19409..8a7582b 100644
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	if (dev->driver_priv)
-		kfree(dev->driver_priv);
+	kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
drivers/net/usb/hso.c +1 -2
index babda7d..9c5aa92 100644
@@ -2746,8 +2746,7 @@ exit:
 		tty_unregister_device(tty_drv, serial->minor);
 		kfree(serial);
 	}
-	if (hso_dev)
-		kfree(hso_dev);
+	kfree(hso_dev);
 	return NULL;
 
 }
Signature · 1 line
2.1.3
maintainer Applied
#393 lore raw

Re: [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"

From: SF Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 16:16:16 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied.

#394 lore raw

PATCH 1/1 net: brcm80211: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -2
index f55f625..8ff7037 100644
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +1 -2
index 8ea9f28..3a2d014 100644
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
 	device_release_driver(fwctx->dev);
 	kfree(fwctx);
 }
drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +1 -2
index 8f8b937..0cb00dc 100644
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 		memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
 				       len : msgbuf->ioctl_resp_ret_len);
 	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
 	return msgbuf->ioctl_resp_status;
 }
drivers/net/wireless/brcm80211/brcmsmac/main.c +1 -2
index 1b47482..ce538a1 100644
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
 		if (txh)
 			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
 					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
 	}
 
 	if (dma && queue < NFIFO) {
Signature · 1 line
2.1.3
Acked-by on v1 1/1
#395 lore raw

Re: [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring<[email protected]>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Goodo for coccinelle and you for running it.

Quoted 64 lines
---
  drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
  drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
  drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
  drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
  4 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -2
index f55f625..8ff7037 100644
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
  	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
  	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
  	brcmf_sdio_free_glom(bus);
 
  	/* Clear rx control and wake any waiters */
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +1 -2
index 8ea9f28..3a2d014 100644
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
  fail:
  	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
  	device_release_driver(fwctx->dev);
  	kfree(fwctx);
  }
drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +1 -2
index 8f8b937..0cb00dc 100644
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
  		memcpy(buf, skb->data, (len<  msgbuf->ioctl_resp_ret_len) ?
  				       len : msgbuf->ioctl_resp_ret_len);
  	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
  	return msgbuf->ioctl_resp_status;
  }
drivers/net/wireless/brcm80211/brcmsmac/main.c +1 -2
index 1b47482..ce538a1 100644
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
  		if (txh)
  			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
  					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
  	}
 
  	if (dma&&  queue<  NFIFO) {
#396 lore raw

PATCH 1/1 net: brcm80211: Delete an unnecessary check before the function call "release_firmware"

From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:48:23 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +1 -2
index 4248f3c..33afb9a 100644
@@ -449,8 +449,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 	if (raw_nvram)
 		bcm47xx_nvram_release_contents(data);
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
 		goto fail;
 
Signature · 1 line
2.6.2
Acked-by on v1 1/1
#397 lore raw

Re: [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware"

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:48:23 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Quoted 20 lines
---
  drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/firmware.c +1 -2
index 4248f3c..33afb9a 100644
@@ -449,8 +449,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
  	if (raw_nvram)
  		bcm47xx_nvram_release_contents(data);
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
  	if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
  		goto fail;
 
Applied
#398 lore raw

Re: brcm80211: Delete an unnecessary check before the function call"release_firmware"

In reply to SF Markus Elfring
Quoted 11 lines

From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 08:48:23 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

#399 lore raw

PATCH 1/1 PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 17:42:23 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/pci/hotplug/cpci_hotplug_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/hotplug/cpci_hotplug_core.c +1 -2
index e09cf78..82c969b 100644
@@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
-	if (slot->dev)
-		pci_dev_put(slot->dev);
+	pci_dev_put(slot->dev);
 	kfree(slot);
 }
 
Signature · 1 line
2.1.3
maintainer Applied
#400 lore raw

Re: [PATCH 1/1] PCI: hotplug: Deletion of an unnecessary check before the function call "pci_dev_put"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 17:42:23 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied to next-pci/misc for v3.19, thanks. This branch will be rebased when v3.19-rc1 is released.

Bjorn

Quoted 21 lines
---
 drivers/pci/hotplug/cpci_hotplug_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/hotplug/cpci_hotplug_core.c +1 -2
index e09cf78..82c969b 100644
@@ -211,8 +211,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
-	if (slot->dev)
-		pci_dev_put(slot->dev);
+	pci_dev_put(slot->dev);
 	kfree(slot);
 }
 
Signature · 1 line
2.1.3
#401 lore raw

PATCH 1/1 SCSI-OSD: Deletion of an unnecessary check before the function call "put_disk"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 18:11:28 +0100

The put_disk() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/osd/osd_uld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -2
index e1d9a4c..3d82ee1 100644
@@ -408,8 +408,7 @@ static void __remove(struct device *dev)
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
 
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
Signature · 1 line
2.1.3
#402 lore raw

PATCH 1/1 SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
Signature · 1 line
2.4.4
Reviewed-by on v1 1/1
#403 lore raw

Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

Quoted 35 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
Signature · 6 lines
2.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 9 lines
Johannes Thumshirn                                       Storage
[email protected]                             +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#404 lore raw

Re: [PATCH] SCSI-OSD: Delete an unnecessary check before the function call "put_disk"

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 16:06:21 +0200

The put_disk() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Quoted 20 lines
---
 drivers/scsi/osd/osd_uld.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/osd/osd_uld.c +1 -3
index 243eab3..e2075522 100644
@@ -407,9 +407,7 @@ static void __remove(struct device *dev)
 
 	OSD_INFO("osd_remove %s\n",
 		 oud->disk ? oud->disk->disk_name : NULL);
-
-	if (oud->disk)
-		put_disk(oud->disk);
+	put_disk(oud->disk);
 	ida_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
#405 lore raw

PATCH 1/1 SCSI: Deletion of unnecessary checks before the function call "put_device"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 18:48:52 +0100

The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/hosts.c      | 3 +--
 drivers/scsi/scsi_sysfs.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/hosts.c +1 -2
index 6de80e3..57afb19 100644
@@ -337,8 +337,7 @@ static void scsi_host_dev_release(struct device *dev)
 
 	kfree(shost->shost_data);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
drivers/scsi/scsi_sysfs.c +1 -2
index 8b4105a..c977c99 100644
@@ -426,8 +426,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
Signature · 1 line
2.1.3
#406 lore raw

PATCH 1/1 SCSI: Delete unnecessary checks before the function call "put_device"

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 19:24:01 +0200

The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/hosts.c      | 4 +---
 drivers/scsi/scsi_sysfs.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/hosts.c +1 -3
index 8bb173e..84c8565 100644
@@ -336,9 +336,7 @@ static void scsi_host_dev_release(struct device *dev)
 	}
 
 	kfree(shost->shost_data);
-
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 	kfree(shost);
 }
 
drivers/scsi/scsi_sysfs.c +1 -3
index 1ac38e7..9ed5391 100644
@@ -425,9 +425,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	kfree(sdev->vpd_pg80);
 	kfree(sdev->inquiry);
 	kfree(sdev);
-
-	if (parent)
-		put_device(parent);
+	put_device(parent);
 }
 
 static void scsi_device_dev_release(struct device *dev)
Signature · 1 line
2.4.4
#407 lore raw

PATCH 1/1 SCSI-libfc: Deletion of an unnecessary check before the function call "fc_fcp_ddp_done"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 20:10:19 +0100

The fc_fcp_ddp_done() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_exch.c +1 -2
index 1b3a094..aad6f48 100644
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
Signature · 1 line
2.1.3
#408 lore raw

PATCH 1/1 SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:50:32 +0200

The fc_fcp_ddp_done() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_exch.c +1 -2
index 1b3a094..aad6f48 100644
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)
Signature · 1 line
2.4.4
Acked-by on v1 1/1
#409 lore raw

Re: [PATCH] SCSI-libfc: Delete an unnecessary check before the function call "fc_fcp_ddp_done"

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 17:50:32 +0200

The fc_fcp_ddp_done() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/libfc/fc_exch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libfc/fc_exch.c +0 -0
index 1b3a094..aad6f48 100644

drivers/scsi/libfc/fc_exch.c static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport, · line 2126

Quoted 9 lines
drivers/scsi/libfc/fc_exch.c +1 -2
@@ -2120,8 +2120,7 @@ static struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
 	spin_unlock_bh(&ep->ex_lock);
 	return sp;
 err:
-	if (fsp)
-		fc_fcp_ddp_done(fsp);
+	fc_fcp_ddp_done(fsp);
 	rc = fc_exch_done_locked(ep);
 	spin_unlock_bh(&ep->ex_lock);
 	if (!rc)

Looks good.

#410 lore raw

PATCH 1/1 SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/eata_pio.c +1 -2
index 8319d2b..707f64d 100644
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 
Signature · 1 line
2.1.3
#411 lore raw

Re: [PATCH] SCSI-eata_pio: Deletion of an unnecessary check before the function call "pci_dev_put"

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 20:37:30 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/eata_pio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/eata_pio.c +0 -0
index 8319d2b..707f64d 100644

drivers/scsi/eata_pio.c static int eata_pio_release(struct Scsi_Host *sh) · line 128

Quoted 9 lines
drivers/scsi/eata_pio.c +1 -2
@@ -122,8 +122,7 @@ static int eata_pio_release(struct Scsi_Host *sh)
 			release_region(sh->io_port, sh->n_io_port);
 	}
 	/* At this point the PCI reference can go */
-	if (hd->pdev)
-		pci_dev_put(hd->pdev);
+	pci_dev_put(hd->pdev);
 	return 1;
 }
 

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#412 lore raw

PATCH 1/1 SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:18:56 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +1 -2
index c56741f..0bfdcba 100644
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {
Signature · 1 line
2.1.3
#413 lore raw

Re: [PATCH] SCSI-aic94xx: Deletion of an unnecessary check before the function call "kfree"

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:18:56 +0100

The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/aic94xx/aic94xx_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +0 -0
index c56741f..0bfdcba 100644

drivers/scsi/aic94xx/aic94xx_init.c static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha) · line 603

Quoted 9 lines
drivers/scsi/aic94xx/aic94xx_init.c +1 -2
@@ -597,8 +597,7 @@ static void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
 	if (asd_ha->hw_prof.scb_ext)
 		asd_free_coherent(asd_ha, asd_ha->hw_prof.scb_ext);
 
-	if (asd_ha->hw_prof.ddb_bitmap)
-		kfree(asd_ha->hw_prof.ddb_bitmap);
+	kfree(asd_ha->hw_prof.ddb_bitmap);
 	asd_ha->hw_prof.ddb_bitmap = NULL;
 
 	for (i = 0; i < ASD_MAX_PHYS; i++) {

How are the chances to integrate this update suggestion into another source code repository?

Regards,
Markus

#414 lore raw

PATCH 1/1 SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +1 -2
index 8e83d04..a72170f 100644
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
Signature · 1 line
2.1.3
maintainer Acked-by on v1 1/1
#415 lore raw

RE: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

Patch looks good.
Thanks!

-----Original Message-----
From: SF Markus Elfring [mailto:[email protected]]
Sent: 21 November 2014 04:17
To: Anil Gurumurthy; James E. J. Bottomley; Sudarsana Kalluru; linux-scsi
Cc: linux-kernel; [email protected]; Julia Lawall
Subject: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +1 -2
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);

--
2.1.3

#416 lore raw

Re: [PATCH] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

Quoted 37 lines

Patch looks good.
Thanks!

-----Original Message-----
From: SF Markus Elfring [mailto:[email protected]]
Sent: 21 November 2014 04:17
To: Anil Gurumurthy; James E. J. Bottomley; Sudarsana Kalluru; linux-scsi
Cc: linux-kernel; [email protected]; Julia Lawall
Subject: [PATCH 1/1] SCSI-bfa: Deletion of an unnecessary check before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Thu, 20 Nov 2014 23:43:17 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/bfa/bfad_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +1 -3
@@ -399,8 +399,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file)
 	if (!fw_debug)
 		return 0;
 
-	if (fw_debug->debug_buffer)
-		vfree(fw_debug->debug_buffer);
+	vfree(fw_debug->debug_buffer);
 
 	file->private_data = NULL;
 	kfree(fw_debug);
--
Quoted 2 lines

2.1.3

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#417 lore raw

PATCH 1/1 SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 09:15:10 +0100

The dst_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/cxgbi/libcxgbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/cxgbi/libcxgbi.c +1 -2
index addd1dd..95d2654 100644
@@ -798,8 +798,7 @@ void cxgbi_sock_closed(struct cxgbi_sock *csk)
 		return;
 	if (csk->saddr.sin_port)
 		sock_put_port(csk);
-	if (csk->dst)
-		dst_release(csk->dst);
+	dst_release(csk->dst);
 	csk->cdev->csk_release_offload_resources(csk);
 	cxgbi_sock_set_state(csk, CTP_CLOSED);
 	cxgbi_inform_iscsi_conn_closing(csk);
Signature · 1 line
2.1.3
#418 lore raw

Re: [PATCH] SCSI-libcxgbi: Deletion of an unnecessary check before the function call "dst_release"

Quoted 19 lines

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 09:15:10 +0100

The dst_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/cxgbi/libcxgbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/cxgbi/libcxgbi.c +0 -0
index addd1dd..95d2654 100644

drivers/scsi/cxgbi/libcxgbi.c void cxgbi_sock_closed(struct cxgbi_sock *csk) · line 804

Quoted 9 lines
drivers/scsi/cxgbi/libcxgbi.c +1 -2
@@ -798,8 +798,7 @@ void cxgbi_sock_closed(struct cxgbi_sock *csk)
 		return;
 	if (csk->saddr.sin_port)
 		sock_put_port(csk);
-	if (csk->dst)
-		dst_release(csk->dst);
+	dst_release(csk->dst);
 	csk->cdev->csk_release_offload_resources(csk);
 	cxgbi_sock_set_state(csk, CTP_CLOSED);
 	cxgbi_inform_iscsi_conn_closing(csk);

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#419 lore raw

PATCH 1/1 SCSI-fnic: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 09:39:43 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/fnic/fnic_debugfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +1 -2
index 2c613bd..ec70e6d 100644
@@ -102,8 +102,7 @@ void fnic_debugfs_terminate(void)
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
 
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
Signature · 1 line
2.1.3
#420 lore raw

PATCH 1/1 SCSI-fnic: Delete an unnecessary check before the function call "vfree"

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jun 2015 20:40:35 +0200

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/fnic/fnic_debugfs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/fnic/fnic_debugfs.c +1 -3
index d6498fa..855d382 100644
@@ -102,9 +102,7 @@ void fnic_debugfs_terminate(void)
 
 	debugfs_remove(fnic_trace_debugfs_root);
 	fnic_trace_debugfs_root = NULL;
-
-	if (fc_trc_flag)
-		vfree(fc_trc_flag);
+	vfree(fc_trc_flag);
 }
 
 /*
Signature · 1 line
2.4.4
#421 lore raw

PATCH 1/1 target: Deletion of unnecessary checks before the function call "module_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 10:25:45 +0100

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/target/iscsi/iscsi_target_transport.c | 3 +--
 drivers/target/target_core_hba.c              | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/target/iscsi/iscsi_target_transport.c +1 -2
index 882728f..08217d6 100644
@@ -26,8 +26,7 @@ struct iscsit_transport *iscsit_get_transport(int type)
 
 void iscsit_put_transport(struct iscsit_transport *t)
 {
-	if (t->owner)
-		module_put(t->owner);
+	module_put(t->owner);
 }
 
 int iscsit_register_transport(struct iscsit_transport *t)
drivers/target/target_core_hba.c +2 -4
index a25051a..e6e496f 100644
@@ -137,8 +137,7 @@ core_alloc_hba(const char *plugin_name, u32 plugin_dep_id, u32 hba_flags)
 	return hba;
 
 out_module_put:
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 	hba->transport = NULL;
 out_free_hba:
 	kfree(hba);
@@ -159,8 +158,7 @@ core_delete_hba(struct se_hba *hba)
 	pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target"
 			" Core\n", hba->hba_id);
 
-	if (hba->transport->owner)
-		module_put(hba->transport->owner);
+	module_put(hba->transport->owner);
 
 	hba->transport = NULL;
 	kfree(hba);
Signature · 1 line
2.1.3
#422 lore raw

Re: [PATCH 1/1] target: Deletion of unnecessary checks before the function call "module_put"

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 10:25:45 +0100

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

Quoted 8 lines

This issue was detected by using the Coccinelle software.

---
 drivers/target/iscsi/iscsi_target_transport.c | 3 +--
 drivers/target/target_core_hba.c              | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

Applied to target-pending/for-next.

Thanks Markus!

--nab

#423 lore raw

PATCH 1/1 thermal: Exynos: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +2 -4
index 3f5ad25..1cbb9d0 100644
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}
 
 	dev_info(sensor_conf->dev,
Signature · 1 line
2.1.3
#424 lore raw

Re: [PATCH 1/1] thermal: Exynos: Deletion of unnecessary checks before two function calls

Quoted 21 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 11:06:33 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/thermal/samsung/exynos_thermal_common.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +0 -0
index 3f5ad25..1cbb9d0 100644
@@ -417,12 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;

drivers/thermal/samsung/exynos_thermal_common.c void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) · line 424

Quoted 10 lines
drivers/thermal/samsung/exynos_thermal_common.c +2 -4
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}

Now you have unnecessary {}

julia

Quoted 6 lines
drivers/thermal/samsung/exynos_thermal_common.c +0 -1
 	dev_info(sensor_conf->dev,
--

2.1.3

#425 lore raw

Re: thermal: Exynos: Deletion of unnecessary checks before two function calls

Quoted 7 lines

drivers/thermal/samsung/exynos_thermal_common.c void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) · line 424

Quoted 5 lines
drivers/thermal/samsung/exynos_thermal_common.c +1 -2
 	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 	}

Now you have unnecessary {}

How are the chances that your source code transformation tool can also consider the deletion of curly brackets in such an use case?

Can any more pretty-printing rules be integrated from a specific coding style configuration?

Regards,
Markus

#426 lore raw

PATCH v2 1/1 thermal: Exynos: Deletion of unnecessary checks before two function calls

In reply to Julia Lawall

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 17:11:49 +0100

The functions cpufreq_cooling_unregister() and thermal_zone_device_unregister() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/thermal/samsung/exynos_thermal_common.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/thermal/samsung/exynos_thermal_common.c +3 -6
index 3f5ad25..b6be572 100644
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
 
 	th_zone = sensor_conf->pzone_data;
 
-	if (th_zone->therm_dev)
-		thermal_zone_device_unregister(th_zone->therm_dev);
+	thermal_zone_device_unregister(th_zone->therm_dev);
 
-	for (i = 0; i < th_zone->cool_dev_size; i++) {
-		if (th_zone->cool_dev[i])
-			cpufreq_cooling_unregister(th_zone->cool_dev[i]);
-	}
+	for (i = 0; i < th_zone->cool_dev_size; ++i)
+		cpufreq_cooling_unregister(th_zone->cool_dev[i]);
 
 	dev_info(sensor_conf->dev,
 		"Exynos: Kernel Thermal management unregistered\n");
Signature · 1 line
2.1.3
#427 lore raw

PATCH 1/1 thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 11:30:18 +0100

The ring_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/thunderbolt/ctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/thunderbolt/ctl.c +2 -4
index 799634b..55b9bdf 100644
@@ -520,10 +520,8 @@ err:
 void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
-	if (ctl->rx)
-		ring_free(ctl->rx);
-	if (ctl->tx)
-		ring_free(ctl->tx);
+	ring_free(ctl->rx);
+	ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
Signature · 1 line
2.1.3
maintainer
#428 lore raw

Re: [PATCH 1/1] thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Hi Markus,

ring_free does not check for null:
http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398

Maybe your software confuses the method with:
http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Andreas

Quoted 33 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 11:30:18 +0100

The ring_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/thunderbolt/ctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/thunderbolt/ctl.c +2 -5
index 799634b..55b9bdf 100644
@@ -520,10 +520,8 @@ err:
 void tb_ctl_free(struct tb_ctl *ctl)
 {
        int i;
-       if (ctl->rx)
-               ring_free(ctl->rx);
-       if (ctl->tx)
-               ring_free(ctl->tx);
+       ring_free(ctl->rx);
+       ring_free(ctl->tx);
 
        /* free RX packets */
        for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
--

2.1.3

#429 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 5 lines

ring_free does not check for null:
http://lxr.free-electrons.com/source/drivers/thunderbolt/nhi.c#L398

Maybe your software confuses the method with:
http://lxr.free-electrons.com/source/drivers/char/tpm/xen-tpmfront.c#L268

Thanks for your feedback.

I am sorry for a bit of confusion here.

1. Would it make sense that a variant for the thunderbolt ring_free() function will also perform input parameter validation?

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

Regards,
Markus

#430 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 2 lines · SF Markus Elfring

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to various ring_<foo> structs and functions.

Other miscellanea:

o typo/spelling fixes (releated/related, loose/lose)
o argument alignment
o comment formatting

---
Perhaps something like this?

unsigned/compiled/untested

 drivers/thunderbolt/ctl.c      |  41 ++++++-------
 drivers/thunderbolt/nhi.c      | 133 +++++++++++++++++++++--------------------
 drivers/thunderbolt/nhi.h      |  47 ++++++++-------
 drivers/thunderbolt/nhi_regs.h |  16 ++---
 4 files changed, 121 insertions(+), 116 deletions(-)
drivers/thunderbolt/ctl.c +21 -20
index 799634b..52783e0 100644
@@ -17,7 +17,7 @@
 struct ctl_pkg {
 	struct tb_ctl *ctl;
 	void *buffer;
-	struct ring_frame frame;
+	struct tb_ring_frame frame;
 };
 
 #define TB_CTL_RX_PKG_COUNT 10
@@ -319,8 +319,8 @@ static struct ctl_pkg *tb_ctl_pkg_alloc(struct tb_ctl *ctl)
 
 /* RX/TX handling */
 
-static void tb_ctl_tx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_tx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 	tb_ctl_pkg_free(pkg);
@@ -357,7 +357,7 @@ static int tb_ctl_tx(struct tb_ctl *ctl, void *data, size_t len,
 	cpu_to_be32_array(pkg->buffer, data, len / 4);
 	*(__be32 *) (pkg->buffer + len) = tb_crc(pkg->buffer, len);
 
-	res = ring_tx(ctl->tx, &pkg->frame);
+	res = tb_ring_tx(ctl->tx, &pkg->frame);
 	if (res) /* ring is stopped */
 		tb_ctl_pkg_free(pkg);
 	return res;
@@ -386,16 +386,16 @@ static void tb_ctl_handle_plug_event(struct tb_ctl *ctl,
 
 static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 {
-	ring_rx(pkg->ctl->rx, &pkg->frame); /*
-					     * We ignore failures during stop.
-					     * All rx packets are referenced
-					     * from ctl->rx_packets, so we do
-					     * not loose them.
-					     */
+	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
+	/*
+	 * We ignore failures during stop.
+	 * All rx packets are referenced from ctl->rx_packets,
+	 * so we do not lose them.
+	 */
 }
 
-static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
-			       bool canceled)
+static void tb_ctl_rx_callback(struct tb_ring *ring,
+			       struct tb_ring_frame *frame, bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
 
@@ -488,11 +488,11 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, hotplug_cb cb, void *cb_data)
 	if (!ctl->frame_pool)
 		goto err;
 
-	ctl->tx = ring_alloc_tx(nhi, 0, 10);
+	ctl->tx = tb_ring_alloc_tx(nhi, 0, 10);
 	if (!ctl->tx)
 		goto err;
 
-	ctl->rx = ring_alloc_rx(nhi, 0, 10);
+	ctl->rx = tb_ring_alloc_rx(nhi, 0, 10);
 	if (!ctl->rx)
 		goto err;
 
@@ -521,9 +521,9 @@ void tb_ctl_free(struct tb_ctl *ctl)
 {
 	int i;
 	if (ctl->rx)
-		ring_free(ctl->rx);
+		tb_ring_free(ctl->rx);
 	if (ctl->tx)
-		ring_free(ctl->tx);
+		tb_ring_free(ctl->tx);
 
 	/* free RX packets */
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
@@ -542,8 +542,9 @@ void tb_ctl_start(struct tb_ctl *ctl)
 {
 	int i;
 	tb_ctl_info(ctl, "control channel starting...\n");
-	ring_start(ctl->tx); /* is used to ack hotplug packets, start first */
-	ring_start(ctl->rx);
+	/* is used to ack hotplug packets, start first */
+	tb_ring_start(ctl->tx);
+	tb_ring_start(ctl->rx);
 	for (i = 0; i < TB_CTL_RX_PKG_COUNT; i++)
 		tb_ctl_rx_submit(ctl->rx_packets[i]);
 }
@@ -558,8 +559,8 @@ void tb_ctl_start(struct tb_ctl *ctl)
  */
 void tb_ctl_stop(struct tb_ctl *ctl)
 {
-	ring_stop(ctl->rx);
-	ring_stop(ctl->tx);
+	tb_ring_stop(ctl->rx);
+	tb_ring_stop(ctl->tx);
 
 	if (!kfifo_is_empty(&ctl->response_fifo))
 		tb_ctl_WARN(ctl, "dangling response in response_fifo\n");
drivers/thunderbolt/nhi.c +68 -65

310 lines not on this page · raw message

drivers/thunderbolt/nhi.h +24 -23

98 lines not on this page · raw message

drivers/thunderbolt/nhi_regs.h +8 -8
index 86b996c..23b7059 100644
@@ -9,7 +9,7 @@
 
 #include <linux/types.h>
 
-enum ring_flags {
+enum tb_ring_flags {
 	RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
 	RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
 	RING_FLAG_PCI_NO_SNOOP = 1 << 29,
@@ -17,7 +17,7 @@ enum ring_flags {
 	RING_FLAG_ENABLE = 1 << 31,
 };
 
-enum ring_desc_flags {
+enum tb_ring_desc_flags {
 	RING_DESC_ISOCH = 0x1, /* TX only? */
 	RING_DESC_COMPLETED = 0x2, /* set by NHI */
 	RING_DESC_POSTED = 0x4, /* always set this */
@@ -25,17 +25,17 @@ enum ring_desc_flags {
 };
 
 /**
- * struct ring_desc - TX/RX ring entry
+ * struct tb_ring_desc - TX/RX ring entry
  *
  * For TX set length/eof/sof.
  * For RX length/eof/sof are set by the NHI.
  */
-struct ring_desc {
+struct tb_ring_desc {
 	u64 phys;
 	u32 length:12;
 	u32 eof:4;
 	u32 sof:4;
-	enum ring_desc_flags flags:12;
+	enum tb_ring_desc_flags flags:12;
 	u32 time; /* write zero */
 } __packed;
 
@@ -43,7 +43,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring tail (set by NHI)
  * 10: ring head (index of first non posted descriptor)
  * 12: descriptor count
@@ -52,7 +52,7 @@ struct ring_desc {
 
 /*
  * 16 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: physical pointer to an array of struct ring_desc
+ * 00: physical pointer to an array of struct tb_ring_desc
  * 08: ring head (index of first not posted descriptor)
  * 10: ring tail (set by NHI)
  * 12: descriptor count
@@ -70,7 +70,7 @@ struct ring_desc {
 
 /*
  * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
- * 00: enum ring_flags
+ * 00: enum tb_ring_flags
  *     If RING_FLAG_E2E_FLOW_CONTROL is set then bits 13-23 must be set to
  *     the corresponding TX hop id.
  * 04: EOF/SOF mask (ignored for RING_FLAG_RAW rings)
#431 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 5 lines
Quoted 2 lines

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to various ring_<foo> structs and functions.

Do you imagine that any XEN software developers need also to reconsider this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#432 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 9 lines · SF Markus Elfring
Quoted 5 lines
Quoted 2 lines

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to various ring_<foo> structs and functions.

Do you imagine that any XEN software developers need also to reconsider this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#433 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 4 lines
Quoted 1 line

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.

I agree also that this implementation detail is correct in principle.

Is a renaming of such identifiers feasible so that the probability of other name clashes can be reduced and corresponding static source code analysis might become a bit easier?

How do you prefer to handle name space issues?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#434 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 10 lines · SF Markus Elfring
Quoted 4 lines
Quoted 1 line

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.

I agree also that this implementation detail is correct in principle.

Is a renaming of such identifiers feasible so that the probability of other name clashes can be reduced and corresponding static source code analysis might become a bit easier?

Why not just make the static source code analysis aware of the problem? You can treat static functions differently that non-static ones. There is no need to change the code.

julia
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#435 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 1 line

Why not just make the static source code analysis aware of the problem?

This is also possible, of course.

Quoted 1 line

You can treat static functions differently that non-static ones.

I have added this detail to my ideas around the next fine-tuning for the published semantic patch approach.

Quoted 1 line

There is no need to change the code.

Can name space prefixes help to make source code a bit safer eventually?

Regards,
Markus

#436 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 7 lines · SF Markus Elfring
Quoted 1 line

Why not just make the static source code analysis aware of the problem?

This is also possible, of course.

Quoted 1 line

You can treat static functions differently that non-static ones.

Quoted 7 lines

I have added this detail to my ideas around the next fine-tuning for the published semantic patch approach.

Quoted 1 line

There is no need to change the code.

Can name space prefixes help to make source code a bit safer eventually?

Not really.
Adding prefixes can make code unnecessarily more verbose though.

maintainer
#437 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

In reply to Joe Perches
Quoted 7 lines · Joe Perches
Quoted 6 lines · SF Markus Elfring
Quoted 5 lines
Quoted 2 lines

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to various ring_<foo> structs and functions.

Quoted 6 lines
Quoted 3 lines

Do you imagine that any XEN software developers need also to reconsider this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.

Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause conflicts? I was under the impression that those are module private. If they are indeed private then I would prefer to not rename them. --
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#438 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

Quoted 8 lines · Andreas Noever
Quoted 7 lines · Joe Perches
Quoted 6 lines · SF Markus Elfring
Quoted 5 lines
Quoted 2 lines

2. Are any additional prefixes appropriate so that further name space conflicts can be better avoided?

To avoid possible external naming conflicts, add tb_ prefix to various ring_<foo> structs and functions.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Do you imagine that any XEN software developers need also to reconsider this implementation detail?
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/char/tpm/xen-tpmfront.c?idü14f9c1272f62c3e8d01300f52467c0d9af50f9#n268

I think static functions can be named whatever
the developer chooses.

Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause conflicts?

If the symbol is not static, yes.

eg: the static uses of "debug" as a control
variable vs the non-static uses of <prefix>debug
when shared among multiple objects in a single
driver.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#439 lore raw

Re: thunderbolt: Deletion of unnecessary checks before the function call "ring_free"

In reply to Andreas Noever
Quoted 1 line

Do symbols which are not exported (no EXPORT_SYMBOL_(GPL)) cause conflicts?

How do you think about to mark more functions from your software module as static?

Quoted 2 lines

I was under the impression that those are module private. If they are indeed private then I would prefer to not rename them.

Would you like to help in avoiding difficulties around name space issues?

Will specific prefixes make understanding a bit easier?

Regards,
Markus

#440 lore raw

PATCH 1/1 tty-hvsi_lib: Deletion of an unnecessary check before the function call "tty_kref_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 12:40:32 +0100

The tty_kref_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/tty/hvc/hvsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/hvc/hvsi_lib.c +1 -2
index 7ae6c29..a270f04 100644
@@ -405,8 +405,7 @@ void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp)
 		hvsi_send_close(pv);
 	}
 
-	if (pv->tty)
-		tty_kref_put(pv->tty);
+	tty_kref_put(pv->tty);
 	pv->tty = NULL;
 }
 
Signature · 1 line
2.1.3
#441 lore raw

PATCH 1/1 tty: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 13:42:29 +0100

The functions put_device() and tty_kref_put() test whether their argument is NULL and then return immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/tty/tty_io.c   | 6 ++----
 drivers/tty/tty_port.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/tty/tty_io.c +2 -4
index 848c17a..3302789 100644
@@ -169,8 +169,7 @@ void free_tty_struct(struct tty_struct *tty)
 {
 	if (!tty)
 		return;
-	if (tty->dev)
-		put_device(tty->dev);
+	put_device(tty->dev);
 	kfree(tty->write_buf);
 	tty->magic = 0xDEADDEAD;
 	kfree(tty);
@@ -1612,8 +1611,7 @@ static void release_tty(struct tty_struct *tty, int idx)
 		tty->link->port->itty = NULL;
 	cancel_work_sync(&tty->port->buf.work);
 
-	if (tty->link)
-		tty_kref_put(tty->link);
+	tty_kref_put(tty->link);
 	tty_kref_put(tty);
 }
 
drivers/tty/tty_port.c +1 -2
index 1b93357..856c064 100644
@@ -193,8 +193,7 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&port->lock, flags);
-	if (port->tty)
-		tty_kref_put(port->tty);
+	tty_kref_put(port->tty);
 	port->tty = tty_kref_get(tty);
 	spin_unlock_irqrestore(&port->lock, flags);
 }
Signature · 1 line
2.1.3
#442 lore raw

PATCH 1/1 USB: gadget: function: Deletion of an unnecessary check before the function call "rndis_add_hdr"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 14:51:43 +0100

The rndis_add_hdr() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/gadget/function/f_rndis.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/function/f_rndis.c +1 -2
index ddb09dc..da56a5f 100644
@@ -375,8 +375,7 @@ static struct sk_buff *rndis_add_header(struct gether *port,
 	struct sk_buff *skb2;
 
 	skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
-	if (skb2)
-		rndis_add_hdr(skb2);
+	rndis_add_hdr(skb2);
 
 	dev_kfree_skb(skb);
 	return skb2;
Signature · 1 line
2.1.3
#443 lore raw

PATCH 1/1 USB: PCI-quirks: Deletion of unnecessary checks before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 15:20:12 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/host/pci-quirks.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/host/pci-quirks.c +4 -8
index 2f3aceb..dd483c1 100644
@@ -233,10 +233,8 @@ commit:
 
 		spin_unlock_irqrestore(&amd_lock, flags);
 
-		if (info.nb_dev)
-			pci_dev_put(info.nb_dev);
-		if (info.smbus_dev)
-			pci_dev_put(info.smbus_dev);
+		pci_dev_put(info.nb_dev);
+		pci_dev_put(info.smbus_dev);
 
 	} else {
 		/* no race - commit the result */
@@ -447,10 +445,8 @@ void usb_amd_dev_put(void)
 
 	spin_unlock_irqrestore(&amd_lock, flags);
 
-	if (nb)
-		pci_dev_put(nb);
-	if (smbus)
-		pci_dev_put(smbus);
+	pci_dev_put(nb);
+	pci_dev_put(smbus);
 }
 EXPORT_SYMBOL_GPL(usb_amd_dev_put);
 
Signature · 1 line
2.1.3
#444 lore raw

PATCH 1/1 USB-SIS: Deletion of an unnecessary check before the function call "usb_put_dev"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 15:50:44 +0100

The usb_put_dev() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/misc/sisusbvga/sisusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/misc/sisusbvga/sisusb.c +1 -2
index 633caf6..022dc00 100644
@@ -2472,8 +2472,7 @@ sisusb_delete(struct kref *kref)
 	if (!sisusb)
 		return;
 
-	if (sisusb->sisusb_dev)
-		usb_put_dev(sisusb->sisusb_dev);
+	usb_put_dev(sisusb->sisusb_dev);
 
 	sisusb->sisusb_dev = NULL;
 	sisusb_free_buffers(sisusb);
Signature · 1 line
2.1.3
#445 lore raw

PATCH 1/1 USB: serial: Deletion of an unnecessary check before the function call "release_firmware"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 16:15:34 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/mxuport.c +1 -2
index ab1d690..3653ec1 100644
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);
 	return err;
 }
 
Signature · 1 line
2.1.3
#446 lore raw

Re: [PATCH 1/1] USB: serial: Deletion of an unnecessary check before the function call "release_firmware"

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 16:15:34 +0100

The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/serial/mxuport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/serial/mxuport.c +0 -0
index ab1d690..3653ec1 100644

drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1104

Quoted 6 lines
drivers/usb/serial/mxuport.c +1 -2
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);

I think that the if should stay. There were two cases on the allocation, so there should be two cases on the release.

julia

Quoted 11 lines
drivers/usb/serial/mxuport.c +0 -1
 	return err;
 }
 
--

2.1.3

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#447 lore raw

Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"

Quoted 5 lines
Quoted 5 lines
drivers/usb/serial/mxuport.c +0 -0
index ab1d690..3653ec1 100644
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
Quoted 8 lines

drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1104

Quoted 6 lines
drivers/usb/serial/mxuport.c +1 -2
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);

I think that the if should stay.

I have got an other opinion.

Quoted 2 lines

There were two cases on the allocation, so there should be two cases on the release.

I find that this implementation detail does not really matter for the necessity of a null pointer check directly before such a function call.

Regards,
Markus

#448 lore raw

Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"

Quoted 14 lines · SF Markus Elfring
Quoted 5 lines
Quoted 5 lines
drivers/usb/serial/mxuport.c +0 -0
index ab1d690..3653ec1 100644
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
Quoted 8 lines

drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1104

Quoted 6 lines
drivers/usb/serial/mxuport.c +1 -2
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);

I think that the if should stay.

Quoted 8 lines

I have got an other opinion.

Quoted 2 lines

There were two cases on the allocation, so there should be two cases on the release.

I find that this implementation detail does not really matter for the necessity of a null pointer check directly before such a function call.

Conceptually, if it is clear 10 lines above that nothing was allocated, and there is a fallback to existing data (according to the comment above) it is strange to be releasing something.

julia

maintainer
#449 lore raw

Re: USB: serial: Deletion of an unnecessary check before the function call "release_firmware"

Quoted 22 lines · Julia Lawall
Quoted 20 lines · SF Markus Elfring
Quoted 5 lines
Quoted 5 lines
drivers/usb/serial/mxuport.c +0 -0
index ab1d690..3653ec1 100644
@@ -1101,8 +1101,7 @@ static int mxuport_probe(struct usb_serial *serial,
Quoted 8 lines

drivers/usb/serial/mxuport.c static int mxuport_probe(struct usb_serial *serial, · line 1104

Quoted 6 lines
drivers/usb/serial/mxuport.c +1 -2
 	 */
 	usb_set_serial_data(serial, (void *)id->driver_info);
 out:
-	if (fw_p)
-		release_firmware(fw_p);
+	release_firmware(fw_p);

I think that the if should stay.

I have got an other opinion.

Quoted 2 lines

There were two cases on the allocation, so there should be two cases on the release.

Quoted 6 lines
Quoted 2 lines

I find that this implementation detail does not really matter for the necessity of a null pointer check directly before such a function call.

Conceptually, if it is clear 10 lines above that nothing was allocated, and there is a fallback to existing data (according to the comment above) it is strange to be releasing something.

I agree with Julia here and will not apply this one.

Thanks,
Johan

#450 lore raw

PATCH 1/1 USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 16:33:18 +0100

The usb_put_dev() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/usbip/vhci_hcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/usbip/vhci_hcd.c +3 -6
index c02374b..cc1b03e 100644
@@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 			dev_info(dev, "SetAddress Request (%d) to port %d\n",
 				 ctrlreq->wValue, vdev->rhport);
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 
 			spin_lock(&vdev->ud.lock);
@@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 				usbip_dbg_vhci_hc(
 					"Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
-			if (vdev->udev)
-				usb_put_dev(vdev->udev);
+			usb_put_dev(vdev->udev);
 			vdev->udev = usb_get_dev(urb->dev);
 			goto out;
 
@@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
 	vdev->speed  = 0;
 	vdev->devid  = 0;
 
-	if (vdev->udev)
-		usb_put_dev(vdev->udev);
+	usb_put_dev(vdev->udev);
 	vdev->udev = NULL;
 
 	if (ud->tcp_socket) {
Signature · 1 line
2.1.3
maintainer Acked-by on v1 1/1
#451 lore raw

Re: [PATCH 1/1] USB-IP: Deletion of unnecessary checks before the function call "usb_put_dev"

Quoted 48 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 16:33:18 +0100

The usb_put_dev() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/usb/usbip/vhci_hcd.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/usbip/vhci_hcd.c +3 -7
index c02374b..cc1b03e 100644
@@ -518,8 +518,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                        dev_info(dev, "SetAddress Request (%d) to port %d\n",
                                 ctrlreq->wValue, vdev->rhport);
 
-                       if (vdev->udev)
-                               usb_put_dev(vdev->udev);
+                       usb_put_dev(vdev->udev);
                        vdev->udev = usb_get_dev(urb->dev);
 
                        spin_lock(&vdev->ud.lock);
@@ -539,8 +538,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                                usbip_dbg_vhci_hc(
                                        "Not yet?:Get_Descriptor to device 0 (get max pipe size)\n");
 
-                       if (vdev->udev)
-                               usb_put_dev(vdev->udev);
+                       usb_put_dev(vdev->udev);
                        vdev->udev = usb_get_dev(urb->dev);
                        goto out;
 
@@ -831,8 +829,7 @@ static void vhci_device_reset(struct usbip_device *ud)
        vdev->speed  = 0;
        vdev->devid  = 0;
 
-       if (vdev->udev)
-               usb_put_dev(vdev->udev);
+       usb_put_dev(vdev->udev);
        vdev->udev = NULL;
 
        if (ud->tcp_socket) {
--
Quoted 2 lines

2.1.3

#452 lore raw

PATCH 1/1 ALSA: core: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 18:34:48 +0100

The functions snd_seq_oss_timer_delete() and vunmap() perform also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/core/seq/oss/seq_oss_init.c | 9 +++------
 sound/core/sgbuf.c                | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)
sound/core/seq/oss/seq_oss_init.c +3 -6
index b9184d2..b0e32e1 100644
@@ -403,14 +403,11 @@ free_devinfo(void *private)
 {
 	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
 
-	if (dp->timer)
-		snd_seq_oss_timer_delete(dp->timer);
+	snd_seq_oss_timer_delete(dp->timer);
 		
-	if (dp->writeq)
-		snd_seq_oss_writeq_delete(dp->writeq);
+	snd_seq_oss_writeq_delete(dp->writeq);
 
-	if (dp->readq)
-		snd_seq_oss_readq_delete(dp->readq);
+	snd_seq_oss_readq_delete(dp->readq);
 	
 	kfree(dp);
 }
sound/core/sgbuf.c +1 -2
index 0a41850..84fffab 100644
@@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
 	if (! sgbuf)
 		return -EINVAL;
 
-	if (dmab->area)
-		vunmap(dmab->area);
+	vunmap(dmab->area);
 	dmab->area = NULL;
 
 	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
Signature · 1 line
2.1.3
Applied
#453 lore raw

Re: [PATCH 1/1] ALSA: core: Deletion of unnecessary checks before two function calls

At Fri, 21 Nov 2014 18:40:49 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 18:34:48 +0100

The functions snd_seq_oss_timer_delete() and vunmap() perform also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 44 lines
---
 sound/core/seq/oss/seq_oss_init.c | 9 +++------
 sound/core/sgbuf.c                | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)
sound/core/seq/oss/seq_oss_init.c +3 -6
index b9184d2..b0e32e1 100644
@@ -403,14 +403,11 @@ free_devinfo(void *private)
 {
 	struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private;
 
-	if (dp->timer)
-		snd_seq_oss_timer_delete(dp->timer);
+	snd_seq_oss_timer_delete(dp->timer);
 
-	if (dp->writeq)
-		snd_seq_oss_writeq_delete(dp->writeq);
+	snd_seq_oss_writeq_delete(dp->writeq);
 
-	if (dp->readq)
-		snd_seq_oss_readq_delete(dp->readq);
+	snd_seq_oss_readq_delete(dp->readq);
 
 	kfree(dp);
 }
sound/core/sgbuf.c +1 -2
index 0a41850..84fffab 100644
@@ -39,8 +39,7 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
 	if (! sgbuf)
 		return -EINVAL;
 
-	if (dmab->area)
-		vunmap(dmab->area);
+	vunmap(dmab->area);
 	dmab->area = NULL;
 
 	tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
Signature · 1 line
2.1.3
#454 lore raw

PATCH 1/1 ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 19:05:50 +0100

The release_and_free_resource() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/isa/es1688/es1688_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/isa/es1688/es1688_lib.c +1 -2
index b3b4f15..fb259491 100644
@@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
 {
 	if (chip->hardware != ES1688_HW_UNDEF)
 		snd_es1688_init(chip, 0);
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 	if (chip->dma8 >= 0) {
Signature · 1 line
2.1.3
Applied
#455 lore raw

Re: [PATCH 1/1] ALSA: es1688_lib: Deletion of an unnecessary check before the function call "release_and_free_resource"

At Fri, 21 Nov 2014 19:11:47 +0100,

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 19:05:50 +0100

The release_and_free_resource() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 21 lines
---
 sound/isa/es1688/es1688_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/isa/es1688/es1688_lib.c +1 -2
index b3b4f15..fb259491 100644
@@ -614,8 +614,7 @@ static int snd_es1688_free(struct snd_es1688 *chip)
 {
 	if (chip->hardware != ES1688_HW_UNDEF)
 		snd_es1688_init(chip, 0);
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 	if (chip->dma8 >= 0) {
Signature · 1 line
2.1.3
#456 lore raw

PATCH 1/1 ALSA: sb: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 19:32:02 +0100

The functions release_and_free_resource() and snd_util_memhdr_free() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 sound/isa/sb/emu8000_synth.c | 3 +--
 sound/isa/sb/sb_common.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
sound/isa/sb/emu8000_synth.c +1 -2
index 4e3fcfb..95b39be 100644
@@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
 		snd_device_free(dev->card, hw->pcm);
 	if (hw->emu)
 		snd_emux_free(hw->emu);
-	if (hw->memhdr)
-		snd_util_memhdr_free(hw->memhdr);
+	snd_util_memhdr_free(hw->memhdr);
 	hw->emu = NULL;
 	hw->memhdr = NULL;
 	return 0;
sound/isa/sb/sb_common.c +1 -2
index 3ef9906..f22b448 100644
@@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
 
 static int snd_sbdsp_free(struct snd_sb *chip)
 {
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
Signature · 1 line
2.1.3
Applied
#457 lore raw

Re: [PATCH 1/1] ALSA: sb: Deletion of unnecessary checks before two function calls

At Fri, 21 Nov 2014 19:35:18 +0100,

Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 19:32:02 +0100

The functions release_and_free_resource() and snd_util_memhdr_free() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi

Quoted 36 lines
---
 sound/isa/sb/emu8000_synth.c | 3 +--
 sound/isa/sb/sb_common.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
sound/isa/sb/emu8000_synth.c +1 -2
index 4e3fcfb..95b39be 100644
@@ -105,8 +105,7 @@ static int snd_emu8000_delete_device(struct snd_seq_device *dev)
 		snd_device_free(dev->card, hw->pcm);
 	if (hw->emu)
 		snd_emux_free(hw->emu);
-	if (hw->memhdr)
-		snd_util_memhdr_free(hw->memhdr);
+	snd_util_memhdr_free(hw->memhdr);
 	hw->emu = NULL;
 	hw->memhdr = NULL;
 	return 0;
sound/isa/sb/sb_common.c +1 -2
index 3ef9906..f22b448 100644
@@ -184,8 +184,7 @@ static int snd_sbdsp_probe(struct snd_sb * chip)
 
 static int snd_sbdsp_free(struct snd_sb *chip)
 {
-	if (chip->res_port)
-		release_and_free_resource(chip->res_port);
+	release_and_free_resource(chip->res_port);
 	if (chip->irq >= 0)
 		free_irq(chip->irq, (void *) chip);
 #ifdef CONFIG_ISA
Signature · 1 line
2.1.3
#458 lore raw

PATCH 1/1 IDE: Deletion of an unnecessary check before the function call "module_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 20:22:32 +0100

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/ide/ide.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ide/ide.c +1 -2
index 2ce6268..e29b02c 100644
@@ -101,8 +101,7 @@ void ide_device_put(ide_drive_t *drive)
 	struct device *host_dev = drive->hwif->host->dev[0];
 	struct module *module = host_dev ? host_dev->driver->owner : NULL;
 
-	if (module)
-		module_put(module);
+	module_put(module);
 #endif
 	put_device(&drive->gendev);
 }
Signature · 1 line
2.1.3
maintainer Applied
#459 lore raw

Re: [PATCH 1/1] IDE: Deletion of an unnecessary check before the function call "module_put"

From: SF Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 20:26:29 +0100

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 20:22:32 +0100

The module_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Applied.

#460 lore raw

PATCH 1/1 Deletion of unnecessary checks before the function call "unw_remove_unwind_table"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 21 Nov 2014 23:57:28 +0100

The unw_remove_unwind_table() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/ia64/kernel/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/ia64/kernel/module.c +2 -4
index 24603be..30ff27d 100644
@@ -946,8 +946,6 @@ module_finalize (const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, struct module *mo
 void
 module_arch_cleanup (struct module *mod)
 {
-	if (mod->arch.init_unw_table)
-		unw_remove_unwind_table(mod->arch.init_unw_table);
-	if (mod->arch.core_unw_table)
-		unw_remove_unwind_table(mod->arch.core_unw_table);
+	unw_remove_unwind_table(mod->arch.init_unw_table);
+	unw_remove_unwind_table(mod->arch.core_unw_table);
 }
Signature · 1 line
2.1.3
#461 lore raw

Re: [PATCH 1/1] [IA64] Deletion of unnecessary checks before the function call "unw_remove_unwind_table"

This one is buggy.

regards,
dan carpenter

#462 lore raw

PATCH 1/1 ARM: OMAP2: Deletion of unnecessary checks before three function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 10:50:33 +0100

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 3 +--
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
index d22c30d..5108859 100644
@@ -199,8 +199,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
arch/arm/mach-omap2/omap_hwmod.c +1 -2
index 9e91a4e..e2406c4 100644
@@ -917,8 +917,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
 
-	if (oh->_clk)
-		clk_disable(oh->_clk);
+	clk_disable(oh->_clk);
 
 	p = oh->slave_ports.next;
 
arch/arm/mach-omap2/timer.c +1 -2
index 43d03fb..5b428a0 100644
@@ -205,8 +205,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
Signature · 1 line
2.1.3
#463 lore raw

PATCH 1/1 ARM: OMAP2: Delete unnecessary checks before three function calls

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
index 4cb8fd9..196366e 100644
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
arch/arm/mach-omap2/omap_hwmod.c +1 -4
index d78c12e..1091ee7 100644
@@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 	int i = 0;
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
-
-	if (oh->_clk)
-		clk_disable(oh->_clk);
-
+	clk_disable(oh->_clk);
 	p = oh->slave_ports.next;
 
 	while (i < oh->slaves_cnt) {
arch/arm/mach-omap2/timer.c +1 -2
index cac46d8..15448221 100644
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
Signature · 1 line
2.4.5
maintainer
#464 lore raw

Re: [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls

Hello Markus

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks for the patch. I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in. So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed.

So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed. Then I would feel a bit more comfortable applying the omap_device.c and omap_hwmod.c changes.

The kerneldoc for of_node_put() does explicitly allow NULLs to be passed in. So I'll apply that change now for v4.3, touching up the commit message accordingly.

regards,

- Paul

Quoted 53 lines
---
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
 arch/arm/mach-omap2/timer.c       | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)
arch/arm/mach-omap2/omap_device.c +1 -2
index 4cb8fd9..196366e 100644
@@ -193,8 +193,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
-		if (pdev->archdata.od)
-			omap_device_delete(pdev->archdata.od);
+		omap_device_delete(pdev->archdata.od);
 		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
arch/arm/mach-omap2/omap_hwmod.c +1 -4
index d78c12e..1091ee7 100644
@@ -921,10 +921,7 @@ static int _disable_clocks(struct omap_hwmod *oh)
 	int i = 0;
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
-
-	if (oh->_clk)
-		clk_disable(oh->_clk);
-
+	clk_disable(oh->_clk);
 	p = oh->slave_ports.next;
 
 	while (i < oh->slaves_cnt) {
arch/arm/mach-omap2/timer.c +1 -2
index cac46d8..15448221 100644
@@ -208,8 +208,7 @@ static void __init omap_dmtimer_init(void)
 	/* If we are a secure device, remove any secure timer nodes */
 	if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
 		np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
-		if (np)
-			of_node_put(np);
+		of_node_put(np);
 	}
 }
 
Signature · 1 line
2.4.5

- Paul

maintainer
#465 lore raw

Re: [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls

Quoted 22 lines · Paul Walmsley

Hello Markus

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks for the patch. I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in. So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed.

Quoted 8 lines

So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed. Then I would feel a bit more comfortable applying the omap_device.c and omap_hwmod.c changes.

The kerneldoc for of_node_put() does explicitly allow NULLs to be passed in. So I'll apply that change now for v4.3, touching up the commit message accordingly.

I have them applied from a later thread already, but will drop both in my branch as I have not pushed them out yet.

Regards,

Tony

maintainer
#466 lore raw

Re: [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls

Quoted 28 lines · Tony Lindgren
Quoted 27 lines · Paul Walmsley

Hello Markus

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks for the patch. I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in. So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed.

So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed. Then I would feel a bit more comfortable applying the omap_device.c and omap_hwmod.c changes.

Quoted 6 lines
Quoted 3 lines

The kerneldoc for of_node_put() does explicitly allow NULLs to be passed in. So I'll apply that change now for v4.3, touching up the commit message accordingly.

I have them applied from a later thread already, but will drop both in my branch as I have not pushed them out yet.

Oops sorry about stepping on your toes - I obviously missed that followup.

- Paul

maintainer
#467 lore raw

Re: [PATCH] ARM: OMAP2: Delete unnecessary checks before three function calls

Quoted 30 lines · Paul Walmsley
Quoted 28 lines · Tony Lindgren
Quoted 27 lines · Paul Walmsley

Hello Markus

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 30 Jun 2015 14:00:16 +0200

The functions clk_disable(), of_node_put() and omap_device_delete() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Thanks for the patch. I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in. So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed.

So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed. Then I would feel a bit more comfortable applying the omap_device.c and omap_hwmod.c changes.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

The kerneldoc for of_node_put() does explicitly allow NULLs to be passed in. So I'll apply that change now for v4.3, touching up the commit message accordingly.

I have them applied from a later thread already, but will drop both in my branch as I have not pushed them out yet.

Oops sorry about stepping on your toes - I obviously missed that followup.

No problem :)

Tony

#468 lore raw

Re: ARM: OMAP2: Delete unnecessary checks before three function calls

In reply to Paul Walmsley
Quoted 4 lines

I have to say, I am a bit leery about applying the omap_device.c and omap_hwmod.c changes, since the called functions -- omap_device_delete() and clk_disable() -- don't explicitly document that NULLs are allowed to be passed in.

How are the chances to improve documentation around such implementation details?

Quoted 2 lines

So there's no explicit contract that callers can rely upon, to (at least in theory) prevent those internal NULL pointer checks from being removed.

Are there any additional variations to consider for source files from different processor architectures?

Quoted 2 lines

So I would suggest that those two functions' kerneldoc be patched first to explicitly state that passing in a NULL pointer is allowed.

Should my static source code analysis approach help you any more to clarify further open issues?

Quoted 1 line

So I'll apply that change now for v4.3, touching up the commit message accordingly.

Thanks for your constructive feedback.

Quoted 3 lines
Quoted 3 lines
 arch/arm/mach-omap2/omap_device.c | 3 +--
 arch/arm/mach-omap2/omap_hwmod.c  | 5 +----
 arch/arm/mach-omap2/timer.c       | 3 +--

Did Tony Lindgren pick a similar update suggestion up, too?
https://lkml.org/lkml/2015/7/15/112

Regards,
Markus

#469 lore raw

PATCH 1/1 ARM-kernel: Deletion of unnecessary checks before two function calls

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 11:33:16 +0100

The functions smp_set_ops() and unwind_table_del() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/arm/kernel/module.c | 3 +--
 arch/arm/kernel/setup.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
arch/arm/kernel/module.c +1 -2
index 6a4dffe..3dffad1 100644
@@ -350,7 +350,6 @@ module_arch_cleanup(struct module *mod)
 	int i;
 
 	for (i = 0; i < ARM_SEC_MAX; i++)
-		if (mod->arch.unwind[i])
-			unwind_table_del(mod->arch.unwind[i]);
+		unwind_table_del(mod->arch.unwind[i]);
 #endif
 }
arch/arm/kernel/setup.c +1 -1
index 84db893d..a7018a2 100644
@@ -929,7 +929,7 @@ void __init setup_arch(char **cmdline_p)
 		if (!mdesc->smp_init || !mdesc->smp_init()) {
 			if (psci_smp_available())
 				smp_set_ops(&psci_smp_ops);
-			else if (mdesc->smp)
+			else
 				smp_set_ops(mdesc->smp);
 		}
 		smp_init_cpus();
Signature · 1 line
2.1.3
#470 lore raw

PATCH 1/1 x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/pci-calgary_64.c +1 -2
index 0497f71..d22a386 100644
@@ -1476,8 +1476,7 @@ cleanup:
 	for (--bus; bus >= 0; --bus) {
 		struct calgary_bus_info *info = &bus_info[bus];
 
-		if (info->tce_space)
-			free_tce_table(info->tce_space);
+		free_tce_table(info->tce_space);
 	}
 	return -ENOMEM;
 }
Signature · 1 line
2.1.3
Acked-by on v1 1/1
#471 lore raw

Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Looks good to me

Quoted 21 lines
---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/pci-calgary_64.c +1 -3
index 0497f71..d22a386 100644
@@ -1476,8 +1476,7 @@ cleanup:
        for (--bus; bus >= 0; --bus) {
                struct calgary_bus_info *info = &bus_info[bus];
 
-               if (info->tce_space)
-                       free_tce_table(info->tce_space);
+               free_tce_table(info->tce_space);
        }
        return -ENOMEM;
 }
--

2.1.3

#472 lore raw

Re: [PATCH 1/1] x86: PCI-Calgary: Deletion of an unnecessary check before the function call "free_tce_table"

Quoted 27 lines
Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 12:55:28 +0100

The free_tce_table() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Looks good to me

Quoted 12 lines
---
 arch/x86/kernel/pci-calgary_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/pci-calgary_64.c +0 -0
index 0497f71..d22a386 100644
@@ -1476,8 +1476,7 @@ cleanup:
        for (--bus; bus >= 0; --bus) {
                struct calgary_bus_info *info = &bus_info[bus];
 
Quoted 9 lines
Quoted 9 lines
arch/x86/kernel/pci-calgary_64.c +1 -3
-               if (info->tce_space)
-                       free_tce_table(info->tce_space);
+               free_tce_table(info->tce_space);
        }
        return -ENOMEM;
 }
--

2.1.3

Do the chances increase to integrate this update suggestion into another source code repository?

Regards,
Markus

#473 lore raw

PATCH 1/1 x86: AMD-perf_event: Deletion of unnecessary checks before the function call "free_percpu"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 14:01:27 +0100

The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_event_amd_uncore.c +2 -4
index 30790d7..4856232 100644
@@ -592,11 +592,9 @@ fail_online:
 fail_l2:
 	if (cpu_has_perfctr_nb)
 		perf_pmu_unregister(&amd_nb_pmu);
-	if (amd_uncore_l2)
-		free_percpu(amd_uncore_l2);
+	free_percpu(amd_uncore_l2);
 fail_nb:
-	if (amd_uncore_nb)
-		free_percpu(amd_uncore_nb);
+	free_percpu(amd_uncore_nb);
 
 fail_nodev:
 	return ret;
Signature · 1 line
2.1.3
#474 lore raw

PATCH 1/1 x86: AMD-perf_event: Delete unnecessary checks before the function call "free_percpu"

From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 09:00:20 +0100

The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_event_amd_uncore.c +2 -4
index cc6cedb..240ecee 100644
@@ -588,11 +588,9 @@ fail_online:
 fail_l2:
 	if (cpu_has_perfctr_nb)
 		perf_pmu_unregister(&amd_nb_pmu);
-	if (amd_uncore_l2)
-		free_percpu(amd_uncore_l2);
+	free_percpu(amd_uncore_l2);
 fail_nb:
-	if (amd_uncore_nb)
-		free_percpu(amd_uncore_nb);
+	free_percpu(amd_uncore_nb);
 
 fail_nodev:
 	return ret;
Signature · 1 line
2.6.2
maintainer
#475 lore raw

Re: [PATCH] x86: AMD-perf_event: Delete unnecessary checks before the function call "free_percpu"

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 09:00:20 +0100

The free_percpu() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/x86/kernel/cpu/perf_event_amd_uncore.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/perf_event_amd_uncore.c +0 -0
index cc6cedb..240ecee 100644

arch/x86/kernel/cpu/perf_event_amd_uncore.c fail_online: · line 593

Quoted 10 lines
arch/x86/kernel/cpu/perf_event_amd_uncore.c +2 -4
@@ -588,11 +588,9 @@ fail_online:
 fail_l2:
 	if (cpu_has_perfctr_nb)
 		perf_pmu_unregister(&amd_nb_pmu);
-	if (amd_uncore_l2)
-		free_percpu(amd_uncore_l2);
+	free_percpu(amd_uncore_l2);
 fail_nb:
-	if (amd_uncore_nb)
-		free_percpu(amd_uncore_nb);
+	free_percpu(amd_uncore_nb);

So I'm really in two minds about such patches; yes its correct. But at the same time; this isn't a performance critical piece of code and the additional condition isn't hurting anything.

Furthermore, I find the explicit test conceptually easier than remembering that kfree() works this way (while many other resource freeing functions do not).

And in error paths -- which aren't our best code by far -- obvious safe is far preferred to clever.

Ingo, preference?

#476 lore raw

PATCH 1/1 s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 15:00:55 +0100

The debug_unregister() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/s390/pci/pci_debug.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/s390/pci/pci_debug.c +2 -4
index eec598c..18403a7 100644
@@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
 
 void zpci_debug_exit(void)
 {
-	if (pci_debug_msg_id)
-		debug_unregister(pci_debug_msg_id);
-	if (pci_debug_err_id)
-		debug_unregister(pci_debug_err_id);
+	debug_unregister(pci_debug_msg_id);
+	debug_unregister(pci_debug_err_id);
 
 	debugfs_remove(debugfs_root);
 }
Signature · 1 line
2.1.3
#477 lore raw

Re: [PATCH 1/1] s390/pci: Deletion of unnecessary checks before the function call "debug_unregister"

Quoted 20 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 15:00:55 +0100

The debug_unregister() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/s390/pci/pci_debug.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/s390/pci/pci_debug.c +0 -0
index eec598c..18403a7 100644
@@ -158,10 +158,8 @@ int __init zpci_debug_init(void)
 
 void zpci_debug_exit(void)

arch/s390/pci/pci_debug.c int __init zpci_debug_init(void) · line 165

Quoted 10 lines
arch/s390/pci/pci_debug.c +2 -4
 {
-	if (pci_debug_msg_id)
-		debug_unregister(pci_debug_msg_id);
-	if (pci_debug_err_id)
-		debug_unregister(pci_debug_err_id);
+	debug_unregister(pci_debug_msg_id);
+	debug_unregister(pci_debug_err_id);
 
 	debugfs_remove(debugfs_root);
 }

Applied.

Thanks,
Sebastian

#478 lore raw

PATCH 1/1 PowerPC-83xx: Deletion of an unnecessary check before the function call "of_node_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 16:18:20 +0100

The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 arch/powerpc/platforms/83xx/usb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/83xx/usb.c +1 -2
index 1ad748b..5c31d82 100644
@@ -162,8 +162,7 @@ int mpc831x_usb_cfg(void)
 
 	iounmap(immap);
 
-	if (immr_node)
-		of_node_put(immr_node);
+	of_node_put(immr_node);
 
 	/* Map USB SOC space */
 	ret = of_address_to_resource(np, 0, &res);
Signature · 1 line
2.1.3
#479 lore raw

PATCH 1/1 video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 16:51:31 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/sh_mobile_lcdcfb.c +1 -2
index 2bcc84a..cfde21d 100644
@@ -2181,8 +2181,7 @@ sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch)
 	if (!info || !info->device)
 		return;
 
-	if (ch->sglist)
-		vfree(ch->sglist);
+	vfree(ch->sglist);
 
 	fb_dealloc_cmap(&info->cmap);
 	framebuffer_release(info);
Signature · 1 line
2.1.3
#480 lore raw

Re: [PATCH 1/1] video: fbdev-LCDC: Deletion of an unnecessary check before the function call "vfree"

Hi,

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 22 Nov 2014 16:51:31 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/sh_mobile_lcdcfb.c +0 -0
index 2bcc84a..cfde21d 100644

drivers/video/fbdev/sh_mobile_lcdcfb.c sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch) · line 2187

Quoted 9 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +1 -2
@@ -2181,8 +2181,7 @@ sh_mobile_lcdc_channel_fb_cleanup(struct sh_mobile_lcdc_chan *ch)
 	if (!info || !info->device)
 		return;
 
-	if (ch->sglist)
-		vfree(ch->sglist);
+	vfree(ch->sglist);
 
 	fb_dealloc_cmap(&info->cmap);
 	framebuffer_release(info);

Thanks, I've applied the fbdev patches. Next time, please use git-format-patch and git-send-email to send a proper patch series.

Tomi

#481 lore raw

PATCH 1/1 video: uvesafb: Deletion of an unnecessary check before the function call "uvesafb_free"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 11:00:26 +0100

The uvesafb_free() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/uvesafb.c +1 -2
index 509d452..f718627 100644
@@ -1219,8 +1219,7 @@ static int uvesafb_release(struct fb_info *info, int user)
 	uvesafb_vbe_state_restore(par, par->vbe_state_orig);
 out:
 	atomic_dec(&par->ref_count);
-	if (task)
-		uvesafb_free(task);
+	uvesafb_free(task);
 	return 0;
 }
 
Signature · 1 line
2.1.3
#482 lore raw

PATCH 1/1 video: udlfb: Deletion of unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 11:40:47 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/udlfb.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/video/fbdev/udlfb.c +3 -6
index 77b890e..01fff0c 100644
@@ -922,8 +922,7 @@ static void dlfb_free(struct kref *kref)
 {
 	struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref);
 
-	if (dev->backing_buffer)
-		vfree(dev->backing_buffer);
+	vfree(dev->backing_buffer);
 
 	kfree(dev->edid);
 
@@ -953,8 +952,7 @@ static void dlfb_free_framebuffer(struct dlfb_data *dev)
 			fb_dealloc_cmap(&info->cmap);
 		if (info->monspecs.modedb)
 			fb_destroy_modedb(info->monspecs.modedb);
-		if (info->screen_base)
-			vfree(info->screen_base);
+		vfree(info->screen_base);
 
 		fb_destroy_modelist(&info->modelist);
 
@@ -1203,8 +1201,7 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info)
 		if (!new_back)
 			pr_info("No shadow/backing buffer allocated\n");
 		else {
-			if (dev->backing_buffer)
-				vfree(dev->backing_buffer);
+			vfree(dev->backing_buffer);
 			dev->backing_buffer = new_back;
 		}
 	}
Signature · 1 line
2.1.3
#483 lore raw

PATCH 1/1 video: smscufx: Deletion of unnecessary checks before the function call "vfree"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 12:30:33 +0100

The vfree() function performs also input parameter validation. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/smscufx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/fbdev/smscufx.c +2 -4
index d513ed6..9279e5f 100644
@@ -1142,8 +1142,7 @@ static void ufx_free_framebuffer_work(struct work_struct *work)
 		fb_dealloc_cmap(&info->cmap);
 	if (info->monspecs.modedb)
 		fb_destroy_modedb(info->monspecs.modedb);
-	if (info->screen_base)
-		vfree(info->screen_base);
+	vfree(info->screen_base);
 
 	fb_destroy_modelist(&info->modelist);
 
@@ -1743,8 +1742,7 @@ error:
 				fb_dealloc_cmap(&info->cmap);
 			if (info->monspecs.modedb)
 				fb_destroy_modedb(info->monspecs.modedb);
-			if (info->screen_base)
-				vfree(info->screen_base);
+			vfree(info->screen_base);
 
 			fb_destroy_modelist(&info->modelist);
 
Signature · 1 line
2.1.3
#484 lore raw

PATCH 1/1 video: fbdev-SIS: Deletion of unnecessary checks before the function call "pci_dev_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 12:55:25 +0100

The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/sis/sis_main.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/video/fbdev/sis/sis_main.c +5 -9
index 3f12a2d..6548a3e 100644
@@ -5989,7 +5989,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if(!ivideo->sisvga_enabled) {
 		if(pci_enable_device(pdev)) {
-			if(ivideo->nbridge) pci_dev_put(ivideo->nbridge);
+			pci_dev_put(ivideo->nbridge);
 			framebuffer_release(sis_fb_info);
 			return -EIO;
 		}
@@ -6202,10 +6202,8 @@ error_0:	iounmap(ivideo->video_vbase);
 error_1:	release_mem_region(ivideo->video_base, ivideo->video_size);
 error_2:	release_mem_region(ivideo->mmio_base, ivideo->mmio_size);
 error_3:	vfree(ivideo->bios_abase);
-		if(ivideo->lpcdev)
-			pci_dev_put(ivideo->lpcdev);
-		if(ivideo->nbridge)
-			pci_dev_put(ivideo->nbridge);
+		pci_dev_put(ivideo->lpcdev);
+		pci_dev_put(ivideo->nbridge);
 		if(!ivideo->sisvga_enabled)
 			pci_disable_device(pdev);
 		framebuffer_release(sis_fb_info);
@@ -6505,11 +6503,9 @@ static void sisfb_remove(struct pci_dev *pdev)
 
 	vfree(ivideo->bios_abase);
 
-	if(ivideo->lpcdev)
-		pci_dev_put(ivideo->lpcdev);
+	pci_dev_put(ivideo->lpcdev);
 
-	if(ivideo->nbridge)
-		pci_dev_put(ivideo->nbridge);
+	pci_dev_put(ivideo->nbridge);
 
 #ifdef CONFIG_MTRR
 	/* Release MTRR region */
Signature · 1 line
2.1.3
#485 lore raw

PATCH 1/1 video: fbdev-OMAP2: Deletion of unnecessary checks before the function call "i2c_put_adapter"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 14:07:22 +0100

The i2c_put_adapter() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/omap2/displays-new/connector-dvi.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/video/fbdev/omap2/displays-new/connector-dvi.c +3 -6
index 74de2bc..196c61a 100644
@@ -262,8 +262,7 @@ static int dvic_probe_pdata(struct platform_device *pdev)
 
 	in = omap_dss_find_output(pdata->source);
 	if (in = NULL) {
-		if (ddata->i2c_adapter)
-			i2c_put_adapter(ddata->i2c_adapter);
+		i2c_put_adapter(ddata->i2c_adapter);
 
 		dev_err(&pdev->dev, "Failed to find video source\n");
 		return -EPROBE_DEFER;
@@ -352,8 +351,7 @@ static int dvic_probe(struct platform_device *pdev)
 err_reg:
 	omap_dss_put_device(ddata->in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return r;
 }
@@ -371,8 +369,7 @@ static int __exit dvic_remove(struct platform_device *pdev)
 
 	omap_dss_put_device(in);
 
-	if (ddata->i2c_adapter)
-		i2c_put_adapter(ddata->i2c_adapter);
+	i2c_put_adapter(ddata->i2c_adapter);
 
 	return 0;
 }
Signature · 1 line
2.1.3
#486 lore raw

PATCH 1/1 video: mx3fb: Deletion of an unnecessary check before the function call "backlight_device_unregister"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 15:15:29 +0100

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/mx3fb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/mx3fb.c +1 -2
index c645a0a..b2d2151 100644
@@ -334,8 +334,7 @@ static void mx3fb_init_backlight(struct mx3fb_data *fbd)
 
 static void mx3fb_exit_backlight(struct mx3fb_data *fbd)
 {
-	if (fbd->bl)
-		backlight_device_unregister(fbd->bl);
+	backlight_device_unregister(fbd->bl);
 }
 
 static void mx3fb_dma_done(void *);
Signature · 1 line
2.1.3
#487 lore raw

PATCH 1/1 video: fbdev-MMP: Deletion of an unnecessary check before the function call "mmp_unregister_path"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 15:45:03 +0100

The mmp_unregister_path() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/mmp/hw/mmp_ctrl.c +1 -2
index 8621a9f..3c12bd8 100644
@@ -441,8 +441,7 @@ static void path_deinit(struct mmphw_path_plat *path_plat)
 	if (!path_plat)
 		return;
 
-	if (path_plat->path)
-		mmp_unregister_path(path_plat->path);
+	mmp_unregister_path(path_plat->path);
 }
 
 static int mmphw_probe(struct platform_device *pdev)
Signature · 1 line
2.1.3
#488 lore raw

PATCH 1/1 video: fbdev-VIA: Deletion of an unnecessary check before the function call "framebuffer_release"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 16:30:05 +0100

The framebuffer_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/via/viafbdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/via/viafbdev.c +1 -2
index 325c43c..f9718f0 100644
@@ -1937,8 +1937,7 @@ out_fb1_unreg_lcd_cle266:
 out_dealloc_cmap:
 	fb_dealloc_cmap(&viafbinfo->cmap);
 out_fb1_release:
-	if (viafbinfo1)
-		framebuffer_release(viafbinfo1);
+	framebuffer_release(viafbinfo1);
 out_fb_release:
 	i2c_bus_free(viaparinfo->shared);
 	framebuffer_release(viafbinfo);
Signature · 1 line
2.1.3
#489 lore raw

PATCH 1/1 video: uvesafb: Deletion of an unnecessary check before the function call "platform_device_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 17:05:18 +0100

The platform_device_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/fbdev/uvesafb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/uvesafb.c +1 -2
index 509d452..17b2e8c 100644
@@ -1923,8 +1923,7 @@ static int uvesafb_init(void)
 			err = -ENOMEM;
 
 		if (err) {
-			if (uvesafb_device)
-				platform_device_put(uvesafb_device);
+			platform_device_put(uvesafb_device);
 			platform_driver_unregister(&uvesafb_driver);
 			cn_del_callback(&uvesafb_cn_id);
 			return err;
Signature · 1 line
2.1.3
#490 lore raw

PATCH 1/1 backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 17:33:08 +0100

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.1.3
#491 lore raw

Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"

Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 17:33:08 +0100

What format is this?

Can you use git format-patch and git send-email instead please?

Quoted 24 lines

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#492 lore raw

Re: [PATCH 1/1] backlight: lp8788: Deletion of an unnecessary check before the function call "backlight_device_unregister"

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 23 Nov 2014 17:33:08 +0100

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

Also the $SUBJECT should be less than 75 chars.

Quoted 21 lines

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#493 lore raw

PATCH v2 1/1 backlight: lp8788: Deletion of a check before backlight_device_unregister()

From: Markus Elfring <[email protected]>

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.1.3
#494 lore raw

Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()

Quoted 18 lines

From: Markus Elfring <[email protected]>

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +0 -0
index d6c4f6a..24a055c 100644

drivers/video/backlight/lp8788_bl.c static void lp8788_backlight_unregister(struct lp8788_bl *bl) · line 227

Quoted 9 lines
drivers/video/backlight/lp8788_bl.c +1 -2
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

Would you like to integrate this update suggestion into another source code repository?

Regards,
Markus

#495 lore raw

Re: [PATCH v2] backlight: lp8788: Deletion of a check before backlight_device_unregister()

Quoted 25 lines · SF Markus Elfring
Quoted 25 lines

From: Markus Elfring <[email protected]>

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index d6c4f6a..24a055c 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
Quoted 5 lines

drivers/video/backlight/lp8788_bl.c static void lp8788_backlight_unregister(struct lp8788_bl *bl) · line 227

Quoted 2 lines
drivers/video/backlight/lp8788_bl.c +0 -0
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,

Would you like to integrate this update suggestion into another source code repository?

If this patch has not received any attention in some time, it's possible that it may have slipped through the gaps. Please re-submit the set.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#496 lore raw

PATCH v3 1/1 video-lp8788: Delete a check before backlight_device_unregister()

From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/video/backlight/lp8788_bl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index e418d5b..5d583d7 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
 	struct backlight_device *bl_dev = bl->bl_dev;
 
-	if (bl_dev)
-		backlight_device_unregister(bl_dev);
+	backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.4.5
maintainer Acked-by on v3 1/1
#497 lore raw

Re: [PATCH v3] video-lp8788: Delete a check before backlight_device_unregister()

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 1 Jul 2015 12:08:31 +0200

Quoted 7 lines

The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

It looks good.

Quoted 21 lines

---
drivers/video/backlight/lp8788_bl.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/backlight/lp8788_bl.c +1 -2
index e418d5b..5d583d7 100644
@@ -221,8 +221,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
 {
   struct backlight_device *bl_dev = bl->bl_dev;
 
-    if (bl_dev)
-        backlight_device_unregister(bl_dev);
+    backlight_device_unregister(bl_dev);
 }
 
 static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
Signature · 1 line
2.4.5