Stefan Behrens
2013-Apr-23 09:25 UTC
[PATCH] Btrfs-progs: btrfs-send: free used memory and close fds
Not important at all since exit() is called afterwards and this is not part of the library. It just makes valgrind happy and thus allows to search for real flaws. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> --- cmds-send.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index adfb67d..72804a9 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -479,6 +479,13 @@ int cmd_send_start(int argc, char **argv) add_clone_source(&send, root_id); subvol_uuid_search_finit(&send.sus); free(subvol); + subvol = NULL; + if (send.mnt_fd >= 0) { + close(send.mnt_fd); + send.mnt_fd = -1; + } + free(send.root_path); + send.root_path = NULL; full_send = 0; break; case ''f'': @@ -487,7 +494,8 @@ int cmd_send_start(int argc, char **argv) case ''p'': if (snapshot_parent) { fprintf(stderr, "ERROR: you cannot have more than one parent (-p)\n"); - return 1; + ret = 1; + goto out; } snapshot_parent = realpath(optarg, NULL); if (!snapshot_parent) { @@ -501,17 +509,20 @@ int cmd_send_start(int argc, char **argv) case ''i'': fprintf(stderr, "ERROR: -i was removed, use -c instead\n"); - return 1; + ret = 1; + goto out; case ''?'': default: fprintf(stderr, "ERROR: send args invalid.\n"); - return 1; + ret = 1; + goto out; } } if (optind == argc) { fprintf(stderr, "ERROR: send needs path to snapshot\n"); - return 1; + ret = 1; + goto out; } if (outname != NULL) { @@ -528,7 +539,8 @@ int cmd_send_start(int argc, char **argv) fprintf(stderr, "ERROR: not dumping send stream into a terminal, " "redirect it into a file\n"); - return 1; + ret = 1; + goto out; } /* use first send subvol to determine mount_root */ @@ -559,6 +571,7 @@ int cmd_send_start(int argc, char **argv) } for (i = optind; i < argc; i++) { + free(subvol); subvol = realpath(argv[i], NULL); if (!subvol) { ret = -errno; @@ -590,13 +603,13 @@ int cmd_send_start(int argc, char **argv) subvol); goto out; } - free(subvol); } for (i = optind; i < argc; i++) { int is_first_subvol; int is_last_subvol; + free(subvol); subvol = argv[i]; fprintf(stderr, "At subvol %s\n", subvol); @@ -655,14 +668,17 @@ int cmd_send_start(int argc, char **argv) parent_root_id = 0; full_send = 0; - free(subvol); } ret = 0; out: + free(subvol); + free(snapshot_parent); + free(send.clone_sources); if (send.mnt_fd >= 0) close(send.mnt_fd); + free(send.root_path); subvol_uuid_search_finit(&send.sus); return ret; } -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Stefan Behrens
2013-Apr-23 09:25 UTC
[PATCH] Btrfs-progs: in btrfs-debug-tree, print -1 in key for (u64)-1
For the objectid and offset field of a key, print -1 instead of the decimal representation of 0xffffffffffffffff. At least for me it is more readable like this. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> --- print-tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/print-tree.c b/print-tree.c index 49c8384..aae47a9 100644 --- a/print-tree.c +++ b/print-tree.c @@ -585,6 +585,9 @@ static void print_objectid(u64 objectid, u8 type) case BTRFS_MULTIPLE_OBJECTIDS: printf("MULTIPLE"); break; + case (u64)-1: + printf("-1"); + break; case BTRFS_FIRST_CHUNK_TREE_OBJECTID: if (type == BTRFS_CHUNK_ITEM_KEY) { printf("FIRST_CHUNK_TREE"); @@ -614,7 +617,10 @@ void btrfs_print_key(struct btrfs_disk_key *disk_key) (unsigned long long)(offset & ((1ll << 48) - 1))); break; default: - printf(" %llu)", (unsigned long long)offset); + if (offset == (u64)-1) + printf(" -1)"); + else + printf(" %llu)", (unsigned long long)offset); break; } } -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html