aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-07 22:07:44 +0200
committerMax Kellermann <max@duempel.org>2008-10-07 22:07:44 +0200
commit8be60263361fa00e9ea332e64db8122455d234d9 (patch)
treef3e140ec48a9db851a8148a2f768128f930f9805 /src/directory.c
parent45334a23e18da4928f53ccb9ecc7afd5f7eca28e (diff)
downloadmpd-8be60263361fa00e9ea332e64db8122455d234d9.tar.gz
mpd-8be60263361fa00e9ea332e64db8122455d234d9.tar.xz
mpd-8be60263361fa00e9ea332e64db8122455d234d9.zip
dbUtils/directory: traverseAllIn forEachSong returns -1 on error
Being consistent with most UNIX functions...
Diffstat (limited to 'src/directory.c')
-rw-r--r--src/directory.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/directory.c b/src/directory.c
index e38a904f0..2c18c6954 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -974,14 +974,11 @@ static int traverseAllInSubDirectory(Directory * directory,
void *data)
{
struct dirvec *dv = &directory->children;
- int errFlag = 0;
+ int err = 0;
size_t j;
- if (forEachDir) {
- errFlag = forEachDir(directory, data);
- if (errFlag)
- return errFlag;
- }
+ if (forEachDir && (err = forEachDir(directory, data)) < 0)
+ return err;
if (forEachSong) {
int i;
@@ -990,16 +987,16 @@ static int traverseAllInSubDirectory(Directory * directory,
for (i = sv->nr; --i >= 0; ) {
Song *song = *sp++;
- if ((errFlag = forEachSong(song, data)))
- return errFlag;
+ if ((err = forEachSong(song, data)) < 0)
+ return err;
}
}
- for (j = 0; !errFlag && j < dv->nr; ++j)
- errFlag = traverseAllInSubDirectory(dv->base[j], forEachSong,
- forEachDir, data);
+ for (j = 0; err >= 0 && j < dv->nr; ++j)
+ err = traverseAllInSubDirectory(dv->base[j], forEachSong,
+ forEachDir, data);
- return errFlag;
+ return err;
}
int traverseAllIn(const char *name,