util.c, rmrf(): only create string when needed

The entry's name is only used when not "." or ".." so only print the
string then.

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Olivier Brunel 2012-01-09 21:37:31 +01:00 committed by Dan McGee
parent c77cec2ffc
commit 1b50223f82
2 changed files with 6 additions and 6 deletions

View File

@ -381,7 +381,6 @@ int _alpm_rmrf(const char *path)
int errflag = 0;
struct dirent *dp;
DIR *dirp;
char name[PATH_MAX];
struct stat st;
if(_alpm_lstat(path, &st) == 0) {
@ -401,9 +400,10 @@ int _alpm_rmrf(const char *path)
return 1;
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if(dp->d_ino) {
sprintf(name, "%s/%s", path, dp->d_name);
if(dp->d_name) {
if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) {
char name[PATH_MAX];
sprintf(name, "%s/%s", path, dp->d_name);
errflag += _alpm_rmrf(name);
}
}

View File

@ -192,10 +192,10 @@ int rmrf(const char *path)
return 1;
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if(dp->d_ino) {
char name[PATH_MAX];
sprintf(name, "%s/%s", path, dp->d_name);
if(dp->d_name) {
if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) {
char name[PATH_MAX];
snprintf(name, PATH_MAX, "%s/%s", path, dp->d_name);
errflag += rmrf(name);
}
}