hgbook

annotate ja/examples/data/remove-redundant-null-checks.patch @ 1051:8e4e523283b5

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