add_files_recursive: Use consistent naming for array and count variables.

Previously we had an array named "namelist" and its count named
"num_entries". We now use an array name of "fs_entries" and a count
named "num_fs_entries" to try to preserve sanity.
This commit is contained in:
Carl Worth 2010-01-05 16:15:43 -08:00
parent 2c4555f1a5
commit 6f05dd8a8c

View file

@ -149,8 +149,8 @@ add_files_recursive (notmuch_database_t *notmuch,
time_t fs_mtime, db_mtime; time_t fs_mtime, db_mtime;
notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS; notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS;
notmuch_message_t *message = NULL; notmuch_message_t *message = NULL;
struct dirent **namelist = NULL; struct dirent **fs_entries = NULL;
int num_entries; int num_fs_entries;
notmuch_directory_t *directory; notmuch_directory_t *directory;
struct stat st; struct stat st;
@ -170,9 +170,9 @@ add_files_recursive (notmuch_database_t *notmuch,
directory = notmuch_database_get_directory (notmuch, path); directory = notmuch_database_get_directory (notmuch, path);
db_mtime = notmuch_directory_get_mtime (directory); db_mtime = notmuch_directory_get_mtime (directory);
num_entries = scandir (path, &namelist, 0, ino_cmp); num_fs_entries = scandir (path, &fs_entries, 0, ino_cmp);
if (num_entries == -1) { if (num_fs_entries == -1) {
fprintf (stderr, "Error opening directory %s: %s\n", fprintf (stderr, "Error opening directory %s: %s\n",
path, strerror (errno)); path, strerror (errno));
ret = NOTMUCH_STATUS_FILE_ERROR; ret = NOTMUCH_STATUS_FILE_ERROR;
@ -182,10 +182,10 @@ add_files_recursive (notmuch_database_t *notmuch,
int i=0; int i=0;
while (!interrupted) { while (!interrupted) {
if (i == num_entries) if (i == num_fs_entries)
break; break;
entry= namelist[i++]; entry = fs_entries[i++];
/* If this directory hasn't been modified since the last /* If this directory hasn't been modified since the last
* add_files, then we only need to look further for * add_files, then we only need to look further for
@ -202,7 +202,7 @@ add_files_recursive (notmuch_database_t *notmuch,
strcmp (entry->d_name, "..") == 0 || strcmp (entry->d_name, "..") == 0 ||
(entry->d_type == DT_DIR && (entry->d_type == DT_DIR &&
(strcmp (entry->d_name, "tmp") == 0) && (strcmp (entry->d_name, "tmp") == 0) &&
is_maildir (namelist, num_entries)) || is_maildir (fs_entries, num_fs_entries)) ||
strcmp (entry->d_name, ".notmuch") ==0) strcmp (entry->d_name, ".notmuch") ==0)
{ {
continue; continue;
@ -291,8 +291,8 @@ add_files_recursive (notmuch_database_t *notmuch,
free (entry); free (entry);
if (dir) if (dir)
closedir (dir); closedir (dir);
if (namelist) if (fs_entries)
free (namelist); free (fs_entries);
return ret; return ret;
} }
@ -358,21 +358,21 @@ count_files (const char *path, int *count)
struct dirent *entry = NULL; struct dirent *entry = NULL;
char *next; char *next;
struct stat st; struct stat st;
struct dirent **namelist = NULL; struct dirent **fs_entries = NULL;
int n_entries = scandir (path, &namelist, 0, ino_cmp); int num_fs_entries = scandir (path, &fs_entries, 0, ino_cmp);
int i = 0; int i = 0;
if (n_entries == -1) { if (num_fs_entries == -1) {
fprintf (stderr, "Warning: failed to open directory %s: %s\n", fprintf (stderr, "Warning: failed to open directory %s: %s\n",
path, strerror (errno)); path, strerror (errno));
goto DONE; goto DONE;
} }
while (!interrupted) { while (!interrupted) {
if (i == n_entries) if (i == num_fs_entries)
break; break;
entry= namelist[i++]; entry = fs_entries[i++];
/* Ignore special directories to avoid infinite recursion. /* Ignore special directories to avoid infinite recursion.
* Also ignore the .notmuch directory. * Also ignore the .notmuch directory.
@ -411,8 +411,8 @@ count_files (const char *path, int *count)
DONE: DONE:
if (entry) if (entry)
free (entry); free (entry);
if (namelist) if (fs_entries)
free (namelist); free (fs_entries);
} }
int int