mkfs.cramfs: remove dead code [coverity scan]
There two possible ways, print error and exit on too long names or truncate the filename -- but it's impossible to do both in the same code :-) It seems that code already assumes warning on long names, so let's remove errx() and keep the behavior in dependence on -E. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
1e9d849b8d
commit
101c80f316
|
@ -319,12 +319,11 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
|
|||
}
|
||||
}
|
||||
namelen = strlen(dirent->d_name);
|
||||
if (namelen > MAX_INPUT_NAMELEN)
|
||||
errx(MKFS_EX_ERROR,
|
||||
_("Very long (%zu bytes) filename `%s' found.\n"
|
||||
" Please increase MAX_INPUT_NAMELEN in "
|
||||
"mkcramfs.c and recompile. Exiting."),
|
||||
namelen, dirent->d_name);
|
||||
if (namelen > MAX_INPUT_NAMELEN) {
|
||||
namelen = MAX_INPUT_NAMELEN;
|
||||
warn_namelen = 1;
|
||||
}
|
||||
|
||||
memcpy(endpath, dirent->d_name, namelen + 1);
|
||||
|
||||
if (lstat(path, &st) < 0) {
|
||||
|
@ -333,15 +332,7 @@ static unsigned int parse_directory(struct entry *root_entry, const char *name,
|
|||
continue;
|
||||
}
|
||||
entry = xcalloc(1, sizeof(struct entry));
|
||||
entry->name = (unsigned char *)xstrdup(dirent->d_name);
|
||||
if (namelen > 255) {
|
||||
/* Can't happen when reading from ext2fs. */
|
||||
|
||||
/* TODO: we ought to avoid chopping in half
|
||||
multi-byte UTF8 characters. */
|
||||
entry->name[namelen = 255] = '\0';
|
||||
warn_namelen = 1;
|
||||
}
|
||||
entry->name = (unsigned char *)xstrndup(dirent->d_name, namelen);
|
||||
entry->mode = st.st_mode;
|
||||
entry->size = st.st_size;
|
||||
entry->uid = st.st_uid;
|
||||
|
@ -891,7 +882,7 @@ int main(int argc, char **argv)
|
|||
if (warn_namelen)
|
||||
/* Can't happen when reading from ext2fs. */
|
||||
/* Bytes, not chars: think UTF8. */
|
||||
warnx(_("warning: filenames truncated to 255 bytes."));
|
||||
warnx(_("warning: filenames truncated to %u bytes."), MAX_INPUT_NAMELEN);
|
||||
if (warn_skip)
|
||||
warnx(_("warning: files were skipped due to errors."));
|
||||
if (warn_size)
|
||||
|
|
Loading…
Reference in New Issue