The following commit has been merged in the master branch:
commit e983b8522fc2be93c3b31e38ddd5ce94448739c1
Author: Guillem Jover <[email protected]>
Date: Wed Nov 3 10:45:08 2010 +0100
Use new enum for dependency check result values
Instead of cryptic literal integers use named enums.
diff --git a/src/main.h b/src/main.h
index 5a35587..cb87420 100644
--- a/src/main.h
+++ b/src/main.h
@@ -185,9 +185,16 @@ void process_queue(void);
void packages(const char *const *argv);
void removal_bulk(struct pkginfo *pkg);
int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in);
-int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
- struct varbuf *aemsgs);
-int breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
+
+enum dep_check {
+ dep_check_halt = 0,
+ dep_check_defer = 1,
+ dep_check_ok = 2,
+};
+
+enum dep_check dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
+ struct varbuf *aemsgs);
+enum dep_check breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs);
void deferred_remove(struct pkginfo *pkg);
void deferred_configure(struct pkginfo *pkg);
diff --git a/src/packages.c b/src/packages.c
index 1bb5f8a..416fe70 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -440,11 +440,11 @@ unsuitable:
return thisf;
}
-static void breaks_check_one(struct varbuf *aemsgs, int *ok,
- struct deppossi *breaks,
- struct pkginfo *broken,
- struct pkginfo *breaker,
- struct pkginfo *virtbroken) {
+static void
+breaks_check_one(struct varbuf *aemsgs, enum dep_check *ok,
+ struct deppossi *breaks, struct pkginfo *broken,
+ struct pkginfo *breaker, struct pkginfo *virtbroken)
+{
struct varbuf depmsg = VARBUF_INIT;
debug(dbg_depcondetail, " checking breaker %s virtbroken %s",
@@ -478,13 +478,14 @@ static void breaks_check_one(struct varbuf *aemsgs, int
*ok,
if (fc_dependsversion) return;
}
if (force_breaks(breaks)) return;
- *ok= 0;
+ *ok = dep_check_halt;
}
-static void breaks_check_target(struct varbuf *aemsgs, int *ok,
- struct pkginfo *broken,
- struct pkginfo *target,
- struct pkginfo *virtbroken) {
+static void
+breaks_check_target(struct varbuf *aemsgs, enum dep_check *ok,
+ struct pkginfo *broken, struct pkginfo *target,
+ struct pkginfo *virtbroken)
+{
struct deppossi *possi;
for (possi = target->installed.depended; possi; possi = possi->rev_next) {
@@ -494,10 +495,12 @@ static void breaks_check_target(struct varbuf *aemsgs,
int *ok,
}
}
-int breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs) {
+enum dep_check
+breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs)
+{
struct dependency *dep;
struct pkginfo *virtbroken;
- int ok= 2;
+ enum dep_check ok = dep_check_ok;
debug(dbg_depcon, " checking Breaks");
@@ -515,10 +518,12 @@ int breakses_ok(struct pkginfo *pkg, struct varbuf
*aemsgs) {
/*
* Checks [Pre]-Depends only.
*/
-int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
- struct varbuf *aemsgs) {
+enum dep_check
+dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
+ struct varbuf *aemsgs)
+{
/* Valid values: 2 = ok, 1 = defer, 0 = halt. */
- int ok;
+ enum dep_check ok;
/* Valid values: 0 = none, 1 = defer, 2 = withwarning, 3 = ok. */
int found, thisf;
int interestingwarnings;
@@ -529,7 +534,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo
*removing,
struct pkginfo *possfixbytrig, *canfixbytrig;
interestingwarnings= 0;
- ok = 2;
+ ok = dep_check_ok;
debug(dbg_depcon,"checking dependencies of %s (- %s)",
pkg->name, removing ? removing->name : "<none>");
@@ -576,7 +581,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo
*removing,
switch (found) {
case 0:
anycannotfixbytrig = true;
- ok= 0;
+ ok = dep_check_halt;
case 2:
varbufaddstr(aemsgs, " ");
varbufaddstr(aemsgs, pkg->name);
@@ -597,7 +602,8 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo
*removing,
canfixbytrig = possfixbytrig;
else
anycannotfixbytrig = true;
- if (ok>1) ok= 1;
+ if (ok > dep_check_defer)
+ ok = dep_check_defer;
break;
case 3:
break;
@@ -605,8 +611,9 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo
*removing,
internerr("unknown value for found '%d'", found);
}
}
- if (ok == 0 && (pkg->clientdata && pkg->clientdata->istobe == itb_remove))
- ok= 1;
+ if (ok == dep_check_halt &&
+ (pkg->clientdata && pkg->clientdata->istobe == itb_remove))
+ ok = dep_check_defer;
if (!anycannotfixbytrig && canfixbytrig)
progress_bytrigproc = canfixbytrig;
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]