hgbook

view en/examples/data/remove-redundant-null-checks.patch @ 19:187702df428b

Piles of new content for MQ chapter - cookbook stuff.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Jul 07 19:56:53 2006 -0700 (2006-07-07)
parents
children
line source
2 From: Jesper Juhl <jesper.juhl@gmail.com>
4 Remove redundant NULL chck before kfree + tiny CodingStyle cleanup for
5 drivers/
7 Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
8 Signed-off-by: Andrew Morton <akpm@osdl.org>
9 ---
11 drivers/char/agp/sgi-agp.c | 5 ++---
12 drivers/char/hvcs.c | 11 +++++------
13 drivers/message/fusion/mptfc.c | 6 ++----
14 drivers/message/fusion/mptsas.c | 3 +--
15 drivers/net/fs_enet/fs_enet-mii.c | 3 +--
16 drivers/net/wireless/ipw2200.c | 22 ++++++----------------
17 drivers/scsi/libata-scsi.c | 4 +---
18 drivers/video/au1100fb.c | 3 +--
19 8 files changed, 19 insertions(+), 38 deletions(-)
21 diff -puN drivers/char/agp/sgi-agp.c~remove-redundant-null-checks-before-free-in-drivers drivers/char/agp/sgi-agp.c
22 --- a/drivers/char/agp/sgi-agp.c~remove-redundant-null-checks-before-free-in-drivers
23 +++ a/drivers/char/agp/sgi-agp.c
24 @@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void)
26 static void __devexit agp_sgi_cleanup(void)
27 {
28 - if (sgi_tioca_agp_bridges)
29 - kfree(sgi_tioca_agp_bridges);
30 - sgi_tioca_agp_bridges=NULL;
31 + kfree(sgi_tioca_agp_bridges);
32 + sgi_tioca_agp_bridges = NULL;
33 }
35 module_init(agp_sgi_init);
36 diff -puN drivers/char/hvcs.c~remove-redundant-null-checks-before-free-in-drivers drivers/char/hvcs.c
37 --- a/drivers/char/hvcs.c~remove-redundant-null-checks-before-free-in-drivers
38 +++ a/drivers/char/hvcs.c
39 @@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops =
40 static int hvcs_alloc_index_list(int n)
41 {
42 int i;
43 +
44 hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
45 if (!hvcs_index_list)
46 return -ENOMEM;
47 hvcs_index_count = n;
48 - for(i = 0; i < hvcs_index_count; i++)
49 + for (i = 0; i < hvcs_index_count; i++)
50 hvcs_index_list[i] = -1;
51 return 0;
52 }
53 @@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n)
54 static void hvcs_free_index_list(void)
55 {
56 /* Paranoia check to be thorough. */
57 - if (hvcs_index_list) {
58 - kfree(hvcs_index_list);
59 - hvcs_index_list = NULL;
60 - hvcs_index_count = 0;
61 - }
62 + kfree(hvcs_index_list);
63 + hvcs_index_list = NULL;
64 + hvcs_index_count = 0;
65 }
67 static int __init hvcs_module_init(void)
68 diff -puN drivers/message/fusion/mptfc.c~remove-redundant-null-checks-before-free-in-drivers drivers/message/fusion/mptfc.c
69 --- a/drivers/message/fusion/mptfc.c~remove-redundant-null-checks-before-free-in-drivers
70 +++ a/drivers/message/fusion/mptfc.c
71 @@ -305,10 +305,8 @@ mptfc_GetFcDevPage0(MPT_ADAPTER *ioc, in
72 }
74 out:
75 - if (pp0_array)
76 - kfree(pp0_array);
77 - if (p0_array)
78 - kfree(p0_array);
79 + kfree(pp0_array);
80 + kfree(p0_array);
81 return rc;
82 }
84 diff -puN drivers/message/fusion/mptsas.c~remove-redundant-null-checks-before-free-in-drivers drivers/message/fusion/mptsas.c
85 --- a/drivers/message/fusion/mptsas.c~remove-redundant-null-checks-before-free-in-drivers
86 +++ a/drivers/message/fusion/mptsas.c
87 @@ -1378,8 +1378,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
88 return 0;
90 out_free_port_info:
91 - if (hba)
92 - kfree(hba);
93 + kfree(hba);
94 out:
95 return error;
96 }
97 diff -puN drivers/net/fs_enet/fs_enet-mii.c~remove-redundant-null-checks-before-free-in-drivers drivers/net/fs_enet/fs_enet-mii.c
98 --- a/drivers/net/fs_enet/fs_enet-mii.c~remove-redundant-null-checks-before-free-in-drivers
99 +++ a/drivers/net/fs_enet/fs_enet-mii.c
100 @@ -431,8 +431,7 @@ static struct fs_enet_mii_bus *create_bu
101 return bus;
103 err:
104 - if (bus)
105 - kfree(bus);
106 + kfree(bus);
107 return ERR_PTR(ret);
108 }
110 diff -puN drivers/net/wireless/ipw2200.c~remove-redundant-null-checks-before-free-in-drivers drivers/net/wireless/ipw2200.c
111 --- a/drivers/net/wireless/ipw2200.c~remove-redundant-null-checks-before-free-in-drivers
112 +++ a/drivers/net/wireless/ipw2200.c
113 @@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_er
114 return error;
115 }
117 -static void ipw_free_error_log(struct ipw_fw_error *error)
118 -{
119 - if (error)
120 - kfree(error);
121 -}
122 -
123 static ssize_t show_event_log(struct device *d,
124 struct device_attribute *attr, char *buf)
125 {
126 @@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device
127 const char *buf, size_t count)
128 {
129 struct ipw_priv *priv = dev_get_drvdata(d);
130 - if (priv->error) {
131 - ipw_free_error_log(priv->error);
132 - priv->error = NULL;
133 - }
134 +
135 + kfree(priv->error);
136 + priv->error = NULL;
137 return count;
138 }
140 @@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_p
141 struct ipw_fw_error *error =
142 ipw_alloc_error_log(priv);
143 ipw_dump_error_log(priv, error);
144 - if (error)
145 - ipw_free_error_log(error);
146 + kfree(error);
147 }
148 #endif
149 } else {
150 @@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_de
151 }
152 }
154 - if (priv->error) {
155 - ipw_free_error_log(priv->error);
156 - priv->error = NULL;
157 - }
158 + kfree(priv->error);
159 + priv->error = NULL;
161 #ifdef CONFIG_IPW2200_PROMISCUOUS
162 ipw_prom_free(priv);
163 diff -puN drivers/scsi/libata-scsi.c~remove-redundant-null-checks-before-free-in-drivers drivers/scsi/libata-scsi.c
164 --- a/drivers/scsi/libata-scsi.c~remove-redundant-null-checks-before-free-in-drivers
165 +++ a/drivers/scsi/libata-scsi.c
166 @@ -222,9 +222,7 @@ int ata_cmd_ioctl(struct scsi_device *sc
167 && copy_to_user(arg + sizeof(args), argbuf, argsize))
168 rc = -EFAULT;
169 error:
170 - if (argbuf)
171 - kfree(argbuf);
172 -
173 + kfree(argbuf);
174 return rc;
175 }
177 diff -puN drivers/video/au1100fb.c~remove-redundant-null-checks-before-free-in-drivers drivers/video/au1100fb.c
178 --- a/drivers/video/au1100fb.c~remove-redundant-null-checks-before-free-in-drivers
179 +++ a/drivers/video/au1100fb.c
180 @@ -743,8 +743,7 @@ void __exit au1100fb_cleanup(void)
181 {
182 driver_unregister(&au1100fb_driver);
184 - if (drv_info.opt_mode)
185 - kfree(drv_info.opt_mode);
186 + kfree(drv_info.opt_mode);
187 }
189 module_init(au1100fb_init);
190 _