From cbe9c23b7e65da20a9aec8b8fecc1604cbddd53d Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Tue, 25 Sep 2012 07:25:46 +0900 Subject: [PATCH] Fix build failure on Clang. --- libarchive/archive_write_set_format_mtree.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index 63d18460f..d8a0433bd 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -1758,14 +1758,11 @@ static int mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file, struct archive_entry *entry) { - struct mtree_writer *mtree; const char *pathname; char *p, *dirname, *slash; size_t len; int ret = ARCHIVE_OK; - mtree = (struct mtree_writer *)a->format_data; - archive_strcpy(&file->pathname, archive_entry_pathname(entry)); #if defined(_WIN32) || defined(__CYGWIN__) /* @@ -1791,6 +1788,8 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file, } } } +#else + (void)a; /* UNUSED */ #endif pathname = file->pathname.s; if (strcmp(pathname, ".") == 0) { @@ -2051,7 +2050,8 @@ mtree_entry_tree(struct archive_write *a, struct mtree_entry *file) const char *fn, *p; int l, r; - if (strcmp(file->pathname.s, ".") == 0) { + if (file->parentdir.length == 0 && file->basename.length == 1 && + file->basename.s[0] == '.') { file->parent = file; if (mtree->root != NULL) { np = mtree->root; @@ -2065,10 +2065,15 @@ mtree_entry_tree(struct archive_write *a, struct mtree_entry *file) return (ARCHIVE_OK); } - if (file->parentdir.length > 0) - fn = p = file->parentdir.s; - else - fn = p = ""; + if (file->parentdir.length == 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Internal programing error " + "in generating canonical name for %s", + file->pathname.s); + return (ARCHIVE_FAILED); + } + + fn = p = file->parentdir.s; /* * If the path of the parent directory of `file' entry is -- 2.47.3