diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-11 19:49:14 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-11 23:34:36 -0700 |
commit | 6e2b0ca9edaed200f250ef487701ad161aa4a168 (patch) | |
tree | fda140c473d960546bc8123be4b85e72fbe9b1b8 /src/directory_save.c | |
parent | e71207440ebdf492e00fd5ac73b0833c82366ac6 (diff) | |
download | mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.tar.gz mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.tar.xz mpd-6e2b0ca9edaed200f250ef487701ad161aa4a168.zip |
directory: don't use identical struct and variable names
Duplicated tokens in close proximity takes too long for my head
to parse; and "dir" is an easy and common abbreviation for
"directory".
Diffstat (limited to '')
-rw-r--r-- | src/directory_save.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/directory_save.c b/src/directory_save.c index 76eace90b..c39ece58a 100644 --- a/src/directory_save.c +++ b/src/directory_save.c @@ -40,14 +40,14 @@ static int directory_song_write(struct mpd_song *song, void *data) } /* TODO error checking */ -int directory_save(int fd, struct directory * directory) +int directory_save(int fd, struct directory *dir) { - struct dirvec *children = &directory->children; + struct dirvec *children = &dir->children; size_t i; - if (!isRootDirectory(directory->path) && + if (!isRootDirectory(dir->path) && fdprintf(fd, DIRECTORY_BEGIN "%s\n", - directory_get_path(directory)) < 0) + directory_get_path(dir)) < 0) return -1; for (i = 0; i < children->nr; ++i) { @@ -63,21 +63,21 @@ int directory_save(int fd, struct directory * directory) if (fdprintf(fd, SONG_BEGIN "\n") < 0) return -1; - if (songvec_for_each(&directory->songs, + if (songvec_for_each(&dir->songs, directory_song_write, (void *)(size_t)fd) < 0) return -1; if (fdprintf(fd, SONG_END "\n") < 0) return -1; - if (!isRootDirectory(directory->path) && + if (!isRootDirectory(dir->path) && fdprintf(fd, DIRECTORY_END "%s\n", - directory_get_path(directory)) < 0) + directory_get_path(dir)) < 0) return -1; return 0; } -void directory_load(FILE * fp, struct directory * directory) +void directory_load(FILE * fp, struct directory *dir) { char buffer[MPD_PATH_MAX * 2]; int bufferSize = MPD_PATH_MAX * 2; @@ -100,19 +100,19 @@ void directory_load(FILE * fp, struct directory * directory) if (prefixcmp(buffer, DIRECTORY_BEGIN)) FATAL("Error reading db at line: %s\n", buffer); name = &(buffer[strlen(DIRECTORY_BEGIN)]); - if (prefixcmp(name, directory->path) != 0) + if (prefixcmp(name, dir->path) != 0) FATAL("Wrong path in database: '%s' in '%s'\n", - name, directory->path); + name, dir->path); - if ((subdir = directory_get_child(directory, name))) { - assert(subdir->parent == directory); + if ((subdir = directory_get_child(dir, name))) { + assert(subdir->parent == dir); } else { - subdir = directory_new(name, directory); - dirvec_add(&directory->children, subdir); + subdir = directory_new(name, dir); + dirvec_add(&dir->children, subdir); } directory_load(fp, subdir); } else if (!prefixcmp(buffer, SONG_BEGIN)) { - readSongInfoIntoList(fp, directory); + readSongInfoIntoList(fp, dir); } else { FATAL("Unknown line in db: %s\n", buffer); } |