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