diff options
-rw-r--r-- | opkg-opk/dirent.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/opkg-opk/dirent.c b/opkg-opk/dirent.c index 575e834..0080d44 100644 --- a/opkg-opk/dirent.c +++ b/opkg-opk/dirent.c @@ -32,6 +32,7 @@ _opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, int is_dir, size_t len; char **buf; int sep; + int ret; len = strlen(dirent->name); if ((*name_len > 0 || is_dir) && *name_len + len + 1 <= *name_buf_len) { @@ -60,7 +61,7 @@ _opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, int is_dir, sep = 0; } else { /* Both buffers full. */ - return OPKG_OPK_ERROR; + return OPKG_OPK_END; } if (*buf == NULL) { /* Caller provided a NULL buffer pointer. */ @@ -68,11 +69,12 @@ _opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, int is_dir, } /* Recurse. */ - if (dirent->parent != NULL && - _opkg_opk_dirent_name_prefix(dirent->parent, is_dir, - name_buf, name_buf_len, pref_buf, pref_buf_len, - name_len, pref_len) == OPKG_OPK_ERROR) { - return OPKG_OPK_ERROR; + if (dirent->parent != NULL && (ret = + _opkg_opk_dirent_name_prefix(dirent->parent, + is_dir, name_buf, name_buf_len, + pref_buf, pref_buf_len, name_len, + pref_len)) != OPKG_OPK_OK) { + return ret; } /* Copy node name and possibly separator suffix. */ @@ -95,16 +97,17 @@ opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, int is_dir, size_t pref_len = 0; char *name = name_buf; char *pref = pref_buf; + int ret; /* NUL bytes */ --name_buf_len; --pref_buf_len; - if (_opkg_opk_dirent_name_prefix(dirent, is_dir, - &name_buf, &name_buf_len, - &pref_buf, &pref_buf_len, - &name_len, &pref_len) == OPKG_OPK_ERROR) { - return OPKG_OPK_ERROR; + if ((ret = _opkg_opk_dirent_name_prefix(dirent, is_dir, + &name_buf, &name_buf_len, + &pref_buf, &pref_buf_len, + &name_len, &pref_len)) != OPKG_OPK_OK) { + return ret; } name[name_len] = '\0'; |