pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools
Log | Files | Refs | README | LICENSE

commit 87d9adfc6d47bad28842ed735a7a2efc104b417e
parent 299886a34bad4edbf40039b916b265ec679524d4
Author: sin <sin@2f30.org>
Date:   Wed,  2 Jul 2014 11:13:33 +0100

No need to traverse the list of packages when removing a db entry

Don't guard against programmer's mistakes.

Diffstat:
Mdb.c | 24+++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/db.c b/db.c @@ -109,22 +109,16 @@ db_add(struct db *db, struct pkg *pkg) int db_rm(struct db *db, struct pkg *pkg) { - struct pkg *tmp; - - TAILQ_FOREACH(tmp, &db->pkg_rm_head, entry) { - if (strcmp(tmp->name, pkg->name) == 0) { - if (vflag == 1) - printf("removing %s\n", pkg->path); - if (remove(pkg->path) < 0) { - weprintf("remove %s:", pkg->path); - return -1; - } - sync(); - return 0; - } + (void) db; + + if (vflag == 1) + printf("removing %s\n", pkg->path); + if (remove(pkg->path) < 0) { + weprintf("remove %s:", pkg->path); + return -1; } - weprintf("internal error: package not found on rm list"); - return -1; + sync(); + return 0; } int