diff options
author | Rob Landley <rob@landley.net> | 2006-03-01 16:39:45 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-03-01 16:39:45 +0000 |
commit | e7c43b66d74ee9902a6732122788a7a16bcfbf18 (patch) | |
tree | ebb8583e9e1265588592614c0b4878daded44125 | |
parent | 93f2286e6e59dab5eed14b5912a79254031c5a62 (diff) | |
download | busybox-w32-e7c43b66d74ee9902a6732122788a7a16bcfbf18.tar.gz busybox-w32-e7c43b66d74ee9902a6732122788a7a16bcfbf18.tar.bz2 busybox-w32-e7c43b66d74ee9902a6732122788a7a16bcfbf18.zip |
Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)
from before "if(x) free(x)".
33 files changed, 140 insertions, 282 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index 70eaefb94..74d3a83d9 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -544,8 +544,7 @@ static void free_package(common_node_t *node) | |||
544 | for (i = 0; i < node->num_of_edges; i++) { | 544 | for (i = 0; i < node->num_of_edges; i++) { |
545 | free(node->edge[i]); | 545 | free(node->edge[i]); |
546 | } | 546 | } |
547 | if ( node->edge ) | 547 | free(node->edge); |
548 | free(node->edge); | ||
549 | free(node); | 548 | free(node); |
550 | } | 549 | } |
551 | } | 550 | } |
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c index df6fa078f..7f700ca7f 100644 --- a/archival/libunarchive/decompress_bunzip2.c +++ b/archival/libunarchive/decompress_bunzip2.c | |||
@@ -714,7 +714,7 @@ extern int uncompressStream(int src_fd, int dst_fd) | |||
714 | } else { | 714 | } else { |
715 | bb_error_msg("Decompression failed"); | 715 | bb_error_msg("Decompression failed"); |
716 | } | 716 | } |
717 | if(bd->dbuf) free(bd->dbuf); | 717 | free(bd->dbuf); |
718 | free(bd); | 718 | free(bd); |
719 | free(outbuf); | 719 | free(outbuf); |
720 | 720 | ||
diff --git a/archival/unzip.c b/archival/unzip.c index ff2b1a266..7e0d107cc 100644 --- a/archival/unzip.c +++ b/archival/unzip.c | |||
@@ -393,7 +393,7 @@ extern int unzip_main(int argc, char **argv) | |||
393 | goto _check_file; | 393 | goto _check_file; |
394 | 394 | ||
395 | default: | 395 | default: |
396 | printf("error: invalid response [%c]\n",(char)i); | 396 | printf("error: invalid response [%c]\n",(char)i); |
397 | goto _check_file; | 397 | goto _check_file; |
398 | } | 398 | } |
399 | 399 | ||
@@ -405,8 +405,8 @@ extern int unzip_main(int argc, char **argv) | |||
405 | } | 405 | } |
406 | 406 | ||
407 | if (verbosity == v_list) { | 407 | if (verbosity == v_list) { |
408 | printf(" -------- -------\n"); | 408 | printf(" -------- -------\n" |
409 | printf("%9d %d files\n", total_size, total_entries); | 409 | "%9d %d files\n", total_size, total_entries); |
410 | } | 410 | } |
411 | 411 | ||
412 | return(EXIT_SUCCESS); | 412 | return(EXIT_SUCCESS); |
diff --git a/e2fsprogs/blkid/cache.c b/e2fsprogs/blkid/cache.c index 87be1269f..daccb30b3 100644 --- a/e2fsprogs/blkid/cache.c +++ b/e2fsprogs/blkid/cache.c | |||
@@ -88,8 +88,7 @@ void blkid_put_cache(blkid_cache cache) | |||
88 | } | 88 | } |
89 | blkid_free_tag(tag); | 89 | blkid_free_tag(tag); |
90 | } | 90 | } |
91 | if (cache->bic_filename) | 91 | free(cache->bic_filename); |
92 | free(cache->bic_filename); | ||
93 | 92 | ||
94 | free(cache); | 93 | free(cache); |
95 | } | 94 | } |
diff --git a/e2fsprogs/blkid/devno.c b/e2fsprogs/blkid/devno.c index 7d083e76f..2979280f7 100644 --- a/e2fsprogs/blkid/devno.c +++ b/e2fsprogs/blkid/devno.c | |||
@@ -218,8 +218,7 @@ int main(int argc, char** argv) | |||
218 | } | 218 | } |
219 | printf("Looking for device 0x%04Lx\n", devno); | 219 | printf("Looking for device 0x%04Lx\n", devno); |
220 | devname = blkid_devno_to_devname(devno); | 220 | devname = blkid_devno_to_devname(devno); |
221 | if (devname) | 221 | free(devname); |
222 | free(devname); | ||
223 | return 0; | 222 | return 0; |
224 | } | 223 | } |
225 | #endif | 224 | #endif |
diff --git a/e2fsprogs/blkid/resolve.c b/e2fsprogs/blkid/resolve.c index 591b63057..40d999a1b 100644 --- a/e2fsprogs/blkid/resolve.c +++ b/e2fsprogs/blkid/resolve.c | |||
@@ -96,10 +96,8 @@ char *blkid_get_devname(blkid_cache cache, const char *token, | |||
96 | ret = blkid_strdup(blkid_dev_devname(dev)); | 96 | ret = blkid_strdup(blkid_dev_devname(dev)); |
97 | 97 | ||
98 | errout: | 98 | errout: |
99 | if (t) | 99 | free(t); |
100 | free(t); | 100 | free(v); |
101 | if (v) | ||
102 | free(v); | ||
103 | if (!cache) { | 101 | if (!cache) { |
104 | blkid_put_cache(c); | 102 | blkid_put_cache(c); |
105 | } | 103 | } |
diff --git a/e2fsprogs/blkid/save.c b/e2fsprogs/blkid/save.c index cc406ebfb..98d8d0260 100644 --- a/e2fsprogs/blkid/save.c +++ b/e2fsprogs/blkid/save.c | |||
@@ -148,8 +148,7 @@ int blkid_flush_cache(blkid_cache cache) | |||
148 | } | 148 | } |
149 | 149 | ||
150 | errout: | 150 | errout: |
151 | if (tmp) | 151 | free(tmp); |
152 | free(tmp); | ||
153 | return ret; | 152 | return ret; |
154 | } | 153 | } |
155 | 154 | ||
diff --git a/e2fsprogs/blkid/tag.c b/e2fsprogs/blkid/tag.c index e2c785cf0..95112eba5 100644 --- a/e2fsprogs/blkid/tag.c +++ b/e2fsprogs/blkid/tag.c | |||
@@ -41,11 +41,8 @@ void blkid_free_tag(blkid_tag tag) | |||
41 | list_del(&tag->bit_tags); /* list of tags for this device */ | 41 | list_del(&tag->bit_tags); /* list of tags for this device */ |
42 | list_del(&tag->bit_names); /* list of tags with this type */ | 42 | list_del(&tag->bit_names); /* list of tags with this type */ |
43 | 43 | ||
44 | if (tag->bit_name) | 44 | free(tag->bit_name); |
45 | free(tag->bit_name); | 45 | free(tag->bit_val); |
46 | if (tag->bit_val) | ||
47 | free(tag->bit_val); | ||
48 | |||
49 | free(tag); | 46 | free(tag); |
50 | } | 47 | } |
51 | 48 | ||
@@ -112,8 +109,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, | |||
112 | return -BLKID_ERR_MEM; | 109 | return -BLKID_ERR_MEM; |
113 | t = blkid_find_tag_dev(dev, name); | 110 | t = blkid_find_tag_dev(dev, name); |
114 | if (!value) { | 111 | if (!value) { |
115 | if (t) | 112 | blkid_free_tag(t); |
116 | blkid_free_tag(t); | ||
117 | } else if (t) { | 113 | } else if (t) { |
118 | if (!strcmp(t->bit_val, val)) { | 114 | if (!strcmp(t->bit_val, val)) { |
119 | /* Same thing, exit */ | 115 | /* Same thing, exit */ |
@@ -165,12 +161,10 @@ int blkid_set_tag(blkid_dev dev, const char *name, | |||
165 | return 0; | 161 | return 0; |
166 | 162 | ||
167 | errout: | 163 | errout: |
168 | if (t) | 164 | blkid_free_tag(t); |
169 | blkid_free_tag(t); | 165 | if (!t) |
170 | else if (val) | ||
171 | free(val); | 166 | free(val); |
172 | if (head) | 167 | blkid_free_tag(head); |
173 | blkid_free_tag(head); | ||
174 | return -BLKID_ERR_MEM; | 168 | return -BLKID_ERR_MEM; |
175 | } | 169 | } |
176 | 170 | ||
diff --git a/e2fsprogs/e2fsck.c b/e2fsprogs/e2fsck.c index 1c97cf4bb..489d2a818 100644 --- a/e2fsprogs/e2fsck.c +++ b/e2fsprogs/e2fsck.c | |||
@@ -2036,10 +2036,7 @@ static struct dir_info *e2fsck_get_dir_info(e2fsck_t ctx, ext2_ino_t ino) | |||
2036 | */ | 2036 | */ |
2037 | static void e2fsck_free_dir_info(e2fsck_t ctx) | 2037 | static void e2fsck_free_dir_info(e2fsck_t ctx) |
2038 | { | 2038 | { |
2039 | if (ctx->dir_info) { | 2039 | ext2fs_free_mem(&ctx->dir_info); |
2040 | ext2fs_free_mem(&ctx->dir_info); | ||
2041 | ctx->dir_info = 0; | ||
2042 | } | ||
2043 | ctx->dir_info_size = 0; | 2040 | ctx->dir_info_size = 0; |
2044 | ctx->dir_info_count = 0; | 2041 | ctx->dir_info_count = 0; |
2045 | } | 2042 | } |
@@ -2178,13 +2175,9 @@ static void e2fsck_free_dx_dir_info(e2fsck_t ctx) | |||
2178 | if (ctx->dx_dir_info) { | 2175 | if (ctx->dx_dir_info) { |
2179 | dir = ctx->dx_dir_info; | 2176 | dir = ctx->dx_dir_info; |
2180 | for (i=0; i < ctx->dx_dir_info_count; i++) { | 2177 | for (i=0; i < ctx->dx_dir_info_count; i++) { |
2181 | if (dir->dx_block) { | 2178 | ext2fs_free_mem(&dir->dx_block); |
2182 | ext2fs_free_mem(&dir->dx_block); | ||
2183 | dir->dx_block = 0; | ||
2184 | } | ||
2185 | } | 2179 | } |
2186 | ext2fs_free_mem(&ctx->dx_dir_info); | 2180 | ext2fs_free_mem(&ctx->dx_dir_info); |
2187 | ctx->dx_dir_info = 0; | ||
2188 | } | 2181 | } |
2189 | ctx->dx_dir_info_size = 0; | 2182 | ctx->dx_dir_info_size = 0; |
2190 | ctx->dx_dir_info_count = 0; | 2183 | ctx->dx_dir_info_count = 0; |
@@ -2245,8 +2238,7 @@ static void ea_refcount_free(ext2_refcount_t refcount) | |||
2245 | if (!refcount) | 2238 | if (!refcount) |
2246 | return; | 2239 | return; |
2247 | 2240 | ||
2248 | if (refcount->list) | 2241 | ext2fs_free_mem(&refcount->list); |
2249 | ext2fs_free_mem(&refcount->list); | ||
2250 | ext2fs_free_mem(&refcount); | 2242 | ext2fs_free_mem(&refcount); |
2251 | } | 2243 | } |
2252 | 2244 | ||
@@ -2259,32 +2251,22 @@ static errcode_t e2fsck_reset_context(e2fsck_t ctx) | |||
2259 | ctx->flags = 0; | 2251 | ctx->flags = 0; |
2260 | ctx->lost_and_found = 0; | 2252 | ctx->lost_and_found = 0; |
2261 | ctx->bad_lost_and_found = 0; | 2253 | ctx->bad_lost_and_found = 0; |
2262 | if (ctx->inode_used_map) { | 2254 | ext2fs_free_inode_bitmap(ctx->inode_used_map); |
2263 | ext2fs_free_inode_bitmap(ctx->inode_used_map); | 2255 | ctx->inode_used_map = 0; |
2264 | ctx->inode_used_map = 0; | 2256 | ext2fs_free_inode_bitmap(ctx->inode_dir_map); |
2265 | } | 2257 | ctx->inode_dir_map = 0; |
2266 | if (ctx->inode_dir_map) { | 2258 | ext2fs_free_inode_bitmap(ctx->inode_reg_map); |
2267 | ext2fs_free_inode_bitmap(ctx->inode_dir_map); | 2259 | ctx->inode_reg_map = 0; |
2268 | ctx->inode_dir_map = 0; | 2260 | ext2fs_free_block_bitmap(ctx->block_found_map); |
2269 | } | 2261 | ctx->block_found_map = 0; |
2270 | if (ctx->inode_reg_map) { | 2262 | ext2fs_free_icount(ctx->inode_link_info); |
2271 | ext2fs_free_inode_bitmap(ctx->inode_reg_map); | 2263 | ctx->inode_link_info = 0; |
2272 | ctx->inode_reg_map = 0; | ||
2273 | } | ||
2274 | if (ctx->block_found_map) { | ||
2275 | ext2fs_free_block_bitmap(ctx->block_found_map); | ||
2276 | ctx->block_found_map = 0; | ||
2277 | } | ||
2278 | if (ctx->inode_link_info) { | ||
2279 | ext2fs_free_icount(ctx->inode_link_info); | ||
2280 | ctx->inode_link_info = 0; | ||
2281 | } | ||
2282 | if (ctx->journal_io) { | 2264 | if (ctx->journal_io) { |
2283 | if (ctx->fs && ctx->fs->io != ctx->journal_io) | 2265 | if (ctx->fs && ctx->fs->io != ctx->journal_io) |
2284 | io_channel_close(ctx->journal_io); | 2266 | io_channel_close(ctx->journal_io); |
2285 | ctx->journal_io = 0; | 2267 | ctx->journal_io = 0; |
2286 | } | 2268 | } |
2287 | if (ctx->fs && ctx->fs->dblist) { | 2269 | if (ctx->fs) { |
2288 | ext2fs_free_dblist(ctx->fs->dblist); | 2270 | ext2fs_free_dblist(ctx->fs->dblist); |
2289 | ctx->fs->dblist = 0; | 2271 | ctx->fs->dblist = 0; |
2290 | } | 2272 | } |
@@ -2292,54 +2274,29 @@ static errcode_t e2fsck_reset_context(e2fsck_t ctx) | |||
2292 | #ifdef ENABLE_HTREE | 2274 | #ifdef ENABLE_HTREE |
2293 | e2fsck_free_dx_dir_info(ctx); | 2275 | e2fsck_free_dx_dir_info(ctx); |
2294 | #endif | 2276 | #endif |
2295 | if (ctx->refcount) { | 2277 | ea_refcount_free(ctx->refcount); |
2296 | ea_refcount_free(ctx->refcount); | 2278 | ctx->refcount = 0; |
2297 | ctx->refcount = 0; | 2279 | ea_refcount_free(ctx->refcount_extra); |
2298 | } | 2280 | ctx->refcount_extra = 0; |
2299 | if (ctx->refcount_extra) { | 2281 | ext2fs_free_block_bitmap(ctx->block_dup_map); |
2300 | ea_refcount_free(ctx->refcount_extra); | 2282 | ctx->block_dup_map = 0; |
2301 | ctx->refcount_extra = 0; | 2283 | ext2fs_free_block_bitmap(ctx->block_ea_map); |
2302 | } | 2284 | ctx->block_ea_map = 0; |
2303 | if (ctx->block_dup_map) { | 2285 | ext2fs_free_inode_bitmap(ctx->inode_bb_map); |
2304 | ext2fs_free_block_bitmap(ctx->block_dup_map); | 2286 | ctx->inode_bb_map = 0; |
2305 | ctx->block_dup_map = 0; | 2287 | ext2fs_free_inode_bitmap(ctx->inode_bad_map); |
2306 | } | 2288 | ctx->inode_bad_map = 0; |
2307 | if (ctx->block_ea_map) { | 2289 | ext2fs_free_inode_bitmap(ctx->inode_imagic_map); |
2308 | ext2fs_free_block_bitmap(ctx->block_ea_map); | 2290 | ctx->inode_imagic_map = 0; |
2309 | ctx->block_ea_map = 0; | 2291 | ext2fs_u32_list_free(ctx->dirs_to_hash); |
2310 | } | 2292 | ctx->dirs_to_hash = 0; |
2311 | if (ctx->inode_bb_map) { | ||
2312 | ext2fs_free_inode_bitmap(ctx->inode_bb_map); | ||
2313 | ctx->inode_bb_map = 0; | ||
2314 | } | ||
2315 | if (ctx->inode_bad_map) { | ||
2316 | ext2fs_free_inode_bitmap(ctx->inode_bad_map); | ||
2317 | ctx->inode_bad_map = 0; | ||
2318 | } | ||
2319 | if (ctx->inode_imagic_map) { | ||
2320 | ext2fs_free_inode_bitmap(ctx->inode_imagic_map); | ||
2321 | ctx->inode_imagic_map = 0; | ||
2322 | } | ||
2323 | if (ctx->dirs_to_hash) { | ||
2324 | ext2fs_u32_list_free(ctx->dirs_to_hash); | ||
2325 | ctx->dirs_to_hash = 0; | ||
2326 | } | ||
2327 | 2293 | ||
2328 | /* | 2294 | /* |
2329 | * Clear the array of invalid meta-data flags | 2295 | * Clear the array of invalid meta-data flags |
2330 | */ | 2296 | */ |
2331 | if (ctx->invalid_inode_bitmap_flag) { | 2297 | ext2fs_free_mem(&ctx->invalid_inode_bitmap_flag); |
2332 | ext2fs_free_mem(&ctx->invalid_inode_bitmap_flag); | 2298 | ext2fs_free_mem(&ctx->invalid_block_bitmap_flag); |
2333 | ctx->invalid_inode_bitmap_flag = 0; | 2299 | ext2fs_free_mem(&ctx->invalid_inode_table_flag); |
2334 | } | ||
2335 | if (ctx->invalid_block_bitmap_flag) { | ||
2336 | ext2fs_free_mem(&ctx->invalid_block_bitmap_flag); | ||
2337 | ctx->invalid_block_bitmap_flag = 0; | ||
2338 | } | ||
2339 | if (ctx->invalid_inode_table_flag) { | ||
2340 | ext2fs_free_mem(&ctx->invalid_inode_table_flag); | ||
2341 | ctx->invalid_inode_table_flag = 0; | ||
2342 | } | ||
2343 | 2300 | ||
2344 | /* Clear statistic counters */ | 2301 | /* Clear statistic counters */ |
2345 | ctx->fs_directory_count = 0; | 2302 | ctx->fs_directory_count = 0; |
@@ -3118,20 +3075,16 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal) | |||
3118 | journal->j_superblock = (journal_superblock_t *)bh->b_data; | 3075 | journal->j_superblock = (journal_superblock_t *)bh->b_data; |
3119 | 3076 | ||
3120 | #ifdef USE_INODE_IO | 3077 | #ifdef USE_INODE_IO |
3121 | if (j_inode) | 3078 | ext2fs_free_mem(&j_inode); |
3122 | ext2fs_free_mem(&j_inode); | ||
3123 | #endif | 3079 | #endif |
3124 | 3080 | ||
3125 | *ret_journal = journal; | 3081 | *ret_journal = journal; |
3126 | return 0; | 3082 | return 0; |
3127 | 3083 | ||
3128 | errout: | 3084 | errout: |
3129 | if (dev_fs) | 3085 | ext2fs_free_mem(&dev_fs); |
3130 | ext2fs_free_mem(&dev_fs); | 3086 | ext2fs_free_mem(&j_inode); |
3131 | if (j_inode) | 3087 | ext2fs_free_mem(&journal); |
3132 | ext2fs_free_mem(&j_inode); | ||
3133 | if (journal) | ||
3134 | ext2fs_free_mem(&journal); | ||
3135 | return retval; | 3088 | return retval; |
3136 | 3089 | ||
3137 | } | 3090 | } |
@@ -3368,11 +3321,9 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal, | |||
3368 | } | 3321 | } |
3369 | 3322 | ||
3370 | #ifndef USE_INODE_IO | 3323 | #ifndef USE_INODE_IO |
3371 | if (journal->j_inode) | 3324 | ext2fs_free_mem(&journal->j_inode); |
3372 | ext2fs_free_mem(&journal->j_inode); | ||
3373 | #endif | 3325 | #endif |
3374 | if (journal->j_fs_dev) | 3326 | ext2fs_free_mem(&journal->j_fs_dev); |
3375 | ext2fs_free_mem(&journal->j_fs_dev); | ||
3376 | ext2fs_free_mem(&journal); | 3327 | ext2fs_free_mem(&journal); |
3377 | } | 3328 | } |
3378 | 3329 | ||
@@ -4346,7 +4297,6 @@ static __u64 ext2_max_sizes[EXT2_MAX_BLOCK_LOG_SIZE - | |||
4346 | static void unwind_pass1(void) | 4297 | static void unwind_pass1(void) |
4347 | { | 4298 | { |
4348 | ext2fs_free_mem(&inodes_to_process); | 4299 | ext2fs_free_mem(&inodes_to_process); |
4349 | inodes_to_process = 0; | ||
4350 | } | 4300 | } |
4351 | 4301 | ||
4352 | /* | 4302 | /* |
@@ -5086,10 +5036,8 @@ static void e2fsck_pass1(e2fsck_t ctx) | |||
5086 | handle_fs_bad_blocks(ctx); | 5036 | handle_fs_bad_blocks(ctx); |
5087 | 5037 | ||
5088 | /* We don't need the block_ea_map any more */ | 5038 | /* We don't need the block_ea_map any more */ |
5089 | if (ctx->block_ea_map) { | 5039 | ext2fs_free_block_bitmap(ctx->block_ea_map); |
5090 | ext2fs_free_block_bitmap(ctx->block_ea_map); | 5040 | ctx->block_ea_map = 0; |
5091 | ctx->block_ea_map = 0; | ||
5092 | } | ||
5093 | 5041 | ||
5094 | if (ctx->flags & E2F_FLAG_RESIZE_INODE) { | 5042 | if (ctx->flags & E2F_FLAG_RESIZE_INODE) { |
5095 | ext2fs_block_bitmap save_bmap; | 5043 | ext2fs_block_bitmap save_bmap; |
@@ -7359,14 +7307,10 @@ static void e2fsck_pass2(e2fsck_t ctx) | |||
7359 | ext2fs_free_mem(&buf); | 7307 | ext2fs_free_mem(&buf); |
7360 | ext2fs_free_dblist(fs->dblist); | 7308 | ext2fs_free_dblist(fs->dblist); |
7361 | 7309 | ||
7362 | if (ctx->inode_bad_map) { | 7310 | ext2fs_free_inode_bitmap(ctx->inode_bad_map); |
7363 | ext2fs_free_inode_bitmap(ctx->inode_bad_map); | 7311 | ctx->inode_bad_map = 0; |
7364 | ctx->inode_bad_map = 0; | 7312 | ext2fs_free_inode_bitmap(ctx->inode_reg_map); |
7365 | } | 7313 | ctx->inode_reg_map = 0; |
7366 | if (ctx->inode_reg_map) { | ||
7367 | ext2fs_free_inode_bitmap(ctx->inode_reg_map); | ||
7368 | ctx->inode_reg_map = 0; | ||
7369 | } | ||
7370 | 7314 | ||
7371 | clear_problem_context(&pctx); | 7315 | clear_problem_context(&pctx); |
7372 | if (ctx->large_files) { | 7316 | if (ctx->large_files) { |
@@ -8665,14 +8609,10 @@ static void e2fsck_pass3(e2fsck_t ctx) | |||
8665 | 8609 | ||
8666 | abort_exit: | 8610 | abort_exit: |
8667 | e2fsck_free_dir_info(ctx); | 8611 | e2fsck_free_dir_info(ctx); |
8668 | if (inode_loop_detect) { | 8612 | ext2fs_free_inode_bitmap(inode_loop_detect); |
8669 | ext2fs_free_inode_bitmap(inode_loop_detect); | 8613 | inode_loop_detect = 0; |
8670 | inode_loop_detect = 0; | 8614 | ext2fs_free_inode_bitmap(inode_done_map); |
8671 | } | 8615 | inode_done_map = 0; |
8672 | if (inode_done_map) { | ||
8673 | ext2fs_free_inode_bitmap(inode_done_map); | ||
8674 | inode_done_map = 0; | ||
8675 | } | ||
8676 | 8616 | ||
8677 | #ifdef RESOURCE_TRACK | 8617 | #ifdef RESOURCE_TRACK |
8678 | if (ctx->options & E2F_OPT_TIME2) { | 8618 | if (ctx->options & E2F_OPT_TIME2) { |
@@ -9497,8 +9437,7 @@ static void e2fsck_pass4(e2fsck_t ctx) | |||
9497 | ctx->inode_bb_map = 0; | 9437 | ctx->inode_bb_map = 0; |
9498 | ext2fs_free_inode_bitmap(ctx->inode_imagic_map); | 9438 | ext2fs_free_inode_bitmap(ctx->inode_imagic_map); |
9499 | ctx->inode_imagic_map = 0; | 9439 | ctx->inode_imagic_map = 0; |
9500 | if (buf) | 9440 | ext2fs_free_mem(&buf); |
9501 | ext2fs_free_mem(&buf); | ||
9502 | #ifdef RESOURCE_TRACK | 9441 | #ifdef RESOURCE_TRACK |
9503 | if (ctx->options & E2F_OPT_TIME2) { | 9442 | if (ctx->options & E2F_OPT_TIME2) { |
9504 | e2fsck_clear_progbar(ctx); | 9443 | e2fsck_clear_progbar(ctx); |
@@ -12360,10 +12299,8 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir, | |||
12360 | 12299 | ||
12361 | static void free_out_dir(struct out_dir *outdir) | 12300 | static void free_out_dir(struct out_dir *outdir) |
12362 | { | 12301 | { |
12363 | if (outdir->buf) | 12302 | free(outdir->buf); |
12364 | free(outdir->buf); | 12303 | free(outdir->hashes); |
12365 | if (outdir->hashes) | ||
12366 | free(outdir->hashes); | ||
12367 | outdir->max = 0; | 12304 | outdir->max = 0; |
12368 | outdir->num =0; | 12305 | outdir->num =0; |
12369 | } | 12306 | } |
@@ -12872,14 +12809,10 @@ resort: | |||
12872 | } | 12809 | } |
12873 | 12810 | ||
12874 | retval = write_directory(ctx, fs, &outdir, ino, fd.compress); | 12811 | retval = write_directory(ctx, fs, &outdir, ino, fd.compress); |
12875 | if (retval) | ||
12876 | goto errout; | ||
12877 | 12812 | ||
12878 | errout: | 12813 | errout: |
12879 | if (dir_buf) | 12814 | free(dir_buf); |
12880 | free(dir_buf); | 12815 | free(fd.harray); |
12881 | if (fd.harray) | ||
12882 | free(fd.harray); | ||
12883 | 12816 | ||
12884 | free_out_dir(&outdir); | 12817 | free_out_dir(&outdir); |
12885 | return retval; | 12818 | return retval; |
@@ -12957,8 +12890,7 @@ void e2fsck_rehash_directories(e2fsck_t ctx) | |||
12957 | if (!all_dirs) | 12890 | if (!all_dirs) |
12958 | ext2fs_u32_list_iterate_end(iter); | 12891 | ext2fs_u32_list_iterate_end(iter); |
12959 | 12892 | ||
12960 | if (ctx->dirs_to_hash) | 12893 | ext2fs_u32_list_free(ctx->dirs_to_hash); |
12961 | ext2fs_u32_list_free(ctx->dirs_to_hash); | ||
12962 | ctx->dirs_to_hash = 0; | 12894 | ctx->dirs_to_hash = 0; |
12963 | 12895 | ||
12964 | #ifdef RESOURCE_TRACK | 12896 | #ifdef RESOURCE_TRACK |
@@ -13676,8 +13608,7 @@ static void check_resize_inode(e2fsck_t ctx) | |||
13676 | } | 13608 | } |
13677 | 13609 | ||
13678 | cleanup: | 13610 | cleanup: |
13679 | if (dind_buf) | 13611 | ext2fs_free_mem(&dind_buf); |
13680 | ext2fs_free_mem(&dind_buf); | ||
13681 | 13612 | ||
13682 | } | 13613 | } |
13683 | 13614 | ||
@@ -14639,8 +14570,7 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name, | |||
14639 | cleanup: | 14570 | cleanup: |
14640 | if (io) | 14571 | if (io) |
14641 | io_channel_close(io); | 14572 | io_channel_close(io); |
14642 | if (buf) | 14573 | ext2fs_free_mem(&buf); |
14643 | ext2fs_free_mem(&buf); | ||
14644 | return (ret_sb); | 14574 | return (ret_sb); |
14645 | } | 14575 | } |
14646 | 14576 | ||
diff --git a/e2fsprogs/ext2fs/bmap.c b/e2fsprogs/ext2fs/bmap.c index 45d49f929..4a53ebc4c 100644 --- a/e2fsprogs/ext2fs/bmap.c +++ b/e2fsprogs/ext2fs/bmap.c | |||
@@ -257,8 +257,7 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, | |||
257 | retval = block_tind_bmap(fs, bmap_flags, b, block_buf, | 257 | retval = block_tind_bmap(fs, bmap_flags, b, block_buf, |
258 | &blocks_alloc, block, phys_blk); | 258 | &blocks_alloc, block, phys_blk); |
259 | done: | 259 | done: |
260 | if (buf) | 260 | ext2fs_free_mem(&buf); |
261 | ext2fs_free_mem(&buf); | ||
262 | if ((retval == 0) && (blocks_alloc || inode_dirty)) { | 261 | if ((retval == 0) && (blocks_alloc || inode_dirty)) { |
263 | inode->i_blocks += (blocks_alloc * fs->blocksize) / 512; | 262 | inode->i_blocks += (blocks_alloc * fs->blocksize) / 512; |
264 | retval = ext2fs_write_inode(fs, ino, inode); | 263 | retval = ext2fs_write_inode(fs, ino, inode); |
diff --git a/e2fsprogs/ext2fs/bmove.c b/e2fsprogs/ext2fs/bmove.c index fb319f8c3..7e98c0fe5 100644 --- a/e2fsprogs/ext2fs/bmove.c +++ b/e2fsprogs/ext2fs/bmove.c | |||
@@ -119,10 +119,8 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, | |||
119 | * block move. | 119 | * block move. |
120 | */ | 120 | */ |
121 | if (flags & EXT2_BMOVE_GET_DBLIST) { | 121 | if (flags & EXT2_BMOVE_GET_DBLIST) { |
122 | if (fs->dblist) { | 122 | ext2fs_free_dblist(fs->dblist); |
123 | ext2fs_free_dblist(fs->dblist); | 123 | fs->dblist = NULL; |
124 | fs->dblist = NULL; | ||
125 | } | ||
126 | retval = ext2fs_init_dblist(fs, 0); | 124 | retval = ext2fs_init_dblist(fs, 0); |
127 | if (retval) | 125 | if (retval) |
128 | return retval; | 126 | return retval; |
diff --git a/e2fsprogs/ext2fs/brel_ma.c b/e2fsprogs/ext2fs/brel_ma.c index 4dcfded37..557143d51 100644 --- a/e2fsprogs/ext2fs/brel_ma.c +++ b/e2fsprogs/ext2fs/brel_ma.c | |||
@@ -186,12 +186,10 @@ static errcode_t bma_free(ext2_brel brel) | |||
186 | ma = brel->priv_data; | 186 | ma = brel->priv_data; |
187 | 187 | ||
188 | if (ma) { | 188 | if (ma) { |
189 | if (ma->entries) | 189 | ext2fs_free_mem(&ma->entries); |
190 | ext2fs_free_mem(&ma->entries); | ||
191 | ext2fs_free_mem(&ma); | 190 | ext2fs_free_mem(&ma); |
192 | } | 191 | } |
193 | if (brel->name) | 192 | ext2fs_free_mem(&brel->name); |
194 | ext2fs_free_mem(&brel->name); | ||
195 | ext2fs_free_mem(&brel); | 193 | ext2fs_free_mem(&brel); |
196 | return 0; | 194 | return 0; |
197 | } | 195 | } |
diff --git a/e2fsprogs/ext2fs/dblist.c b/e2fsprogs/ext2fs/dblist.c index 0cf5698fa..73313faf3 100644 --- a/e2fsprogs/ext2fs/dblist.c +++ b/e2fsprogs/ext2fs/dblist.c | |||
@@ -99,8 +99,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count, | |||
99 | fs->dblist = dblist; | 99 | fs->dblist = dblist; |
100 | return 0; | 100 | return 0; |
101 | cleanup: | 101 | cleanup: |
102 | if (dblist) | 102 | ext2fs_free_mem(&dblist); |
103 | ext2fs_free_mem(&dblist); | ||
104 | return retval; | 103 | return retval; |
105 | } | 104 | } |
106 | 105 | ||
diff --git a/e2fsprogs/ext2fs/fileio.c b/e2fsprogs/ext2fs/fileio.c index 669e80c65..da349fea2 100644 --- a/e2fsprogs/ext2fs/fileio.c +++ b/e2fsprogs/ext2fs/fileio.c | |||
@@ -73,8 +73,7 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, | |||
73 | return 0; | 73 | return 0; |
74 | 74 | ||
75 | fail: | 75 | fail: |
76 | if (file->buf) | 76 | ext2fs_free_mem(&file->buf); |
77 | ext2fs_free_mem(&file->buf); | ||
78 | ext2fs_free_mem(&file); | 77 | ext2fs_free_mem(&file); |
79 | return retval; | 78 | return retval; |
80 | } | 79 | } |
@@ -197,8 +196,7 @@ errcode_t ext2fs_file_close(ext2_file_t file) | |||
197 | 196 | ||
198 | retval = ext2fs_file_flush(file); | 197 | retval = ext2fs_file_flush(file); |
199 | 198 | ||
200 | if (file->buf) | 199 | ext2fs_free_mem(&file->buf); |
201 | ext2fs_free_mem(&file->buf); | ||
202 | ext2fs_free_mem(&file); | 200 | ext2fs_free_mem(&file); |
203 | 201 | ||
204 | return retval; | 202 | return retval; |
diff --git a/e2fsprogs/ext2fs/freefs.c b/e2fsprogs/ext2fs/freefs.c index 3fd51f257..f0f7b3eec 100644 --- a/e2fsprogs/ext2fs/freefs.c +++ b/e2fsprogs/ext2fs/freefs.c | |||
@@ -30,25 +30,17 @@ void ext2fs_free(ext2_filsys fs) | |||
30 | if (fs->io) { | 30 | if (fs->io) { |
31 | io_channel_close(fs->io); | 31 | io_channel_close(fs->io); |
32 | } | 32 | } |
33 | if (fs->device_name) | 33 | ext2fs_free_mem(&fs->device_name); |
34 | ext2fs_free_mem(&fs->device_name); | 34 | ext2fs_free_mem(&fs->super); |
35 | if (fs->super) | 35 | ext2fs_free_mem(&fs->orig_super); |
36 | ext2fs_free_mem(&fs->super); | 36 | ext2fs_free_mem(&fs->group_desc); |
37 | if (fs->orig_super) | 37 | ext2fs_free_block_bitmap(fs->block_map); |
38 | ext2fs_free_mem(&fs->orig_super); | 38 | ext2fs_free_inode_bitmap(fs->inode_map); |
39 | if (fs->group_desc) | 39 | |
40 | ext2fs_free_mem(&fs->group_desc); | 40 | ext2fs_badblocks_list_free(fs->badblocks); |
41 | if (fs->block_map) | ||
42 | ext2fs_free_block_bitmap(fs->block_map); | ||
43 | if (fs->inode_map) | ||
44 | ext2fs_free_inode_bitmap(fs->inode_map); | ||
45 | |||
46 | if (fs->badblocks) | ||
47 | ext2fs_badblocks_list_free(fs->badblocks); | ||
48 | fs->badblocks = 0; | 41 | fs->badblocks = 0; |
49 | 42 | ||
50 | if (fs->dblist) | 43 | ext2fs_free_dblist(fs->dblist); |
51 | ext2fs_free_dblist(fs->dblist); | ||
52 | 44 | ||
53 | if (fs->icache) | 45 | if (fs->icache) |
54 | ext2fs_free_inode_cache(fs->icache); | 46 | ext2fs_free_inode_cache(fs->icache); |
@@ -64,14 +56,8 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap) | |||
64 | return; | 56 | return; |
65 | 57 | ||
66 | bitmap->magic = 0; | 58 | bitmap->magic = 0; |
67 | if (bitmap->description) { | 59 | ext2fs_free_mem(&bitmap->description); |
68 | ext2fs_free_mem(&bitmap->description); | 60 | ext2fs_free_mem(&bitmap->bitmap); |
69 | bitmap->description = 0; | ||
70 | } | ||
71 | if (bitmap->bitmap) { | ||
72 | ext2fs_free_mem(&bitmap->bitmap); | ||
73 | bitmap->bitmap = 0; | ||
74 | } | ||
75 | ext2fs_free_mem(&bitmap); | 61 | ext2fs_free_mem(&bitmap); |
76 | } | 62 | } |
77 | 63 | ||
@@ -100,10 +86,8 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache) | |||
100 | { | 86 | { |
101 | if (--icache->refcount) | 87 | if (--icache->refcount) |
102 | return; | 88 | return; |
103 | if (icache->buffer) | 89 | ext2fs_free_mem(&icache->buffer); |
104 | ext2fs_free_mem(&icache->buffer); | 90 | ext2fs_free_mem(&icache->cache); |
105 | if (icache->cache) | ||
106 | ext2fs_free_mem(&icache->cache); | ||
107 | icache->buffer_blk = 0; | 91 | icache->buffer_blk = 0; |
108 | ext2fs_free_mem(&icache); | 92 | ext2fs_free_mem(&icache); |
109 | } | 93 | } |
@@ -113,12 +97,10 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache) | |||
113 | */ | 97 | */ |
114 | void ext2fs_u32_list_free(ext2_u32_list bb) | 98 | void ext2fs_u32_list_free(ext2_u32_list bb) |
115 | { | 99 | { |
116 | if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) | 100 | if (!bb || bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) |
117 | return; | 101 | return; |
118 | 102 | ||
119 | if (bb->list) | 103 | ext2fs_free_mem(&bb->list); |
120 | ext2fs_free_mem(&bb->list); | ||
121 | bb->list = 0; | ||
122 | ext2fs_free_mem(&bb); | 104 | ext2fs_free_mem(&bb); |
123 | } | 105 | } |
124 | 106 | ||
@@ -136,9 +118,7 @@ void ext2fs_free_dblist(ext2_dblist dblist) | |||
136 | if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) | 118 | if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) |
137 | return; | 119 | return; |
138 | 120 | ||
139 | if (dblist->list) | 121 | ext2fs_free_mem(&dblist->list); |
140 | ext2fs_free_mem(&dblist->list); | ||
141 | dblist->list = 0; | ||
142 | if (dblist->fs && dblist->fs->dblist == dblist) | 122 | if (dblist->fs && dblist->fs->dblist == dblist) |
143 | dblist->fs->dblist = 0; | 123 | dblist->fs->dblist = 0; |
144 | dblist->magic = 0; | 124 | dblist->magic = 0; |
diff --git a/e2fsprogs/ext2fs/get_pathname.c b/e2fsprogs/ext2fs/get_pathname.c index 594090da0..000479096 100644 --- a/e2fsprogs/ext2fs/get_pathname.c +++ b/e2fsprogs/ext2fs/get_pathname.c | |||
@@ -132,8 +132,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, | |||
132 | retval = 0; | 132 | retval = 0; |
133 | 133 | ||
134 | cleanup: | 134 | cleanup: |
135 | if (gp.name) | 135 | ext2fs_free_mem(&gp.name); |
136 | ext2fs_free_mem(&gp.name); | ||
137 | return retval; | 136 | return retval; |
138 | } | 137 | } |
139 | 138 | ||
diff --git a/e2fsprogs/ext2fs/icount.c b/e2fsprogs/ext2fs/icount.c index 01677775f..7ae2a5c0f 100644 --- a/e2fsprogs/ext2fs/icount.c +++ b/e2fsprogs/ext2fs/icount.c | |||
@@ -59,12 +59,9 @@ void ext2fs_free_icount(ext2_icount_t icount) | |||
59 | return; | 59 | return; |
60 | 60 | ||
61 | icount->magic = 0; | 61 | icount->magic = 0; |
62 | if (icount->list) | 62 | ext2fs_free_mem(&icount->list); |
63 | ext2fs_free_mem(&icount->list); | 63 | ext2fs_free_inode_bitmap(icount->single); |
64 | if (icount->single) | 64 | ext2fs_free_inode_bitmap(icount->multiple); |
65 | ext2fs_free_inode_bitmap(icount->single); | ||
66 | if (icount->multiple) | ||
67 | ext2fs_free_inode_bitmap(icount->multiple); | ||
68 | ext2fs_free_mem(&icount); | 65 | ext2fs_free_mem(&icount); |
69 | } | 66 | } |
70 | 67 | ||
diff --git a/e2fsprogs/ext2fs/imager.c b/e2fsprogs/ext2fs/imager.c index 00eb71723..ece66fc30 100644 --- a/e2fsprogs/ext2fs/imager.c +++ b/e2fsprogs/ext2fs/imager.c | |||
@@ -371,7 +371,6 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags) | |||
371 | 371 | ||
372 | retval = 0; | 372 | retval = 0; |
373 | errout: | 373 | errout: |
374 | if (buf) | 374 | free(buf); |
375 | free(buf); | ||
376 | return (retval); | 375 | return (retval); |
377 | } | 376 | } |
diff --git a/e2fsprogs/ext2fs/inode.c b/e2fsprogs/ext2fs/inode.c index e50bece40..4c386c77c 100644 --- a/e2fsprogs/ext2fs/inode.c +++ b/e2fsprogs/ext2fs/inode.c | |||
@@ -123,7 +123,7 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, | |||
123 | save_get_blocks = fs->get_blocks; | 123 | save_get_blocks = fs->get_blocks; |
124 | fs->get_blocks = 0; | 124 | fs->get_blocks = 0; |
125 | retval = ext2fs_read_bb_inode(fs, &fs->badblocks); | 125 | retval = ext2fs_read_bb_inode(fs, &fs->badblocks); |
126 | if (retval && fs->badblocks) { | 126 | if (retval) { |
127 | ext2fs_badblocks_list_free(fs->badblocks); | 127 | ext2fs_badblocks_list_free(fs->badblocks); |
128 | fs->badblocks = 0; | 128 | fs->badblocks = 0; |
129 | } | 129 | } |
diff --git a/e2fsprogs/ext2fs/irel_ma.c b/e2fsprogs/ext2fs/irel_ma.c index d9e73f73c..f4fe1e0f3 100644 --- a/e2fsprogs/ext2fs/irel_ma.c +++ b/e2fsprogs/ext2fs/irel_ma.c | |||
@@ -309,8 +309,7 @@ static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new) | |||
309 | return ENOENT; | 309 | return ENOENT; |
310 | 310 | ||
311 | ma->entries[(unsigned) new] = ma->entries[(unsigned) old]; | 311 | ma->entries[(unsigned) new] = ma->entries[(unsigned) old]; |
312 | if (ma->ref_entries[(unsigned) new].refs) | 312 | ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs); |
313 | ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs); | ||
314 | ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old]; | 313 | ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old]; |
315 | 314 | ||
316 | ma->entries[(unsigned) old].new = 0; | 315 | ma->entries[(unsigned) old].new = 0; |
@@ -332,8 +331,7 @@ static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old) | |||
332 | return ENOENT; | 331 | return ENOENT; |
333 | 332 | ||
334 | ma->entries[old].new = 0; | 333 | ma->entries[old].new = 0; |
335 | if (ma->ref_entries[(unsigned) old].refs) | 334 | ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs); |
336 | ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs); | ||
337 | ma->orig_map[ma->entries[(unsigned) old].orig] = 0; | 335 | ma->orig_map[ma->entries[(unsigned) old].orig] = 0; |
338 | 336 | ||
339 | ma->ref_entries[(unsigned) old].num = 0; | 337 | ma->ref_entries[(unsigned) old].num = 0; |
@@ -352,21 +350,17 @@ static errcode_t ima_free(ext2_irel irel) | |||
352 | ma = irel->priv_data; | 350 | ma = irel->priv_data; |
353 | 351 | ||
354 | if (ma) { | 352 | if (ma) { |
355 | if (ma->orig_map) | 353 | ext2fs_free_mem(&ma->orig_map); |
356 | ext2fs_free_mem(&ma->orig_map); | 354 | ext2fs_free_mem(&ma->entries); |
357 | if (ma->entries) | ||
358 | ext2fs_free_mem(&ma->entries); | ||
359 | if (ma->ref_entries) { | 355 | if (ma->ref_entries) { |
360 | for (ino = 0; ino <= ma->max_inode; ino++) { | 356 | for (ino = 0; ino <= ma->max_inode; ino++) { |
361 | if (ma->ref_entries[(unsigned) ino].refs) | 357 | ext2fs_free_mem(&ma->ref_entries[(unsigned) ino].refs); |
362 | ext2fs_free_mem(&ma->ref_entries[(unsigned) ino].refs); | ||
363 | } | 358 | } |
364 | ext2fs_free_mem(&ma->ref_entries); | 359 | ext2fs_free_mem(&ma->ref_entries); |
365 | } | 360 | } |
366 | ext2fs_free_mem(&ma); | 361 | ext2fs_free_mem(&ma); |
367 | } | 362 | } |
368 | if (irel->name) | 363 | ext2fs_free_mem(&irel->name); |
369 | ext2fs_free_mem(&irel->name); | ||
370 | ext2fs_free_mem(&irel); | 364 | ext2fs_free_mem(&irel); |
371 | return 0; | 365 | return 0; |
372 | } | 366 | } |
diff --git a/e2fsprogs/ext2fs/mkdir.c b/e2fsprogs/ext2fs/mkdir.c index bf46e5050..c3c03711c 100644 --- a/e2fsprogs/ext2fs/mkdir.c +++ b/e2fsprogs/ext2fs/mkdir.c | |||
@@ -133,8 +133,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, | |||
133 | ext2fs_inode_alloc_stats2(fs, ino, +1, 1); | 133 | ext2fs_inode_alloc_stats2(fs, ino, +1, 1); |
134 | 134 | ||
135 | cleanup: | 135 | cleanup: |
136 | if (block) | 136 | ext2fs_free_mem(&block); |
137 | ext2fs_free_mem(&block); | ||
138 | return retval; | 137 | return retval; |
139 | 138 | ||
140 | } | 139 | } |
diff --git a/e2fsprogs/ext2fs/namei.c b/e2fsprogs/ext2fs/namei.c index 6ce4bb363..2c372f4e2 100644 --- a/e2fsprogs/ext2fs/namei.c +++ b/e2fsprogs/ext2fs/namei.c | |||
@@ -61,8 +61,7 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir, | |||
61 | pathname = (char *)&(ei.i_block[0]); | 61 | pathname = (char *)&(ei.i_block[0]); |
62 | retval = open_namei(fs, root, dir, pathname, ei.i_size, 1, | 62 | retval = open_namei(fs, root, dir, pathname, ei.i_size, 1, |
63 | link_count, buf, res_inode); | 63 | link_count, buf, res_inode); |
64 | if (buffer) | 64 | ext2fs_free_mem(&buffer); |
65 | ext2fs_free_mem(&buffer); | ||
66 | return retval; | 65 | return retval; |
67 | } | 66 | } |
68 | 67 | ||
diff --git a/e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/ext2fs/rw_bitmaps.c index ae7b6e0cf..d5698a221 100644 --- a/e2fsprogs/ext2fs/rw_bitmaps.c +++ b/e2fsprogs/ext2fs/rw_bitmaps.c | |||
@@ -163,8 +163,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) | |||
163 | if (retval) | 163 | if (retval) |
164 | return retval; | 164 | return retval; |
165 | if (do_block) { | 165 | if (do_block) { |
166 | if (fs->block_map) | 166 | ext2fs_free_block_bitmap(fs->block_map); |
167 | ext2fs_free_block_bitmap(fs->block_map); | ||
168 | sprintf(buf, "block bitmap for %s", fs->device_name); | 167 | sprintf(buf, "block bitmap for %s", fs->device_name); |
169 | retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); | 168 | retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); |
170 | if (retval) | 169 | if (retval) |
@@ -172,8 +171,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) | |||
172 | block_bitmap = fs->block_map->bitmap; | 171 | block_bitmap = fs->block_map->bitmap; |
173 | } | 172 | } |
174 | if (do_inode) { | 173 | if (do_inode) { |
175 | if (fs->inode_map) | 174 | ext2fs_free_inode_bitmap(fs->inode_map); |
176 | ext2fs_free_inode_bitmap(fs->inode_map); | ||
177 | sprintf(buf, "inode bitmap for %s", fs->device_name); | 175 | sprintf(buf, "inode bitmap for %s", fs->device_name); |
178 | retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); | 176 | retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); |
179 | if (retval) | 177 | if (retval) |
@@ -247,14 +245,11 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) | |||
247 | cleanup: | 245 | cleanup: |
248 | if (do_block) { | 246 | if (do_block) { |
249 | ext2fs_free_mem(&fs->block_map); | 247 | ext2fs_free_mem(&fs->block_map); |
250 | fs->block_map = 0; | ||
251 | } | 248 | } |
252 | if (do_inode) { | 249 | if (do_inode) { |
253 | ext2fs_free_mem(&fs->inode_map); | 250 | ext2fs_free_mem(&fs->inode_map); |
254 | fs->inode_map = 0; | ||
255 | } | 251 | } |
256 | if (buf) | 252 | ext2fs_free_mem(&buf); |
257 | ext2fs_free_mem(&buf); | ||
258 | return retval; | 253 | return retval; |
259 | } | 254 | } |
260 | 255 | ||
diff --git a/e2fsprogs/ext2fs/test_io.c b/e2fsprogs/ext2fs/test_io.c index d4b36532f..45f9090cb 100644 --- a/e2fsprogs/ext2fs/test_io.c +++ b/e2fsprogs/ext2fs/test_io.c | |||
@@ -203,10 +203,8 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) | |||
203 | return 0; | 203 | return 0; |
204 | 204 | ||
205 | cleanup: | 205 | cleanup: |
206 | if (io) | 206 | ext2fs_free_mem(&io); |
207 | ext2fs_free_mem(&io); | 207 | ext2fs_free_mem(&data); |
208 | if (data) | ||
209 | ext2fs_free_mem(&data); | ||
210 | return retval; | 208 | return retval; |
211 | } | 209 | } |
212 | 210 | ||
@@ -229,8 +227,7 @@ static errcode_t test_close(io_channel channel) | |||
229 | fclose(data->outfile); | 227 | fclose(data->outfile); |
230 | 228 | ||
231 | ext2fs_free_mem(&channel->private_data); | 229 | ext2fs_free_mem(&channel->private_data); |
232 | if (channel->name) | 230 | ext2fs_free_mem(&channel->name); |
233 | ext2fs_free_mem(&channel->name); | ||
234 | ext2fs_free_mem(&channel); | 231 | ext2fs_free_mem(&channel); |
235 | return retval; | 232 | return retval; |
236 | } | 233 | } |
diff --git a/e2fsprogs/ext2fs/unix_io.c b/e2fsprogs/ext2fs/unix_io.c index 36b222577..7f57afddc 100644 --- a/e2fsprogs/ext2fs/unix_io.c +++ b/e2fsprogs/ext2fs/unix_io.c | |||
@@ -280,8 +280,7 @@ static void free_cache(struct unix_private_data *data) | |||
280 | cache->access_time = 0; | 280 | cache->access_time = 0; |
281 | cache->dirty = 0; | 281 | cache->dirty = 0; |
282 | cache->in_use = 0; | 282 | cache->in_use = 0; |
283 | if (cache->buf) | 283 | ext2fs_free_mem(&cache->buf); |
284 | ext2fs_free_mem(&cache->buf); | ||
285 | cache->buf = 0; | 284 | cache->buf = 0; |
286 | } | 285 | } |
287 | } | 286 | } |
@@ -461,8 +460,7 @@ cleanup: | |||
461 | free_cache(data); | 460 | free_cache(data); |
462 | ext2fs_free_mem(&data); | 461 | ext2fs_free_mem(&data); |
463 | } | 462 | } |
464 | if (io) | 463 | ext2fs_free_mem(&io); |
465 | ext2fs_free_mem(&io); | ||
466 | return retval; | 464 | return retval; |
467 | } | 465 | } |
468 | 466 | ||
@@ -487,8 +485,7 @@ static errcode_t unix_close(io_channel channel) | |||
487 | free_cache(data); | 485 | free_cache(data); |
488 | 486 | ||
489 | ext2fs_free_mem(&channel->private_data); | 487 | ext2fs_free_mem(&channel->private_data); |
490 | if (channel->name) | 488 | ext2fs_free_mem(&channel->name); |
491 | ext2fs_free_mem(&channel->name); | ||
492 | ext2fs_free_mem(&channel); | 489 | ext2fs_free_mem(&channel); |
493 | return retval; | 490 | return retval; |
494 | } | 491 | } |
diff --git a/editors/sed.c b/editors/sed.c index b08eae4dc..f58f442e8 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -556,10 +556,8 @@ static void add_cmd(char *cmdstr) | |||
556 | } | 556 | } |
557 | 557 | ||
558 | /* If we glued multiple lines together, free the memory. */ | 558 | /* If we glued multiple lines together, free the memory. */ |
559 | if(add_cmd_line) { | 559 | free(add_cmd_line); |
560 | free(add_cmd_line); | 560 | add_cmd_line=NULL; |
561 | add_cmd_line=NULL; | ||
562 | } | ||
563 | } | 561 | } |
564 | 562 | ||
565 | /* Append to a string, reallocating memory as necessary. */ | 563 | /* Append to a string, reallocating memory as necessary. */ |
diff --git a/modutils/insmod.c b/modutils/insmod.c index d5d58a191..d40012d70 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -4231,9 +4231,8 @@ out: | |||
4231 | #ifdef CONFIG_FEATURE_CLEAN_UP | 4231 | #ifdef CONFIG_FEATURE_CLEAN_UP |
4232 | if(fp) | 4232 | if(fp) |
4233 | fclose(fp); | 4233 | fclose(fp); |
4234 | if(tmp1) { | 4234 | free(tmp1); |
4235 | free(tmp1); | 4235 | if(!tmp1) { |
4236 | } else { | ||
4237 | free(m_name); | 4236 | free(m_name); |
4238 | } | 4237 | } |
4239 | free(m_filename); | 4238 | free(m_filename); |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 699fa7d06..156ceb7ab 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1356,16 +1356,15 @@ extern int ifupdown_main(int argc, char **argv) | |||
1356 | } else { | 1356 | } else { |
1357 | /* Remove an interface from the linked list */ | 1357 | /* Remove an interface from the linked list */ |
1358 | if (iface_state) { | 1358 | if (iface_state) { |
1359 | /* This needs to be done better */ | 1359 | const llist_t *link = iface_state->link; |
1360 | free(iface_state->data); | 1360 | free(iface_state->data); |
1361 | free(iface_state->link); | 1361 | iface_state->data = NULL; |
1362 | if (iface_state->link) { | 1362 | iface_state->link = NULL; |
1363 | iface_state->data = iface_state->link->data; | 1363 | if (link) { |
1364 | iface_state->link = iface_state->link->link; | 1364 | iface_state->data = link->data; |
1365 | } else { | 1365 | iface_state->link = link->link; |
1366 | iface_state->data = NULL; | ||
1367 | iface_state->link = NULL; | ||
1368 | } | 1366 | } |
1367 | free(link); | ||
1369 | } | 1368 | } |
1370 | } | 1369 | } |
1371 | } | 1370 | } |
diff --git a/networking/inetd.c b/networking/inetd.c index 9f6acdb98..931052a5a 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -413,8 +413,7 @@ static void freeconfig (servtab_t *cp) | |||
413 | free (cp->se_group); | 413 | free (cp->se_group); |
414 | free (cp->se_server); | 414 | free (cp->se_server); |
415 | for (i = 0; i < MAXARGV; i++) | 415 | for (i = 0; i < MAXARGV; i++) |
416 | if (cp->se_argv[i]) | 416 | free (cp->se_argv[i]); |
417 | free (cp->se_argv[i]); | ||
418 | } | 417 | } |
419 | 418 | ||
420 | static int bump_nofile (void) | 419 | static int bump_nofile (void) |
diff --git a/networking/traceroute.c b/networking/traceroute.c index e6011cc47..22d27f240 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -902,10 +902,8 @@ gethostinfo(const char *host) | |||
902 | static void | 902 | static void |
903 | freehostinfo(struct hostinfo *hi) | 903 | freehostinfo(struct hostinfo *hi) |
904 | { | 904 | { |
905 | if (hi->name != NULL) { | 905 | free(hi->name); |
906 | free(hi->name); | 906 | hi->name = NULL; |
907 | hi->name = NULL; | ||
908 | } | ||
909 | free((char *)hi->addrs); | 907 | free((char *)hi->addrs); |
910 | free((char *)hi); | 908 | free((char *)hi); |
911 | } | 909 | } |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index e035bd4c2..7e7f94a5a 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -217,7 +217,7 @@ int main(int argc, char *argv[]) | |||
217 | case 'c': | 217 | case 'c': |
218 | if (no_clientid) show_usage(); | 218 | if (no_clientid) show_usage(); |
219 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 219 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
220 | if (client_config.clientid) free(client_config.clientid); | 220 | free(client_config.clientid); |
221 | client_config.clientid = xmalloc(len + 2); | 221 | client_config.clientid = xmalloc(len + 2); |
222 | client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; | 222 | client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; |
223 | client_config.clientid[OPT_LEN] = len; | 223 | client_config.clientid[OPT_LEN] = len; |
@@ -230,7 +230,7 @@ int main(int argc, char *argv[]) | |||
230 | break; | 230 | break; |
231 | case 'V': | 231 | case 'V': |
232 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 232 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
233 | if (client_config.vendorclass) free(client_config.vendorclass); | 233 | free(client_config.vendorclass); |
234 | client_config.vendorclass = xmalloc(len + 2); | 234 | client_config.vendorclass = xmalloc(len + 2); |
235 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; | 235 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; |
236 | client_config.vendorclass[OPT_LEN] = len; | 236 | client_config.vendorclass[OPT_LEN] = len; |
@@ -245,7 +245,7 @@ int main(int argc, char *argv[]) | |||
245 | case 'h': | 245 | case 'h': |
246 | case 'H': | 246 | case 'H': |
247 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 247 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
248 | if (client_config.hostname) free(client_config.hostname); | 248 | free(client_config.hostname); |
249 | client_config.hostname = xmalloc(len + 2); | 249 | client_config.hostname = xmalloc(len + 2); |
250 | client_config.hostname[OPT_CODE] = DHCP_HOST_NAME; | 250 | client_config.hostname[OPT_CODE] = DHCP_HOST_NAME; |
251 | client_config.hostname[OPT_LEN] = len; | 251 | client_config.hostname[OPT_LEN] = len; |
@@ -253,7 +253,7 @@ int main(int argc, char *argv[]) | |||
253 | break; | 253 | break; |
254 | case 'F': | 254 | case 'F': |
255 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); | 255 | len = strlen(optarg) > 255 ? 255 : strlen(optarg); |
256 | if (client_config.fqdn) free(client_config.fqdn); | 256 | free(client_config.fqdn); |
257 | client_config.fqdn = xmalloc(len + 5); | 257 | client_config.fqdn = xmalloc(len + 5); |
258 | client_config.fqdn[OPT_CODE] = DHCP_FQDN; | 258 | client_config.fqdn[OPT_CODE] = DHCP_FQDN; |
259 | client_config.fqdn[OPT_LEN] = len + 3; | 259 | client_config.fqdn[OPT_LEN] = len + 3; |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 01534f2bb..416b1feb0 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -62,7 +62,7 @@ static int read_str(const char *line, void *arg) | |||
62 | { | 62 | { |
63 | char **dest = arg; | 63 | char **dest = arg; |
64 | 64 | ||
65 | if (*dest) free(*dest); | 65 | free(*dest); |
66 | *dest = strdup(line); | 66 | *dest = strdup(line); |
67 | 67 | ||
68 | return 1; | 68 | return 1; |
diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c index c87124584..30517020d 100644 --- a/scripts/config/confdata.c +++ b/scripts/config/confdata.c | |||
@@ -102,8 +102,7 @@ int conf_read(const char *name) | |||
102 | case S_INT: | 102 | case S_INT: |
103 | case S_HEX: | 103 | case S_HEX: |
104 | case S_STRING: | 104 | case S_STRING: |
105 | if (sym->user.val) | 105 | free(sym->user.val); |
106 | free(sym->user.val); | ||
107 | default: | 106 | default: |
108 | sym->user.val = NULL; | 107 | sym->user.val = NULL; |
109 | sym->user.tri = no; | 108 | sym->user.tri = no; |