removal of possible NULL argument
This commit is contained in:
6
dir.c
6
dir.c
@@ -28,13 +28,14 @@ unsigned long get_dir_size(char *path){
|
|||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
unsigned long entry_count = 0;
|
unsigned long entry_count = 0;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
if (dir && file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
if (dir) {
|
||||||
|
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
||||||
while ((entry=readdir(dir))) {
|
while ((entry=readdir(dir))) {
|
||||||
entry_count++;
|
entry_count++;
|
||||||
}
|
}
|
||||||
/* removes files "." and ".." */
|
/* removes files "." and ".." */
|
||||||
entry_count -= 2;
|
entry_count -= 2;
|
||||||
} else if (dir) {
|
} else {
|
||||||
while ((entry=readdir(dir))) {
|
while ((entry=readdir(dir))) {
|
||||||
if (entry->d_name[0] != '.') {
|
if (entry->d_name[0] != '.') {
|
||||||
entry_count++;
|
entry_count++;
|
||||||
@@ -42,6 +43,7 @@ unsigned long get_dir_size(char *path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
}
|
||||||
return entry_count;
|
return entry_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user