The following commit has been merged in the master branch:
commit 95a4b0b31be033488de1786fa163bce7f79b111d
Author: Guillem Jover <[email protected]>
Date: Tue Sep 29 14:23:10 2009 +0200
Switch to use stdbool were appropriate
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 124fd79..5536a50 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -25,6 +25,7 @@
#include <dpkg/i18n.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -72,18 +73,20 @@ static const char *arbitrary_fields[] = {
static const char private_prefix[] = "Private-";
-static int known_arbitrary_field(const struct arbitraryfield *field) {
+static bool
+known_arbitrary_field(const struct arbitraryfield *field)
+{
const char **known;
/* Always accept fields starting with a private field prefix. */
if (strncasecmp(field->name, private_prefix, strlen(private_prefix)) == 0)
- return 1;
+ return true;
for (known= arbitrary_fields; *known; known++)
if (strcasecmp(field->name, *known) == 0)
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Do a quick check if vstring is a valid versionnumber. Valid in this case
diff --git a/lib/dpkg/database.c b/lib/dpkg/database.c
index 1fb79cb..39924e1 100644
--- a/lib/dpkg/database.c
+++ b/lib/dpkg/database.c
@@ -97,7 +97,9 @@ void blankpackageperfile(struct pkginfoperfile *pifp) {
static int nes(const char *s) { return s && *s; }
-int informative(struct pkginfo *pkg, struct pkginfoperfile *info) {
+bool
+informative(struct pkginfo *pkg, struct pkginfoperfile *info)
+{
/* Used by dselect and dpkg query options as an aid to decide
* whether to display things, and by dump to decide whether to write them
* out.
@@ -108,8 +110,9 @@ int informative(struct pkginfo *pkg, struct pkginfoperfile
*info) {
pkg->status != stat_notinstalled ||
informativeversion(&pkg->configversion)))
/* We ignore Section and Priority, as these tend to hang around. */
- return 1;
- if (!info->valid) return 0;
+ return true;
+ if (!info->valid)
+ return false;
if (info->depends ||
nes(info->description) ||
nes(info->maintainer) ||
@@ -119,8 +122,9 @@ int informative(struct pkginfo *pkg, struct pkginfoperfile
*info) {
nes(info->source) ||
informativeversion(&info->version) ||
info->conffiles ||
- info->arbs) return 1;
- return 0;
+ info->arbs)
+ return true;
+ return false;
}
struct pkginfo *findpackage(const char *inname) {
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index a9debc7..f5d7fca 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -29,6 +29,7 @@
DPKG_BEGIN_DECLS
#include <sys/types.h>
+#include <stdbool.h>
#include <stdio.h>
struct versionrevision {
@@ -323,7 +324,7 @@ struct pkginfo *findpackage(const char *name);
void blankpackage(struct pkginfo *pp);
void blankpackageperfile(struct pkginfoperfile *pifp);
void blankversion(struct versionrevision*);
-int informative(struct pkginfo *pkg, struct pkginfoperfile *info);
+bool informative(struct pkginfo *pkg, struct pkginfoperfile *info);
int countpackages(void);
void resetpackages(void);
@@ -386,14 +387,14 @@ void varbufdependency(struct varbuf *vb, struct
dependency *dep);
/*** from vercmp.c ***/
-int versionsatisfied(struct pkginfoperfile *it, struct deppossi *against);
-int versionsatisfied3(const struct versionrevision *it,
- const struct versionrevision *ref,
- enum depverrel verrel);
+bool versionsatisfied(struct pkginfoperfile *it, struct deppossi *against);
+bool versionsatisfied3(const struct versionrevision *it,
+ const struct versionrevision *ref,
+ enum depverrel verrel);
int versioncompare(const struct versionrevision *version,
const struct versionrevision *refversion);
-int epochsdiffer(const struct versionrevision *a,
- const struct versionrevision *b);
+bool epochsdiffer(const struct versionrevision *a,
+ const struct versionrevision *b);
/*** from nfmalloc.c ***/
void *nfmalloc(size_t);
diff --git a/lib/dpkg/vercmp.c b/lib/dpkg/vercmp.c
index da8fb3e..85c7a9e 100644
--- a/lib/dpkg/vercmp.c
+++ b/lib/dpkg/vercmp.c
@@ -28,8 +28,10 @@
#include <dpkg/dpkg-db.h>
#include <dpkg/parsedump.h>
-int epochsdiffer(const struct versionrevision *a,
- const struct versionrevision *b) {
+bool
+epochsdiffer(const struct versionrevision *a,
+ const struct versionrevision *b)
+{
return a->epoch != b->epoch;
}
@@ -76,11 +78,14 @@ int versioncompare(const struct versionrevision *version,
return verrevcmp(version->revision,refversion->revision);
}
-int versionsatisfied3(const struct versionrevision *it,
- const struct versionrevision *ref,
- enum depverrel verrel) {
+bool
+versionsatisfied3(const struct versionrevision *it,
+ const struct versionrevision *ref,
+ enum depverrel verrel)
+{
int r;
- if (verrel == dvr_none) return 1;
+ if (verrel == dvr_none)
+ return true;
r= versioncompare(it,ref);
switch (verrel) {
case dvr_earlierequal: return r <= 0;
@@ -91,9 +96,11 @@ int versionsatisfied3(const struct versionrevision *it,
default:
internerr("unknown depverrel '%d'", verrel);
}
- return 0;
+ return false;
}
-int versionsatisfied(struct pkginfoperfile *it, struct deppossi *against) {
+bool
+versionsatisfied(struct pkginfoperfile *it, struct deppossi *against)
+{
return versionsatisfied3(&it->version,&against->version,against->verrel);
}
diff --git a/src/archives.c b/src/archives.c
index f9f95a8..fbe334a 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -159,8 +159,11 @@ static void destroyobstack(void) {
}
}
-int filesavespackage(struct fileinlist *file, struct pkginfo *pkgtobesaved,
- struct pkginfo *pkgbeinginstalled) {
+bool
+filesavespackage(struct fileinlist *file,
+ struct pkginfo *pkgtobesaved,
+ struct pkginfo *pkgbeinginstalled)
+{
struct pkginfo *divpkg, *thirdpkg;
struct filepackages *packageslump;
int i;
@@ -181,14 +184,14 @@ int filesavespackage(struct fileinlist *file, struct
pkginfo *pkgtobesaved,
divpkg= file->namenode->divert->pkg;
if (divpkg == pkgtobesaved || divpkg == pkgbeinginstalled) {
debug(dbg_eachfiledetail,"filesavespackage ... diverted -- save!");
- return 1;
+ return true;
}
}
/* Is the file in the package being installed ? If so then it can't save.
*/
if (file->namenode->flags & fnnf_new_inarchive) {
debug(dbg_eachfiledetail,"filesavespackage ... in new archive -- no save");
- return 0;
+ return false;
}
/* Look for a 3rd package which can take over the file (in case
* it's a directory which is shared by many packages.
@@ -215,11 +218,11 @@ int filesavespackage(struct fileinlist *file, struct
pkginfo *pkgtobesaved,
}
/* We've found a package that can take this file. */
debug(dbg_eachfiledetail, "filesavespackage ... taken -- no save");
- return 0;
+ return false;
}
}
debug(dbg_eachfiledetail, "filesavespackage ... not taken -- save !");
- return 1;
+ return true;
}
void cu_pathname(int argc, void **argv) {
@@ -270,9 +273,10 @@ struct pkg_deconf_list *deconfigure = NULL;
static time_t currenttime;
-static int does_replace(struct pkginfo *newpigp,
- struct pkginfoperfile *newpifp,
- struct pkginfo *oldpigp) {
+static int
+does_replace(struct pkginfo *newpigp, struct pkginfoperfile *newpifp,
+ struct pkginfo *oldpigp)
+{
struct dependency *dep;
debug(dbg_depcon,"does_replace new=%s old=%s (%s)",newpigp->name,
@@ -284,10 +288,10 @@ static int does_replace(struct pkginfo *newpigp,
versiondescribe(&dep->list->version,vdew_always));
if (!versionsatisfied(&oldpigp->installed,dep->list)) continue;
debug(dbg_depcon,"does_replace ... yes");
- return 1;
+ return true;
}
debug(dbg_depcon,"does_replace ... no");
- return 0;
+ return false;
}
static void newtarobject_utime(const char *path, struct TarInfo *ti) {
@@ -360,9 +364,10 @@ struct fileinlist *addfiletolist(struct tarcontext *tc,
return nifd;
}
-static int linktosameexistingdir(const struct TarInfo *ti,
- const char *fname,
- struct varbuf *symlinkfn) {
+static bool
+linktosameexistingdir(const struct TarInfo *ti, const char *fname,
+ struct varbuf *symlinkfn)
+{
struct stat oldstab, newstab;
int statr;
const char *lastslash;
@@ -372,9 +377,10 @@ static int linktosameexistingdir(const struct TarInfo *ti,
if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
ohshite(_("failed to stat (dereference) existing symlink `%.250s'"),
fname);
- return 0;
+ return false;
}
- if (!S_ISDIR(oldstab.st_mode)) return 0;
+ if (!S_ISDIR(oldstab.st_mode))
+ return false;
/* But is it to the same dir ? */
varbufreset(symlinkfn);
@@ -393,12 +399,14 @@ static int linktosameexistingdir(const struct TarInfo *ti,
if (!(errno == ENOENT || errno == ELOOP || errno == ENOTDIR))
ohshite(_("failed to stat (dereference) proposed new symlink target"
" `%.250s' for symlink `%.250s'"), symlinkfn->buf, fname);
- return 0;
+ return false;
}
- if (!S_ISDIR(newstab.st_mode)) return 0;
+ if (!S_ISDIR(newstab.st_mode))
+ return false;
if (newstab.st_dev != oldstab.st_dev ||
- newstab.st_ino != oldstab.st_ino) return 0;
- return 1;
+ newstab.st_ino != oldstab.st_ino)
+ return false;
+ return true;
}
int tarobject(struct TarInfo *ti) {
@@ -864,12 +872,11 @@ int tarobject(struct TarInfo *ti) {
return 0;
}
-static int try_deconfigure_can(int (*force_p)(struct deppossi*),
- struct pkginfo *pkg,
- struct deppossi *pdep,
- const char *action,
- struct pkginfo *removal,
- const char *why) {
+static int
+try_deconfigure_can(bool (*force_p)(struct deppossi *), struct pkginfo *pkg,
+ struct deppossi *pdep, const char *action,
+ struct pkginfo *removal, const char *why)
+{
/* Also checks whether the pdep is forced, first, according to force_p.
* force_p may be 0 in which case nothing is considered forced.
*
diff --git a/src/archives.h b/src/archives.h
index 8cb68bb..858013f 100644
--- a/src/archives.h
+++ b/src/archives.h
@@ -22,6 +22,8 @@
#ifndef ARCHIVES_H
#define ARCHIVES_H
+#include <stdbool.h>
+
struct tarcontext {
int backendpipe;
struct pkginfo *pkg;
@@ -66,8 +68,8 @@ int unlinkorrmdir(const char *filename);
int tarobject(struct TarInfo *ti);
int tarfileread(void *ud, char *buf, int len);
-int filesavespackage(struct fileinlist*, struct pkginfo*,
- struct pkginfo *pkgbeinginstalled);
+bool filesavespackage(struct fileinlist *, struct pkginfo *,
+ struct pkginfo *pkgbeinginstalled);
void check_conflict(struct dependency *dep, struct pkginfo *pkg,
const char *pfilename);
diff --git a/src/depcon.c b/src/depcon.c
index f109384..cf1af9c 100644
--- a/src/depcon.c
+++ b/src/depcon.c
@@ -40,17 +40,19 @@ struct cyclesofarlink {
struct deppossi *possi;
};
-static int findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink
*sofar);
+static bool findbreakcyclerecursive(struct pkginfo *pkg,
+ struct cyclesofarlink *sofar);
-static int foundcyclebroken(struct cyclesofarlink *thislink,
- struct cyclesofarlink *sofar,
- struct pkginfo *dependedon,
- struct deppossi *possi) {
+static bool
+foundcyclebroken(struct cyclesofarlink *thislink, struct cyclesofarlink *sofar,
+ struct pkginfo *dependedon, struct deppossi *possi)
+{
struct cyclesofarlink *sol;
const char *postinstfilename;
struct stat stab;
- if(!possi) return 0;
+ if(!possi)
+ return false;
/* We're investigating the dependency `possi' to see if it
* is part of a loop. To this end we look to see whether the
* depended-on package is already one of the packages whose
@@ -86,10 +88,12 @@ static int foundcyclebroken(struct cyclesofarlink *thislink,
sol->possi->cyclebreak= 1;
debug(dbg_depcon,"cycle broken at %s -> %s\n",
sol->possi->up->up->name, sol->possi->ed->name);
- return 1;
+ return true;
}
-static int findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink
*sofar) {
+static bool
+findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *sofar)
+{
/* Cycle breaking works recursively down the package dependency
* tree. `sofar' is the list of packages we've descended down
* already - if we encounter any of its packages again in a
@@ -101,7 +105,7 @@ static int findbreakcyclerecursive(struct pkginfo *pkg,
struct cyclesofarlink *s
struct pkginfo *provider;
if (pkg->color == black)
- return 0;
+ return false;
pkg->color = gray;
if (f_debug & dbg_depcondetail) {
@@ -125,7 +129,8 @@ static int findbreakcyclerecursive(struct pkginfo *pkg,
struct cyclesofarlink *s
/* Don't find the same cycles again. */
if (possi->cyclebreak) continue;
thislink.possi= possi;
- if (foundcyclebroken(&thislink,sofar,possi->ed,possi)) return 1;
+ if (foundcyclebroken(&thislink, sofar, possi->ed,possi))
+ return true;
/* Right, now we try all the providers ... */
for (providelink= possi->ed->installed.depended;
providelink;
@@ -136,16 +141,19 @@ static int findbreakcyclerecursive(struct pkginfo *pkg,
struct cyclesofarlink *s
/* We don't break things at `provides' links, so `possi' is
* still the one we use.
*/
- if (foundcyclebroken(&thislink,sofar,provider,possi)) return 1;
+ if (foundcyclebroken(&thislink, sofar, provider, possi))
+ return true;
}
}
}
/* Nope, we didn't find a cycle to break. */
pkg->color = black;
- return 0;
+ return false;
}
-int findbreakcycle(struct pkginfo *pkg) {
+bool
+findbreakcycle(struct pkginfo *pkg)
+{
struct pkgiterator *iter;
struct pkginfo *tpkg;
@@ -195,18 +203,20 @@ void describedepcon(struct varbuf *addto, struct
dependency *dep) {
varbuffree(&depstr);
}
-int depisok(struct dependency *dep, struct varbuf *whynot,
- struct pkginfo **canfixbyremove, int allowunconfigd) {
+bool
+depisok(struct dependency *dep, struct varbuf *whynot,
+ struct pkginfo **canfixbyremove, int allowunconfigd)
+{
/* *whynot must already have been initialised; it need not be
* empty though - it will be reset before use.
- * If depisok returns 0 for `not OK' it will contain a description,
+ * If depisok returns false for ‘not OK’ it will contain a description,
* newline-terminated BUT NOT NULL-TERMINATED, of the reason.
- * If depisok returns 1 it will contain garbage.
+ * If depisok returns true it will contain garbage.
* allowunconfigd should be non-zero during the `Pre-Depends' checking
* before a package is unpacked, when it is sufficient for the package
* to be unpacked provided that both the unpacked and previously-configured
* versions are acceptable.
- * On 0 return (`not OK'), *canfixbyremove refers to a package which
+ * On false return (‘not OK’), *canfixbyremove refers to a package which
* if removed (dep_conflicts) or deconfigured (dep_breaks) will fix
* the problem. Caller may pass 0 for canfixbyremove and need not
* initialise *canfixbyremove.
@@ -235,7 +245,7 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
*/
switch (dep->up->clientdata->istobe) {
case itb_remove: case itb_deconfigure:
- return 1;
+ return true;
case itb_normal:
/* Only installed packages can be make dependency problems */
switch (dep->up->status) {
@@ -245,7 +255,7 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
break;
case stat_notinstalled: case stat_configfiles: case stat_halfinstalled:
case stat_halfconfigured: case stat_unpacked:
- return 1;
+ return true;
default:
internerr("unknown status depending '%d'", dep->up->status);
}
@@ -267,9 +277,9 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
dep->type == dep_recommends || dep->type == dep_suggests ) {
/* Go through the alternatives. As soon as we find one that
- * we like, we return `1' straight away. Otherwise, when we get to
+ * we like, we return ‘true’ straight away. Otherwise, when we get to
* the end we'll have accumulated all the reasons in whynot and
- * can return `0'.
+ * can return ‘false’.
*/
for (possi= dep->list; possi; possi= possi->next) {
@@ -281,7 +291,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
sprintf(linebuf,_(" %.250s is to be
deconfigured.\n"),possi->ed->name);
break;
case itb_installnew:
- if (versionsatisfied(&possi->ed->available,possi)) return 1;
+ if (versionsatisfied(&possi->ed->available, possi))
+ return true;
sprintf(linebuf,_(" %.250s is to be installed, but is version
%.250s.\n"),
possi->ed->name,
versiondescribe(&possi->ed->available.version,vdew_nonambig));
@@ -290,7 +301,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
switch (possi->ed->status) {
case stat_installed:
case stat_triggerspending:
- if (versionsatisfied(&possi->ed->installed,possi)) return 1;
+ if (versionsatisfied(&possi->ed->installed, possi))
+ return true;
sprintf(linebuf,_(" %.250s is installed, but is version %.250s.\n"),
possi->ed->name,
versiondescribe(&possi->ed->installed.version,vdew_nonambig));
@@ -322,7 +334,7 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
versiondescribe(&possi->ed->configversion,vdew_nonambig));
break;
} else {
- return 1;
+ return true;
}
}
/* Fall through. */
@@ -345,7 +357,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
provider;
provider= provider->nextrev) {
if (provider->up->type != dep_provides) continue;
- if (provider->up->up->clientdata->istobe == itb_installnew) return 1;
+ if (provider->up->up->clientdata->istobe == itb_installnew)
+ return true;
}
/* Now look at the packages already on the system. */
@@ -371,7 +384,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
provider->up->up->name, possi->ed->name);
break;
case itb_normal: case itb_preinstall:
- if (provider->up->up->status == stat_installed) return 1;
+ if (provider->up->up->status == stat_installed)
+ return true;
sprintf(linebuf, _(" %.250s provides %.250s but is %s.\n"),
provider->up->up->name, possi->ed->name,
gettext(statusstrings[provider->up->up->status]));
@@ -393,14 +407,14 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
}
}
- return 0;
+ return false;
} else {
/* It's conflicts or breaks. There's only one main alternative,
- * but we also have to consider Providers. We return `0' as soon
+ * but we also have to consider Providers. We return ‘false’ as soon
* as we find something that matches the conflict, and only describe
- * it then. If we get to the end without finding anything we return `1'.
+ * it then. If we get to the end without finding anything we return ‘true’.
*/
possi= dep->list;
@@ -422,7 +436,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
possi->ed->name,
versiondescribe(&possi->ed->available.version,vdew_nonambig));
varbufaddstr(whynot, linebuf);
- if (!canfixbyremove) return 0;
+ if (!canfixbyremove)
+ return false;
nconflicts++;
*canfixbyremove= possi->ed;
break;
@@ -445,7 +460,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
versiondescribe(&possi->ed->installed.version,vdew_nonambig),
gettext(statusstrings[possi->ed->status]));
varbufaddstr(whynot, linebuf);
- if (!canfixbyremove) return 0;
+ if (!canfixbyremove)
+ return false;
nconflicts++;
*canfixbyremove= possi->ed;
}
@@ -472,7 +488,7 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
/* We can't remove the one we're about to install: */
if (canfixbyremove)
*canfixbyremove = NULL;
- return 0;
+ return false;
}
/* Now look at the packages already on the system. */
@@ -510,7 +526,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
provider->up->up->name, possi->ed->name,
gettext(statusstrings[provider->up->up->status]));
varbufaddstr(whynot, linebuf);
- if (!canfixbyremove) return 0;
+ if (!canfixbyremove)
+ return false;
nconflicts++;
*canfixbyremove= provider->up->up;
break;
@@ -523,10 +540,11 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
}
}
- if (!nconflicts) return 1;
+ if (!nconflicts)
+ return true;
if (nconflicts > 1)
*canfixbyremove = NULL;
- return 0;
+ return false;
} /* if (dependency) {...} else {...} */
}
diff --git a/src/enquiry.c b/src/enquiry.c
index 60a39d3..1a853a2 100644
--- a/src/enquiry.c
+++ b/src/enquiry.c
@@ -25,6 +25,7 @@
#include <dpkg/i18n.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -45,18 +46,22 @@
#include "main.h"
struct badstatinfo {
- int (*yesno)(struct pkginfo*, const struct badstatinfo *bsi);
+ bool (*yesno)(struct pkginfo *, const struct badstatinfo *bsi);
int val;
const char *explanation;
};
-static int bsyn_reinstreq(struct pkginfo *pkg, const struct badstatinfo *bsi) {
+static bool
+bsyn_reinstreq(struct pkginfo *pkg, const struct badstatinfo *bsi)
+{
return pkg->eflag &= eflag_reinstreq;
}
-static int bsyn_status(struct pkginfo *pkg, const struct badstatinfo *bsi) {
+static bool
+bsyn_status(struct pkginfo *pkg, const struct badstatinfo *bsi)
+{
if (pkg->eflag &= eflag_reinstreq)
- return 0;
+ return false;
return (int)pkg->status == bsi->val;
}
@@ -142,22 +147,25 @@ struct sectionentry {
int count;
};
-static int yettobeunpacked(struct pkginfo *pkg, const char **thissect) {
- if (pkg->want != want_install) return 0;
+static bool
+yettobeunpacked(struct pkginfo *pkg, const char **thissect)
+{
+ if (pkg->want != want_install)
+ return false;
switch (pkg->status) {
case stat_unpacked: case stat_installed: case stat_halfconfigured:
case stat_triggerspending:
case stat_triggersawaited:
- return 0;
+ return false;
case stat_notinstalled: case stat_halfinstalled: case stat_configfiles:
if (thissect)
*thissect= pkg->section && *pkg->section ? pkg->section : _("<unknown>");
- return 1;
+ return true;
default:
internerr("unknown package status '%d'", pkg->status);
}
- return 0;
+ return false;
}
void unpackchk(const char *const *argv) {
diff --git a/src/errors.c b/src/errors.c
index 309f793..01f696d 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -93,16 +93,19 @@ int reportbroken_retexitstatus(void) {
return nerrs ? 1 : 0;
}
-int skip_due_to_hold(struct pkginfo *pkg) {
- if (pkg->want != want_hold) return 0;
+bool
+skip_due_to_hold(struct pkginfo *pkg)
+{
+ if (pkg->want != want_hold)
+ return false;
if (fc_hold) {
fprintf(stderr, _("Package %s was on hold, processing it anyway as you
requested\n"),
pkg->name);
- return 0;
+ return false;
}
printf(_("Package %s is on hold, not touching it. Use --force-hold to
override.\n"),
pkg->name);
- return 1;
+ return true;
}
void forcibleerr(int forceflag, const char *fmt, ...) {
diff --git a/src/help.c b/src/help.c
index d0b104f..2ebffc1 100644
--- a/src/help.c
+++ b/src/help.c
@@ -130,26 +130,35 @@ void checkpath(void) {
warned);
}
-int ignore_depends(struct pkginfo *pkg) {
+bool
+ignore_depends(struct pkginfo *pkg)
+{
struct pkg_list *id;
for (id= ignoredependss; id; id= id->next)
- if (id->pkg == pkg) return 1;
- return 0;
+ if (id->pkg == pkg)
+ return true;
+ return false;
}
-int force_depends(struct deppossi *possi) {
+bool
+force_depends(struct deppossi *possi)
+{
return fc_depends ||
ignore_depends(possi->ed) ||
ignore_depends(possi->up->up);
}
-int force_breaks(struct deppossi *possi) {
+bool
+force_breaks(struct deppossi *possi)
+{
return fc_breaks ||
ignore_depends(possi->ed) ||
ignore_depends(possi->up->up);
}
-int force_conflicts(struct deppossi *possi) {
+bool
+force_conflicts(struct deppossi *possi)
+{
return fc_conflicts;
}
@@ -455,8 +464,13 @@ void debug(int which, const char *fmt, ...) {
putc('\n',stderr);
}
-int hasdirectoryconffiles(struct filenamenode *file, struct pkginfo *pkg) {
- /* Returns 1 if the directory contains conffiles belonging to pkg, 0
otherwise. */
+/*
+ * Returns true if the directory contains conffiles belonging to pkg,
+ * false otherwise.
+ */
+bool
+hasdirectoryconffiles(struct filenamenode *file, struct pkginfo *pkg)
+{
struct conffile *conff;
size_t namelen;
@@ -467,16 +481,20 @@ int hasdirectoryconffiles(struct filenamenode *file,
struct pkginfo *pkg) {
if (!strncmp(file->name,conff->name,namelen)) {
debug(dbg_veryverbose, "directory %s has conffile %s from %s",
file->name, conff->name, pkg->name);
- return 1;
+ return true;
}
}
debug(dbg_veryverbose, "hasdirectoryconffiles no");
- return 0;
+ return false;
}
-
-int isdirectoryinuse(struct filenamenode *file, struct pkginfo *pkg) {
- /* Returns 1 if the file is used by packages other than pkg, 0 otherwise. */
+/*
+ * Returns true if the file is used by packages other than pkg,
+ * false otherwise.
+ */
+bool
+isdirectoryinuse(struct filenamenode *file, struct pkginfo *pkg)
+{
struct filepackages *packageslump;
int i;
@@ -489,11 +507,11 @@ int isdirectoryinuse(struct filenamenode *file, struct
pkginfo *pkg) {
debug(dbg_veryverbose, "isdirectoryinuse considering [%d] %s ...", i,
packageslump->pkgs[i]->name);
if (packageslump->pkgs[i] == pkg) continue;
- return 1;
+ return true;
}
}
debug(dbg_veryverbose, "isdirectoryinuse no");
- return 0;
+ return false;
}
void oldconffsetflags(const struct conffile *searchconff) {
diff --git a/src/main.c b/src/main.c
index 3a084ba..78c34c3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
#include <dpkg/i18n.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -323,7 +324,7 @@ static void setpipe(const struct cmdinfo *cip, const char
*value) {
*pipe_head = pipe_new;
}
-static int
+static bool
is_invoke_action(enum action action)
{
switch (action) {
@@ -333,9 +334,9 @@ is_invoke_action(enum action action)
case act_triggers:
case act_remove:
case act_purge:
- return 1;
+ return true;
default:
- return 0;
+ return false;
}
}
diff --git a/src/main.h b/src/main.h
index 698c9c6..5b81b63 100644
--- a/src/main.h
+++ b/src/main.h
@@ -214,18 +214,18 @@ void cu_prermremove(int argc, void **argv);
void print_error_perpackage(const char *emsg, const char *arg);
void forcibleerr(int forceflag, const char *format, ...) DPKG_ATTR_PRINTF(2);
int reportbroken_retexitstatus(void);
-int skip_due_to_hold(struct pkginfo *pkg);
+bool skip_due_to_hold(struct pkginfo *pkg);
/* from help.c */
struct stat;
-int ignore_depends(struct pkginfo *pkg);
-int force_breaks(struct deppossi *possi);
-int force_depends(struct deppossi *possi);
-int force_conff_new(struct deppossi *possi);
-int force_conff_miss(struct deppossi *possi);
-int force_conflicts(struct deppossi *possi);
+bool ignore_depends(struct pkginfo *pkg);
+bool force_breaks(struct deppossi *possi);
+bool force_depends(struct deppossi *possi);
+bool force_conff_new(struct deppossi *possi);
+bool force_conff_miss(struct deppossi *possi);
+bool force_conflicts(struct deppossi *possi);
void oldconffsetflags(const struct conffile *searchconff);
void ensure_pathname_nonexisting(const char *pathname);
int secure_unlink(const char *pathname);
@@ -254,8 +254,8 @@ void post_postinst_tasks_core(struct pkginfo *pkg);
void post_postinst_tasks(struct pkginfo *pkg, enum pkgstatus new_status);
void clear_istobes(void);
-int isdirectoryinuse(struct filenamenode *namenode, struct pkginfo *pkg);
-int hasdirectoryconffiles(struct filenamenode *namenode, struct pkginfo *pkg);
+bool isdirectoryinuse(struct filenamenode *namenode, struct pkginfo *pkg);
+bool hasdirectoryconffiles(struct filenamenode *namenode, struct pkginfo *pkg);
enum debugflags {
dbg_general= 00001,
@@ -291,10 +291,10 @@ void trig_activate_packageprocessing(struct pkginfo *pkg);
/* from depcon.c */
-int depisok(struct dependency *dep, struct varbuf *whynot,
- struct pkginfo **fixbyrm, int allowunconfigd);
+bool depisok(struct dependency *dep, struct varbuf *whynot,
+ struct pkginfo **fixbyrm, int allowunconfigd);
struct cyclesofarlink;
-int findbreakcycle(struct pkginfo *pkg);
+bool findbreakcycle(struct pkginfo *pkg);
void describedepcon(struct varbuf *addto, struct dependency *dep);
#endif /* MAIN_H */
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 2214819..e7bb2a4 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -71,6 +71,7 @@
#endif
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -208,14 +209,14 @@ static void *xmalloc(int size);
static void push(struct pid_list **list, pid_t pid);
static void do_help(void);
static void parse_options(int argc, char * const *argv);
-static int pid_is_user(pid_t pid, uid_t uid);
-static int pid_is_cmd(pid_t pid, const char *name);
+static bool pid_is_user(pid_t pid, uid_t uid);
+static bool pid_is_cmd(pid_t pid, const char *name);
static void check(pid_t pid);
static void do_pidfile(const char *name);
static void do_stop(int signal_nr, int quietmode,
int *n_killed, int *n_notkilled, int retry_nr);
#if defined(OSLinux) || defined(OShpux)
-static int pid_is_exec(pid_t pid, const struct stat *esb);
+static bool pid_is_exec(pid_t pid, const struct stat *esb);
#endif
@@ -920,7 +921,7 @@ get_proc_stat (pid_t pid, ps_flags_t flags)
#endif
#if defined(OSLinux)
-static int
+static bool
pid_is_exec(pid_t pid, const struct stat *esb)
{
char lname[32];
@@ -932,30 +933,30 @@ pid_is_exec(pid_t pid, const struct stat *esb)
sprintf(lname, "/proc/%d/exe", pid);
nread = readlink(lname, lcontents, sizeof(lcontents));
if (nread == -1)
- return 0;
+ return false;
lcontents[nread] = '\0';
if (strcmp(lcontents + nread - strlen(deleted), deleted) == 0)
lcontents[nread - strlen(deleted)] = '\0';
if (stat(lcontents, &sb) != 0)
- return 0;
+ return false;
return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
}
#elif defined(OShpux)
-static int
+static bool
pid_is_exec(pid_t pid, const struct stat *esb)
{
struct pst_status pst;
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, (int)pid) < 0)
- return 0;
+ return false;
return ((dev_t)pst.pst_text.psf_fsid.psfs_id == esb->st_dev &&
(ino_t)pst.pst_text.psf_fileid == esb->st_ino);
}
#elif defined(HAVE_KVM_H)
-static int
+static bool
pid_is_exec(pid_t pid, const char *name)
{
kvm_t *kd;
@@ -971,13 +972,13 @@ pid_is_exec(pid_t pid, const char *name)
errx(1, "%s", kvm_geterr(kd));
pidexec = (&kp->kp_proc)->p_comm;
if (strlen(name) != strlen(pidexec))
- return 0;
+ return false;
return (strcmp(name, pidexec) == 0) ? 1 : 0;
}
#endif
#if defined(OSLinux)
-static int
+static bool
pid_is_user(pid_t pid, uid_t uid)
{
struct stat sb;
@@ -985,11 +986,11 @@ pid_is_user(pid_t pid, uid_t uid)
sprintf(buf, "/proc/%d", pid);
if (stat(buf, &sb) != 0)
- return 0;
+ return false;
return (sb.st_uid == uid);
}
#elif defined(OSHurd)
-static int
+static bool
pid_is_user(pid_t pid, uid_t uid)
{
struct proc_stat *ps;
@@ -998,17 +999,17 @@ pid_is_user(pid_t pid, uid_t uid)
return ps && proc_stat_owner_uid(ps) == uid;
}
#elif defined(OShpux)
-static int
+static bool
pid_is_user(pid_t pid, uid_t uid)
{
struct pst_status pst;
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, (int)pid) < 0)
- return 0;
+ return false;
return ((uid_t)pst.pst_uid == uid);
}
#elif defined(HAVE_KVM_H)
-static int
+static bool
pid_is_user(pid_t pid, uid_t uid)
{
kvm_t *kd;
@@ -1027,13 +1028,13 @@ pid_is_user(pid_t pid, uid_t uid)
kvm_read(kd, (u_long)&(kp->kp_proc.p_cred->p_ruid),
&proc_uid, sizeof(uid_t));
else
- return 0;
+ return false;
return (proc_uid == (uid_t)uid);
}
#endif
#if defined(OSLinux)
-static int
+static bool
pid_is_cmd(pid_t pid, const char *name)
{
char buf[32];
@@ -1043,12 +1044,12 @@ pid_is_cmd(pid_t pid, const char *name)
sprintf(buf, "/proc/%d/stat", pid);
f = fopen(buf, "r");
if (!f)
- return 0;
+ return false;
while ((c = getc(f)) != EOF && c != '(')
;
if (c != '(') {
fclose(f);
- return 0;
+ return false;
}
/* This hopefully handles command names containing ')'. */
while ((c = getc(f)) != EOF && c == *name)
@@ -1057,7 +1058,7 @@ pid_is_cmd(pid_t pid, const char *name)
return (c == ')' && *name == '\0');
}
#elif defined(OSHurd)
-static int
+static bool
pid_is_cmd(pid_t pid, const char *name)
{
struct proc_stat *ps;
@@ -1066,17 +1067,17 @@ pid_is_cmd(pid_t pid, const char *name)
return ps && !strcmp(proc_stat_args(ps), name);
}
#elif defined(OShpux)
-static int
+static bool
pid_is_cmd(pid_t pid, const char *name)
{
struct pst_status pst;
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, (int)pid) < 0)
- return 0;
+ return false;
return (strcmp(pst.pst_ucomm, name) == 0);
}
#elif defined(HAVE_KVM_H)
-static int
+static bool
pid_is_cmd(pid_t pid, const char *name)
{
kvm_t *kd;
@@ -1115,25 +1116,25 @@ pid_is_cmd(pid_t pid, const char *name)
}
if (strlen(name) != strlen(start_argv_0_p))
- return 0;
+ return false;
return (strcmp(name, start_argv_0_p) == 0) ? 1 : 0;
}
#endif
#if defined(OSHurd)
-static int
+static bool
pid_is_running(pid_t pid)
{
return get_proc_stat(pid, 0) != NULL;
}
#else /* !OSHurd */
-static int
+static bool
pid_is_running(pid_t pid)
{
if (kill(pid, 0) == 0 || errno == EPERM)
- return 1;
+ return true;
else if (errno == ESRCH)
- return 0;
+ return false;
else
fatal("Error checking pid %u status: %s", pid, strerror(errno));
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]