Browse Source

Use bool instead of int wherever appropriate

Guillem Jover 16 years ago
parent
commit
7eb30624a0

+ 7 - 5
dpkg-deb/extract.c

@@ -33,6 +33,7 @@
 #include <dirent.h>
 #include <unistd.h>
 #include <ar.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -124,7 +125,8 @@ void extracthalf(const char *debar, const char *directory,
   char nlc;
   char *cur;
   struct ar_hdr arh;
-  int readfromfd, oldformat= 0, header_done, adminmember;
+  int readfromfd, adminmember;
+  bool oldformat, header_done;
   struct compressor *decompressor = &compressor_gzip;
   
   ar= fopen(debar,"r"); if (!ar) ohshite(_("failed to read archive `%.255s'"),debar);
@@ -132,10 +134,10 @@ void extracthalf(const char *debar, const char *directory,
   if (!fgets(versionbuf,sizeof(versionbuf),ar)) readfail(ar,debar,_("version number"));
 
   if (!strcmp(versionbuf,"!<arch>\n")) {
-    oldformat= 0;
+    oldformat = false;
 
     ctrllennum= 0;
-    header_done= 0;
+    header_done = false;
     for (;;) {
       if (fread(&arh,1,sizeof(arh),ar) != sizeof(arh))
         readfail(ar,debar,_("between members"));
@@ -164,7 +166,7 @@ void extracthalf(const char *debar, const char *directory,
         *cur= '.';
         strncpy(versionbuf,infobuf,sizeof(versionbuf));
         versionbuf[sizeof(versionbuf) - 1] = '\0';
-        header_done= 1;
+        header_done = true;
       } else if (arh.ar_name[0] == '_') {
           /* Members with `_' are noncritical, and if we don't understand them
            * we skip them.
@@ -210,7 +212,7 @@ void extracthalf(const char *debar, const char *directory,
              sscanf(versionbuf,"%f%c%d",&versionnum,&nlc,&dummy) == 2 &&
              nlc == '\n') {
     
-    oldformat= 1;
+    oldformat = true;
     l = strlen(versionbuf);
     if (l && versionbuf[l - 1] == '\n')
       versionbuf[l - 1] = '\0';

+ 18 - 6
dpkg-deb/info.c

@@ -193,18 +193,29 @@ static void info_list(const char *debar, const char *directory) {
 }
 
 static void info_field(const char *debar, const char *directory,
-                       const char *const *fields, int showfieldname) {
+                       const char *const *fields, bool showfieldname)
+{
   FILE *cc;
   char fieldname[MAXFIELDNAME+1];
   char *pf;
   const char *const *fp;
-  int doing, c, lno, fnl;
+  int c, lno, fnl;
+  bool doing;
 
   if (!(cc= fopen("control","r"))) ohshite(_("could not open the `control' component"));
-  doing= 1; lno= 1;
+  doing = true;
+  lno = 1;
   for (;;) {
-    c= getc(cc);  if (c==EOF) { doing=0; break; }
-    if (c == '\n') { lno++; doing=1; continue; }
+    c = getc(cc);
+    if (c == EOF) {
+      doing = false;
+      break;
+    }
+    if (c == '\n') {
+      lno++;
+      doing = true;
+      continue;
+    }
     if (!isspace(c)) {
       for (pf=fieldname, fnl=0;
            fnl <= MAXFIELDNAME && c!=EOF && !isspace(c) && c!=':';
@@ -212,7 +223,8 @@ static void info_field(const char *debar, const char *directory,
       *pf = '\0';
       doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF;
       for (fp=fields; !doing && *fp; fp++)
-        if (!strcasecmp(*fp,fieldname)) doing=1;
+        if (!strcasecmp(*fp, fieldname))
+          doing = true;
       if (showfieldname) {
         if (doing)
           fputs(fieldname,stdout);

+ 19 - 7
dpkg-split/queue.c

@@ -49,22 +49,32 @@
 
 #include "dpkg-split.h"
 
-static int decompose_filename(const char *filename, struct partqueue *pq) {
+static bool
+decompose_filename(const char *filename, struct partqueue *pq)
+{
   const char *p;
   char *q;
 
   if (strspn(filename, "0123456789abcdef") != MD5HASHLEN ||
       filename[MD5HASHLEN] != '.')
-    return 0;
+    return false;
   q = nfmalloc(MD5HASHLEN + 1);
   memcpy(q, filename, MD5HASHLEN);
   q[MD5HASHLEN] = '\0';
   pq->info.md5sum= q;
   p = filename + MD5HASHLEN + 1;
-  pq->info.maxpartlen= strtol(p,&q,16); if (q==p || *q++ != '.') return 0;
-  p=q; pq->info.thispartn= (int)strtol(p,&q,16); if (q==p || *q++ != '.') return 0;
-  p=q; pq->info.maxpartn= (int)strtol(p,&q,16); if (q==p || *q) return 0;
-  return 1;
+  pq->info.maxpartlen = strtol(p, &q, 16);
+  if (q == p || *q++ != '.')
+    return false;
+  p = q;
+  pq->info.thispartn = (int)strtol(p, &q, 16);
+  if (q == p || *q++ != '.')
+    return false;
+  p = q;
+  pq->info.maxpartn = (int)strtol(p, &q, 16);
+  if (q == p || *q)
+    return false;
+  return true;
 }
 
 void scandepot(void) {
@@ -96,7 +106,9 @@ void scandepot(void) {
   closedir(depot);
 }
 
-static int partmatches(struct partinfo *pi, struct partinfo *refi) {
+static bool
+partmatches(struct partinfo *pi, struct partinfo *refi)
+{
   return (pi->md5sum &&
           !strcmp(pi->md5sum,refi->md5sum) &&
           pi->maxpartn == refi->maxpartn &&

+ 10 - 6
dselect/basecmds.cc

@@ -93,25 +93,29 @@ void baselist::kd_searchagain() {
   dosearch();
 }
 
-int baselist::checksearch(char* str) {
-  return 1;
+bool
+baselist::checksearch(char *str)
+{
+  return true;
 }
 
-int baselist::matchsearch(int index) {
+bool
+baselist::matchsearch(int index)
+{
   int lendiff, searchlen, i;
   const char *name;
 
   name = itemname(index);
   if (!name)
-    return 0;	/* Skip things without a name (seperators). */
+    return false;	/* Skip things without a name (seperators). */
 
   searchlen=strlen(searchstring);
   lendiff = strlen(name) - searchlen;
   for (i=0; i<=lendiff; i++)
     if (!strncasecmp(name + i, searchstring, searchlen))
-      return 1;
+      return true;
 
-  return 0;
+  return false;
 }
 
 void baselist::kd_search() {

+ 9 - 4
dselect/bindings.cc

@@ -39,13 +39,17 @@ keybindings::keybindings(const interpretation *ints, const orgbinding *orgbindin
   describestart();
 }
 
-int keybindings::bind(int key, const char *action) {
-  if (key == -1) return 0;
+bool
+keybindings::bind(int key, const char *action)
+{
+  if (key == -1)
+    return false;
   
   const interpretation *interp = interps;
   while (interp->action && strcmp(interp->action, action))
     interp++;
-  if (!interp->action) return 0;
+  if (!interp->action)
+    return false;
   
   const description *desc = descriptions;
   while (desc->action && strcmp(desc->action, action))
@@ -63,7 +67,8 @@ int keybindings::bind(int key, const char *action) {
   }
   b->interp = interp;
   b->desc = desc ? desc->desc : 0;
-  return 1;
+
+  return true;
 }
 
 const char *keybindings::find(const char *action) {

+ 3 - 2
dselect/bindings.h

@@ -53,13 +53,14 @@ struct keybindings {
   const description *iterate;
   const interpretation *interps;
   
-  int bind(int key, const char *action);
+  bool bind(int key, const char *action);
   
  public:
   int name2key(const char *name);
   const char *key2name(int key);
   
-  int bind(const char *name, const char *action) { return bind(name2key(name),action); }
+  bool bind(const char *name, const char *action)
+  { return bind(name2key(name), action); }
   const interpretation *operator()(int key);
   const char *find(const char *action);
 

+ 2 - 2
dselect/dselect.h

@@ -103,8 +103,8 @@ protected:
   virtual const char *itemname(int index) =0;
   virtual const struct helpmenuentry *helpmenulist() =0;
 
-  virtual int checksearch(char* str);
-  virtual int matchsearch(int index);
+  virtual bool checksearch(char *str);
+  virtual bool matchsearch(int index);
   void wordwrapinfo(int offset, const char *string);
   
 public:

+ 9 - 6
dselect/pkgcmds.cc

@@ -30,13 +30,16 @@
 #include "dselect.h"
 #include "pkglist.h"
 
-int packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith) {
+bool
+packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith) {
   switch (statsortorder) {
   case sso_avail:
-    if (comparewith->clientdata->ssavail != pkg->clientdata->ssavail) return 0;
+    if (comparewith->clientdata->ssavail != pkg->clientdata->ssavail)
+      return false;
     break;
   case sso_state:
-    if (comparewith->clientdata->ssstate != pkg->clientdata->ssstate) return 0;
+    if (comparewith->clientdata->ssstate != pkg->clientdata->ssstate)
+      return false;
     break;
   case sso_unsorted:
     break;
@@ -47,13 +50,13 @@ int packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewit
       (comparewith->priority != pkg->priority ||
        (comparewith->priority == pkginfo::pri_other &&
         strcasecmp(comparewith->otherpriority, pkg->otherpriority))))
-    return 0;
+    return false;
   if (comparewith->section &&
       strcasecmp(comparewith->section,
                  pkg->section ?
                  pkg->section : ""))
-    return 0;
-  return 1;
+    return false;
+  return true;
 }
 
 void packagelist::affectedrange(int *startp, int *endp) {

+ 16 - 10
dselect/pkgdepcon.cc

@@ -33,7 +33,9 @@
 
 static const int depdebug= 1;
 
-int packagelist::useavailable(pkginfo *pkg) {
+bool
+packagelist::useavailable(pkginfo *pkg)
+{
   if (pkg->clientdata &&
       pkg->clientdata->selected == pkginfo::want_install &&
       informative(pkg,&pkg->available) &&
@@ -41,9 +43,9 @@ int packagelist::useavailable(pkginfo *pkg) {
          pkg->status == pkginfo::stat_triggersawaited ||
          pkg->status == pkginfo::stat_triggerspending) ||
        versioncompare(&pkg->available.version,&pkg->installed.version) > 0))
-    return 1;
+    return true;
   else
-    return 0;
+    return false;
 }
 
 pkginfoperfile *packagelist::findinfo(pkginfo *pkg) {
@@ -357,7 +359,9 @@ int packagelist::resolvedepcon(dependency *depends) {
   return 1;
 }
 
-int packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade) {
+bool
+packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
+{
   // `satisfied' here for Conflicts and Breaks means that the
   //  restriction is violated ie that the target package is wanted
   int would;
@@ -381,16 +385,18 @@ int packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade
       assert(want == pkginfo::want_install);
       return versionsatisfied(&possi->ed->available,possi);
     } else {
-      if (versionsatisfied(&possi->ed->installed,possi)) return 1;
+      if (versionsatisfied(&possi->ed->installed, possi))
+        return true;
       if (want == pkginfo::want_hold && fixbyupgrade && !*fixbyupgrade &&
           versionsatisfied(&possi->ed->available,possi) &&
           versioncompare(&possi->ed->available.version,
                          &possi->ed->installed.version) > 1)
         *fixbyupgrade= possi->ed->clientdata;
-      return 0;
+      return false;
     }
   }
-  if (possi->verrel != dvr_none) return 0;
+  if (possi->verrel != dvr_none)
+    return false;
   deppossi *provider;
   if (possi->ed->installed.valid) {
     for (provider= possi->ed->installed.depended;
@@ -401,7 +407,7 @@ int packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade
           !useavailable(provider->up->up) &&
           would_like_to_install(provider->up->up->clientdata->selected,
                                 provider->up->up))
-        return 1;
+        return true;
     }
   }
   if (possi->ed->available.valid) {
@@ -414,7 +420,7 @@ int packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade
                                  provider->up->up))
         continue;
       if (useavailable(provider->up->up))
-        return 1;
+        return true;
       if (fixbyupgrade && !*fixbyupgrade &&
           (!(provider->up->up->status == pkginfo::stat_installed ||
              provider->up->up->status == pkginfo::stat_triggerspending ||
@@ -424,5 +430,5 @@ int packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade
         *fixbyupgrade= provider->up->up->clientdata;
     }
   }
-  return 0;
+  return false;
 }

+ 17 - 11
dselect/pkglist.cc

@@ -490,10 +490,13 @@ packagelist::~packagelist() {
   if (debug) fprintf(debug,"packagelist[%p]::~packagelist() done\n",this);
 }
 
-int packagelist::checksearch(char* rx) {
+bool
+packagelist::checksearch(char *rx)
+{
   int r,opt = REG_NOSUB;
 
-  if (!rx || !*rx) return 0;
+  if (!rx || !*rx)
+    return false;
 
   searchdescr=0;
   if (searchstring[0]) {
@@ -510,7 +513,7 @@ int packagelist::checksearch(char* rx) {
     rx[r++]='\0';
     if (strcspn(rx+r, "di")!=0) {
       displayerror(_("invalid search option given"));
-      return 0;
+      return false;
     }
 
    while (rx[r]) {
@@ -524,31 +527,34 @@ int packagelist::checksearch(char* rx) {
 
   if ((r=regcomp(&searchfsm, rx, opt))!=0) {
     displayerror(_("error in regular expression"));
-    return 0;
+    return false;
   }
   
-  return 1;
+  return true;
 }
 
-int packagelist::matchsearch(int index) {
+bool
+packagelist::matchsearch(int index)
+{
   const char *name;
 
   name = itemname(index);
   if (!name)
-    return 0;	/* Skip things without a name (seperators) */
+    return false;	/* Skip things without a name (seperators) */
 
   if (regexec(&searchfsm, name, 0, NULL, 0) == 0)
-    return 1;
+    return true;
 
   if (searchdescr) {
     const char* descr = table[index]->pkg->available.description;
-    if (!descr || !*descr) return 0;
+    if (!descr || !*descr)
+      return false;
 
     if (regexec(&searchfsm, descr, 0, NULL, 0)==0)
-      return 1;
+      return true;
   }
 
-  return 0;
+  return false;
 }
 
 pkginfo **packagelist::display() {

+ 7 - 7
dselect/pkglist.h

@@ -131,14 +131,14 @@ protected:
   
   // Dependency and sublist processing
   struct doneent { doneent *next; void *dep; } *depsdone, *unavdone;
-  int alreadydone(doneent**, void*);
+  bool alreadydone(doneent **, void *);
   int resolvedepcon(dependency*);
   int checkdependers(pkginfo*, int changemade); // returns new changemade
   int deselect_one_of(pkginfo *er, pkginfo *ed, dependency *dep);
   
   // Define these virtuals
-  int checksearch(char* str);
-  int matchsearch(int index);
+  bool checksearch(char *str);
+  bool matchsearch(int index);
   void redraw1itemsel(int index, int selected);
   void redrawcolheads();
   void redrawthisstate();
@@ -156,7 +156,7 @@ protected:
   pkginfo::pkgwant reallywant(pkginfo::pkgwant, struct perpackagestate*);
   int describemany(char buf[], const char *prioritystring, const char *section,
                    const struct perpackagestate *pps);
-  int deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade);
+  bool deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade);
 
   void sortmakeheads();
   void resortredisplay();
@@ -170,7 +170,7 @@ protected:
   void addheading(enum ssavailval, enum ssstateval,
                   pkginfo::pkgpriority, const char*, const char *section);
   void sortinplace();
-  int affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith);
+  bool affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith);
   void affectedrange(int *startp, int *endp);
   void setwant(pkginfo::pkgwant nw);
   void sethold(int hold);
@@ -203,9 +203,9 @@ protected:
   void add(pkginfo*);
   void add(pkginfo*, pkginfo::pkgwant);
   void add(pkginfo*, const char *extrainfo, showpriority displayimportance);
-  int add(dependency*, showpriority displayimportance);
+  bool add(dependency *, showpriority displayimportance);
   void addunavailable(deppossi*);
-  int useavailable(pkginfo*);
+  bool useavailable(pkginfo *);
   pkginfoperfile *findinfo(pkginfo*);
 
   int resolvesuggest();

+ 12 - 6
dselect/pkgsublist.cc

@@ -76,19 +76,22 @@ void packagelist::add(pkginfo *pkg, const char *extrainfo, showpriority showimp)
   pkg->clientdata->relations.terminate();
 }   
 
-int packagelist::alreadydone(doneent **done, void *check) {
+bool
+packagelist::alreadydone(doneent **done, void *check)
+{
   doneent *search = *done;
   
   while (search && search->dep != check)
     search = search->next;
-  if (search) return 1;
+  if (search)
+    return true;
   if (debug) fprintf(debug,"packagelist[%p]::alreadydone(%p,%p) new\n",
                      this,done,check);
   search= new doneent;
   search->next= *done;
   search->dep= check;
   *done= search;
-  return 0;
+  return false;
 }
 
 void packagelist::addunavailable(deppossi *possi) {
@@ -105,10 +108,13 @@ void packagelist::addunavailable(deppossi *possi) {
   vb(_(" does not appear to be available\n"));
 }
 
-int packagelist::add(dependency *depends, showpriority displayimportance) {
+bool
+packagelist::add(dependency *depends, showpriority displayimportance)
+{
   if (debug) fprintf(debug,"packagelist[%p]::add(dependency[%p])\n",this,depends);
 
-  if (alreadydone(&depsdone,depends)) return 0;
+  if (alreadydone(&depsdone, depends))
+    return false;
   
   const char *comma= "";
   varbuf info;
@@ -152,7 +158,7 @@ int packagelist::add(dependency *depends, showpriority displayimportance) {
       }
     }
   }
-  return 1;
+  return true;
 }
 
 void repeatedlydisplay(packagelist *sub,

+ 4 - 4
lib/dpkg/database.c

@@ -71,8 +71,8 @@ void blankpackage(struct pkginfo *pigp) {
   pigp->section= NULL;
   blankversion(&pigp->configversion);
   pigp->files= NULL;
-  pigp->installed.valid= 0;
-  pigp->available.valid= 0;
+  pigp->installed.valid = false;
+  pigp->available.valid = false;
   pigp->clientdata= NULL;
   pigp->trigaw.head = pigp->trigaw.tail = NULL;
   pigp->othertrigaw_head = NULL;
@@ -82,7 +82,7 @@ void blankpackage(struct pkginfo *pigp) {
 }
 
 void blankpackageperfile(struct pkginfoperfile *pifp) {
-  pifp->essential= 0;
+  pifp->essential = false;
   pifp->depends= NULL;
   pifp->depended= NULL;
   pifp->description= pifp->maintainer= pifp->source= pifp->installedsize= pifp->bugs= pifp->origin= NULL;
@@ -90,7 +90,7 @@ void blankpackageperfile(struct pkginfoperfile *pifp) {
   blankversion(&pifp->version);
   pifp->conffiles= NULL;
   pifp->arbs= NULL;
-  pifp->valid= 1;
+  pifp->valid = true;
 }
 
 static int nes(const char *s) { return s && *s; }

+ 7 - 7
lib/dpkg/dpkg-db.h

@@ -77,7 +77,7 @@ struct deppossi {
   struct deppossi *next, *nextrev, *backrev;
   struct versionrevision version;
   enum depverrel verrel;
-  int cyclebreak;
+  bool cyclebreak;
 };
 
 struct arbitraryfield {
@@ -90,7 +90,7 @@ struct conffile {
   struct conffile *next;
   const char *name;
   const char *hash;
-  int obsolete;
+  bool obsolete;
 };
 
 struct filedetails {
@@ -102,10 +102,10 @@ struct filedetails {
 };
 
 struct pkginfoperfile { /* pif */
-  int valid;
+  bool valid;
   struct dependency *depends;
   struct deppossi *depended;
-  int essential; /* The `essential' flag, 1=yes, 0=no (absent) */
+  bool essential; /* The ‘essential’ flag, true = yes, false = no (absent). */
   const char *description;
   const char *maintainer;
   const char *source;
@@ -243,7 +243,7 @@ int parsedb(const char *filename, enum parsedbflags, struct pkginfo **donep,
 void copy_dependency_links(struct pkginfo *pkg,
                            struct dependency **updateme,
                            struct dependency *newdepends,
-                           int available);
+                           bool available);
 
 /*** from parsehelp.c ***/
 
@@ -258,7 +258,7 @@ extern const struct namevalue statusinfos[];
 extern const struct namevalue eflaginfos[];
 extern const struct namevalue wantinfos[];
 
-int informativeversion(const struct versionrevision *version);
+bool informativeversion(const struct versionrevision *version);
 
 enum versiondisplayepochwhen { vdew_never, vdew_nonambig, vdew_always };
 void varbufversion(struct varbuf*, const struct versionrevision*,
@@ -272,7 +272,7 @@ const char *versiondescribe(const struct versionrevision*,
 void writerecord(FILE*, const char*,
                  const struct pkginfo*, const struct pkginfoperfile*);
 
-void writedb(const char *filename, int available, int mustsync);
+void writedb(const char *filename, bool available, bool mustsync);
 
 void varbufrecord(struct varbuf*, const struct pkginfo*, const struct pkginfoperfile*);
 void varbufdependency(struct varbuf *vb, struct dependency *dep);

+ 3 - 1
lib/dpkg/dump.c

@@ -352,7 +352,9 @@ void writerecord(FILE *file, const char *filename,
    varbuf_destroy(&vb);
 }
 
-void writedb(const char *filename, int available, int mustsync) {
+void
+writedb(const char *filename, bool available, bool mustsync)
+{
   static char writebuf[8192];
   
   struct pkgiterator *it;

+ 3 - 3
lib/dpkg/fields.c

@@ -130,14 +130,14 @@ void f_charfield(struct pkginfo *pigp, struct pkginfoperfile *pifp,
 void f_boolean(struct pkginfo *pigp, struct pkginfoperfile *pifp,
                struct parsedb_state *ps,
                const char *value, const struct fieldinfo *fip) {
-  int boolean;
+  bool boolean;
 
   if (!*value)
     return;
 
   boolean = convert_string(ps, _("yes/no in boolean field"),
                            -1, pigp, value, booleaninfos, NULL);
-  PKGPFIELD(pifp, fip->integer, int) = boolean;
+  PKGPFIELD(pifp, fip->integer, bool) = boolean;
 }
 
 void f_section(struct pkginfo *pigp, struct pkginfoperfile *pifp,
@@ -348,7 +348,7 @@ void f_dependency(struct pkginfo *pigp, struct pkginfoperfile *pifp,
                         * `forward' links in deppossi (`ed') only, and the backward
                         * links from the depended on packages to dop are left undone.
                         */
-      dop->cyclebreak= 0;
+      dop->cyclebreak = false;
 /* skip whitespace after packagename */
       while (isspace(*p)) p++;
       if (*p == '(') {			/* if we have a versioned relation */

+ 3 - 3
lib/dpkg/nfmalloc.c

@@ -33,7 +33,7 @@
 #define obstack_chunk_free free
 
 static struct obstack db_obs;
-static int dbobs_init = 0;
+static bool dbobs_init = false;
 
 /* We use lots of mem, so use a large chunk */
 #define CHUNK_SIZE 8192
@@ -42,7 +42,7 @@ static int dbobs_init = 0;
 
 static void nfobstack_init(void) {
   obstack_init(&db_obs);
-  dbobs_init = 1;
+  dbobs_init = true;
   obstack_chunk_size(&db_obs) = CHUNK_SIZE;
 }
   
@@ -68,6 +68,6 @@ nfstrnsave(const char *string, size_t size)
 void nffreeall(void) {
   if (dbobs_init) {
     obstack_free(&db_obs, NULL);
-    dbobs_init = 0;
+    dbobs_init = false;
   }
 }

+ 2 - 1
lib/dpkg/parse.c

@@ -406,7 +406,8 @@ int parsedb(const char *filename, enum parsedbflags flags,
 void copy_dependency_links(struct pkginfo *pkg,
                            struct dependency **updateme,
                            struct dependency *newdepends,
-                           int available) {
+                           bool available)
+{
   /* This routine is used to update the `reverse' dependency pointers
    * when new `forwards' information has been constructed.  It first
    * removes all the links based on the old information.  The old

+ 5 - 3
lib/dpkg/parsehelp.c

@@ -84,8 +84,8 @@ parse_warn(struct parsedb_state *ps,
 	[v] = { .name = n, .value = v, .length = sizeof(n) - 1 }
 
 const struct namevalue booleaninfos[] = {
-  NAMEVALUE_DEF("no",  0),
-  NAMEVALUE_DEF("yes", 1),
+  NAMEVALUE_DEF("no",  false),
+  NAMEVALUE_DEF("yes", true),
   { .name = NULL }
 };
 
@@ -162,7 +162,9 @@ const struct nickname nicknames[]= {
   { .nick = NULL }
 };
 
-int informativeversion(const struct versionrevision *version) {
+bool
+informativeversion(const struct versionrevision *version)
+{
   return (version->epoch ||
           (version->version && *version->version) ||
           (version->revision && *version->revision));

+ 5 - 5
lib/dpkg/pkg-format.c

@@ -61,7 +61,7 @@ pkg_format_node_new(void)
 	return buf;
 }
 
-static int
+static bool
 parsefield(struct pkg_format_node *cur, const char *fmt, const char *fmtend)
 {
 	int len;
@@ -79,7 +79,7 @@ parsefield(struct pkg_format_node *cur, const char *fmt, const char *fmtend)
 			fprintf(stderr,
 			        _("invalid character `%c' in field width\n"),
 			       *endptr);
-			return 0;
+			return false;
 		}
 
 		if (w < 0) {
@@ -96,10 +96,10 @@ parsefield(struct pkg_format_node *cur, const char *fmt, const char *fmtend)
 	memcpy(cur->data, fmt, len);
 	cur->data[len] = '\0';
 
-	return 1;
+	return true;
 }
 
-static int
+static bool
 parsestring(struct pkg_format_node *cur, const char *fmt, const char *fmtend)
 {
 	int len;
@@ -134,7 +134,7 @@ parsestring(struct pkg_format_node *cur, const char *fmt, const char *fmtend)
 	}
 	*write = '\0';
 
-	return 1;
+	return true;
 }
 
 void

+ 3 - 1
lib/dpkg/progress.h

@@ -21,6 +21,8 @@
 #ifndef LIBDPKG_PROGRESS_H
 #define LIBDPKG_PROGRESS_H
 
+#include <stdbool.h>
+
 #include <dpkg/macros.h>
 
 DPKG_BEGIN_DECLS
@@ -32,7 +34,7 @@ struct progress {
 	int cur;
 	int last_percent;
 
-	int on_tty;
+	bool on_tty;
 };
 
 void progress_init(struct progress *progress, const char *text, int max);

+ 12 - 12
lib/dpkg/triglib.c

@@ -123,40 +123,40 @@ trig_record_activation(struct pkginfo *pend, struct pkginfo *aw, const char *tri
 }
 
 /* NB that this is also called from fields.c where *pend is a temporary! */
-int
+bool
 trig_note_pend_core(struct pkginfo *pend, const char *trig /*not copied!*/)
 {
 	struct trigpend *tp;
 
 	for (tp = pend->trigpend_head; tp; tp = tp->next)
 		if (!strcmp(tp->name, trig))
-			return 0;
+			return false;
 
 	tp = nfmalloc(sizeof(*tp));
 	tp->name = trig;
 	tp->next = pend->trigpend_head;
 	pend->trigpend_head = tp;
 
-	return 1;
+	return true;
 }
 
-/* Returns: 1 for done, 0 for already noted. */
-int
+/* Returns: true for done, false for already noted. */
+bool
 trig_note_pend(struct pkginfo *pend, const char *trig /*not copied!*/)
 {
 	if (!trig_note_pend_core(pend, trig))
-		return 0;
+		return false;
 
 	pend->status = pend->trigaw.head ? stat_triggersawaited :
 	               stat_triggerspending;
 
-	return 1;
+	return true;
 }
 
-/* Returns: 1 for done, 0 for already noted. */
+/* Returns: true for done, false for already noted. */
 /* NB that this is called also from fields.c where *aw is a temporary
  * but pend is from findpackage()! */
-int
+bool
 trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 {
 	struct trigaw *ta;
@@ -164,7 +164,7 @@ trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 	/* We search through aw's list because that's probably shorter. */
 	for (ta = aw->trigaw.head; ta; ta = ta->sameaw.next)
 		if (ta->pend == pend)
-			return 0;
+			return false;
 
 	ta = nfmalloc(sizeof(*ta));
 	ta->aw = aw;
@@ -173,7 +173,7 @@ trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 	pend->othertrigaw_head = ta;
 	LIST_LINK_TAIL_PART(aw->trigaw, ta, sameaw.);
 
-	return 1;
+	return true;
 }
 
 void
@@ -830,7 +830,7 @@ struct filenamenode {
 static struct filenamenode *trigger_files;
 
 static struct filenamenode *
-th_simple_nn_find(const char *name, int nonew)
+th_simple_nn_find(const char *name, bool nonew)
 {
 	struct filenamenode *search;
 

+ 4 - 4
lib/dpkg/triglib.h

@@ -54,7 +54,7 @@ struct trig_hooks {
 	void (*enqueue_deferred)(struct pkginfo *pend);
 	void (*transitional_activate)(enum modstatdb_rw cstatus);
 
-	struct filenamenode *(*namenode_find)(const char *filename, int nonew);
+	struct filenamenode *(*namenode_find)(const char *filename, bool nonew);
 	struct trigfileint **(*namenode_interested)(struct filenamenode *fnn);
 
 	/* Returns a pointer from nfmalloc. */
@@ -74,9 +74,9 @@ char *trig_get_triggersdir(const char *admindir);
 void trig_file_activate_byname(const char *trig, struct pkginfo *aw);
 void trig_file_activate(struct filenamenode *trig, struct pkginfo *aw);
 
-int trig_note_pend_core(struct pkginfo *pend, const char *trig /*not copied!*/);
-int trig_note_pend(struct pkginfo *pend, const char *trig /*not copied!*/);
-int trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
+bool trig_note_pend_core(struct pkginfo *pend, const char *trig /*not copied!*/);
+bool trig_note_pend(struct pkginfo *pend, const char *trig /*not copied!*/);
+bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
 void trig_clear_awaiters(struct pkginfo *notpend);
 
 void trig_enqueue_awaited_pend(struct pkginfo *pend);

+ 11 - 8
src/archives.c

@@ -82,14 +82,14 @@ static int safe_read(int fd, void *buf, int len)
 }
 
 static struct obstack tar_obs;
-static int tarobs_init= 0;
+static bool tarobs_init = false;
 
 /* ensure the obstack is properly initialized */
 static void ensureobstackinit(void) {
 
   if (!tarobs_init) {
     obstack_init(&tar_obs);
-    tarobs_init= 1;
+    tarobs_init = true;
   }
 }
 
@@ -97,7 +97,7 @@ static void ensureobstackinit(void) {
 static void destroyobstack(void) {
   if (tarobs_init) {
     obstack_free(&tar_obs, NULL);
-    tarobs_init= 0;
+    tarobs_init = false;
   }
 }
 
@@ -934,7 +934,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
   int ok;
 
   fixbydeconf = NULL;
-  if (depisok(dep, &why, &fixbydeconf, 0)) {
+  if (depisok(dep, &why, &fixbydeconf, false)) {
     varbuf_destroy(&why);
     return;
   }
@@ -989,7 +989,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
   struct dependency *providecheck;
 
   fixbyrm = NULL;
-  if (depisok(dep, &conflictwhy, &fixbyrm, 0)) {
+  if (depisok(dep, &conflictwhy, &fixbyrm, false)) {
     varbuf_destroy(&conflictwhy);
     varbuf_destroy(&removalwhy);
     return;
@@ -1021,7 +1021,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
              pdep= pdep->nextrev) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
             continue;
-          if (depisok(pdep->up, &removalwhy, NULL, 0))
+          if (depisok(pdep->up, &removalwhy, NULL, false))
             continue;
           varbufaddc(&removalwhy,0);
           if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
@@ -1038,7 +1038,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
                  pdep= pdep->nextrev) {
               if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
                 continue;
-              if (depisok(pdep->up, &removalwhy, NULL, 0))
+              if (depisok(pdep->up, &removalwhy, NULL, false))
                 continue;
               varbufaddc(&removalwhy,0);
               fprintf(stderr, _("dpkg"
@@ -1243,7 +1243,10 @@ void archivefiles(const char *const *argv) {
   modstatdb_shutdown();
 }
 
-int wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver, int saywhy) {
+int
+wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver,
+              bool saywhy)
+{
   /* Decide whether we want to install a new version of the package.
    * ver is the version we might want to install.  If saywhy is 1 then
    * if we skip the package we say what we are doing (and, if we are

+ 3 - 3
src/depcon.c

@@ -85,7 +85,7 @@ foundcyclebroken(struct cyclesofarlink *thislink, struct cyclesofarlink *sofar,
   /* Now we have either a package with no postinst, or the other
    * occurrence of the current package in the list.
    */
-  sol->possi->cyclebreak= 1;
+  sol->possi->cyclebreak = true;
   debug(dbg_depcon,"cycle broken at %s -> %s\n",
         sol->possi->up->up->name, sol->possi->ed->name);
   return true;
@@ -206,14 +206,14 @@ void describedepcon(struct varbuf *addto, struct dependency *dep) {
   
 bool
 depisok(struct dependency *dep, struct varbuf *whynot,
-        struct pkginfo **canfixbyremove, int allowunconfigd)
+        struct pkginfo **canfixbyremove, bool allowunconfigd)
 {
   /* *whynot must already have been initialised; it need not be
    * empty though - it will be reset before use.
    * If depisok returns false for ‘not OK’ it will contain a description,
    * newline-terminated BUT NOT NULL-TERMINATED, of the reason.
    * If depisok returns true it will contain garbage.
-   * allowunconfigd should be non-zero during the `Pre-Depends' checking
+   * allowunconfigd should be true 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.

+ 5 - 5
src/enquiry.c

@@ -126,7 +126,7 @@ void audit(const char *const *argv) {
   struct pkgiterator *it;
   struct pkginfo *pkg;
   const struct badstatinfo *bsi;
-  int head;
+  bool head;
 
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
@@ -134,13 +134,13 @@ void audit(const char *const *argv) {
   modstatdb_init(admindir,msdbrw_readonly);
 
   for (bsi= badstatinfos; bsi->yesno; bsi++) {
-    head= 0;
+    head = false;
     it= iterpkgstart(); 
     while ((pkg= iterpkgnext(it))) {
       if (!bsi->yesno(pkg,bsi)) continue;
       if (!head) {
         fputs(gettext(bsi->explanation),stdout);
-        head= 1;
+        head = true;
       }
       describebriefly(pkg);
     }
@@ -340,7 +340,7 @@ void predeppackage(const char *const *argv) {
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep, &vb, NULL, 1))
+      if (depisok(dep, &vb, NULL, true))
         continue;
       break; /* This will leave dep non-NULL, and so exit the loop. */
     }
@@ -389,7 +389,7 @@ void predeppackage(const char *const *argv) {
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep, &vb, NULL, 1))
+      if (depisok(dep, &vb, NULL, true))
         continue;
       break; /* This will leave dep non-NULL, and so exit the loop. */
     }

+ 1 - 1
src/errors.c

@@ -41,7 +41,7 @@
 
 #include "main.h"
 
-int abort_processing = 0;
+bool abort_processing = false;
 
 static int nerrs = 0;
 

+ 13 - 9
src/filesdb.c

@@ -53,7 +53,7 @@
 
 /*** Generic data structures and routines ***/
 
-static int allpackagesdone= 0;
+static bool allpackagesdone = false;
 static int nfiles= 0;
 
 void
@@ -64,16 +64,16 @@ ensure_package_clientdata(struct pkginfo *pkg)
   pkg->clientdata = nfmalloc(sizeof(struct perpackagestate));
   pkg->clientdata->istobe = itb_normal;
   pkg->clientdata->color = white;
-  pkg->clientdata->fileslistvalid = 0;
+  pkg->clientdata->fileslistvalid = false;
   pkg->clientdata->files = NULL;
   pkg->clientdata->listfile_phys_offs = 0;
   pkg->clientdata->trigprocdeferred = NULL;
 }
 
 void note_must_reread_files_inpackage(struct pkginfo *pkg) {
-  allpackagesdone= 0;
+  allpackagesdone = false;
   ensure_package_clientdata(pkg);
-  pkg->clientdata->fileslistvalid= 0;
+  pkg->clientdata->fileslistvalid = false;
 }
 
 static int saidread=0;
@@ -200,7 +200,8 @@ ensure_packagefiles_available(struct pkginfo *pkg)
 
   /* Packages which aren't installed don't have a files list. */
   if (pkg->status == stat_notinstalled) {
-    pkg->clientdata->fileslistvalid= 1; return;
+    pkg->clientdata->fileslistvalid = true;
+    return;
   }
 
   filelistfile= pkgadminfile(pkg,LISTFILE);
@@ -219,7 +220,7 @@ ensure_packagefiles_available(struct pkginfo *pkg)
                 "package has no files currently installed."), pkg->name);
     }
     pkg->clientdata->files = NULL;
-    pkg->clientdata->fileslistvalid= 1;
+    pkg->clientdata->fileslistvalid = true;
     return;
   }
 
@@ -259,7 +260,7 @@ ensure_packagefiles_available(struct pkginfo *pkg)
 
   onerr_abort--;
 
-  pkg->clientdata->fileslistvalid= 1;
+  pkg->clientdata->fileslistvalid = true;
 }
 
 #if defined(HAVE_LINUX_FIEMAP_H)
@@ -382,7 +383,7 @@ void ensure_allinstfiles_available(void) {
 
   pkg_array_destroy(&array);
 
-  allpackagesdone= 1;
+  allpackagesdone = true;
 
   if (saidread==1) {
     progress_done(&progress);
@@ -396,7 +397,10 @@ void ensure_allinstfiles_available_quiet(void) {
   ensure_allinstfiles_available();
 }
 
-void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list, int leaveout) {
+void
+write_filelist_except(struct pkginfo *pkg, struct fileinlist *list,
+                      bool leaveout)
+{
   /* If leaveout is nonzero, will not write any file whose filenamenode
    * has the fnnf_elide_other_lists flag set.
    */

+ 2 - 1
src/filesdb.h

@@ -152,7 +152,8 @@ void ensure_allinstfiles_available(void);
 void ensure_allinstfiles_available_quiet(void);
 void note_must_reread_files_inpackage(struct pkginfo *pkg);
 struct filenamenode *findnamenode(const char *filename, enum fnnflags flags);
-void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list, int leaveout);
+void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list,
+                           bool leaveout);
 
 struct reversefilelistiter { struct fileinlist *todo; };
 

+ 5 - 4
src/main.c

@@ -570,7 +570,8 @@ void commandfd(const char *const *argv) {
   char *ptr, *endptr;
   FILE *in;
   unsigned long infd;
-  int c, lno, i, skipchar;
+  int c, lno, i;
+  bool skipchar;
   void (*actionfunction)(const char *const *argv);
 
   pipein = *argv++;
@@ -614,14 +615,14 @@ void commandfd(const char *const *argv) {
     argc= 1;
     ptr= linevb.buf;
     endptr= ptr + linevb.used;
-    skipchar= 0;
+    skipchar = false;
     while(ptr < endptr) {
       if (skipchar) {
-	skipchar= 0;
+	skipchar = false;
       } else if (*ptr == '\\') {
 	memmove(ptr, (ptr+1), (linevb.used-(linevb.buf - ptr)-1));
 	endptr--;
-	skipchar= 1;
+	skipchar = true;
 	continue;
       } else if (isspace(*ptr)) {
 	if (mode == 1) {

+ 5 - 4
src/main.h

@@ -46,7 +46,7 @@ struct perpackagestate {
    *       1            !=0          read, all is OK
    *       1             0           read OK, but, there were no files
    */
-  int fileslistvalid;
+  bool fileslistvalid;
   struct fileinlist *files;
   int replacingfilesandsaid;
 
@@ -131,7 +131,7 @@ extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;
 extern int fc_conff_old, fc_conff_def;
 extern int fc_badverify;
 
-extern int abort_processing;
+extern bool abort_processing;
 extern int errabort;
 extern const char *admindir;
 extern const char *instdir;
@@ -147,7 +147,8 @@ struct invoke_hook {
 
 void archivefiles(const char *const *argv);
 void process_archive(const char *filename);
-int wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver, int saywhy);
+int wanttoinstall(struct pkginfo *pkg, const struct versionrevision *ver,
+                  bool saywhy);
 struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
 				   struct filenamenode *namenode);
 
@@ -282,7 +283,7 @@ void trig_activate_packageprocessing(struct pkginfo *pkg);
 /* from depcon.c */
 
 bool depisok(struct dependency *dep, struct varbuf *whynot,
-             struct pkginfo **fixbyrm, int allowunconfigd);
+             struct pkginfo **fixbyrm, bool allowunconfigd);
 struct cyclesofarlink;
 bool findbreakcycle(struct pkginfo *pkg);
 void describedepcon(struct varbuf *addto, struct dependency *dep);

+ 5 - 5
src/processarc.c

@@ -314,7 +314,7 @@ void process_archive(const char *filename) {
       /* Ignore these here. */
       break;
     case dep_predepends:
-      if (!depisok(dsearch, &depprobwhy, NULL, 1)) {
+      if (!depisok(dsearch, &depprobwhy, NULL, true)) {
         varbufaddc(&depprobwhy,0);
         fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
                 pfilename, pkg->name, depprobwhy.buf);
@@ -965,7 +965,7 @@ void process_archive(const char *filename) {
         newpossi->version= possi->version;
       else
         blankversion(&newpossi->version);
-      newpossi->cyclebreak= 0;
+      newpossi->cyclebreak = false;
       *newpossilastp= newpossi;
       newpossilastp= &newpossi->next;
     }
@@ -1055,7 +1055,7 @@ void process_archive(const char *filename) {
          pdep= pdep->nextrev) {
       if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
           pdep->up->type != dep_recommends) continue;
-      if (depisok(pdep->up, &depprobwhy, NULL, 0))
+      if (depisok(pdep->up, &depprobwhy, NULL, false))
         continue;
       varbufaddc(&depprobwhy,0);
       debug(dbg_veryverbose,"process_archive cannot disappear: %s",depprobwhy.buf);
@@ -1073,7 +1073,7 @@ void process_archive(const char *filename) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
               pdep->up->type != dep_recommends)
             continue;
-          if (depisok(pdep->up, &depprobwhy, NULL, 0))
+          if (depisok(pdep->up, &depprobwhy, NULL, false))
             continue;
           varbufaddc(&depprobwhy,0);
           debug(dbg_veryverbose,"process_archive cannot disappear (provides %s): %s",
@@ -1139,7 +1139,7 @@ void process_archive(const char *filename) {
     blankversion(&otherpkg->configversion);
     blankpackageperfile(&otherpkg->installed);
 
-    otherpkg->clientdata->fileslistvalid= 0;
+    otherpkg->clientdata->fileslistvalid = false;
 
     modstatdb_note(otherpkg);
 

+ 5 - 4
src/query.c

@@ -74,7 +74,7 @@ static int getwidth(void) {
 }
 
 static void
-list1package(struct pkginfo *pkg, int *head, struct pkg_array *array)
+list1package(struct pkginfo *pkg, bool *head, struct pkg_array *array)
 {
   int i,l,w;
   static int nw,vw,dw;
@@ -122,7 +122,7 @@ Desired=Unknown/Install/Remove/Purge/Hold\n\
     for (l=0;l<vw;l++) printf("="); printf("-");	/* version */
     for (l=0;l<dw;l++) printf("="); 			/* description */
     printf("\n");
-    *head= 1;
+    *head = true;
   }
   if (!pkg->installed.valid) blankpackageperfile(&pkg->installed);
   limiteddescription(pkg,dw,&pdesc,&l);
@@ -140,14 +140,15 @@ listpackages(const char *const *argv)
 {
   struct pkg_array array;
   struct pkginfo *pkg;
-  int i, head;
+  int i;
+  bool head;
 
   modstatdb_init(admindir,msdbrw_readonly);
 
   pkg_array_init_from_db(&array);
   pkg_array_sort(&array, pkg_sorter_by_name);
 
-  head = 0;
+  head = false;
 
   if (!*argv) {
     for (i = 0; i < array.n_pkgs; i++) {

+ 12 - 7
src/remove.c

@@ -181,7 +181,7 @@ static void push_leftover(struct fileinlist **leftoverp,
 
 static void removal_bulk_remove_files(
     struct pkginfo *pkg, 
-    int *out_foundpostrm) 
+    bool *out_foundpostrm)
 {
   int before;
   int infodirbaseused;
@@ -271,7 +271,7 @@ static void removal_bulk_remove_files(
     varbufaddc(&fnvb,0);
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
     push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
-  *out_foundpostrm= 0;
+    *out_foundpostrm = false;
 
     debug(dbg_general, "removal_bulk cleaning info directory");
 
@@ -286,7 +286,10 @@ static void removal_bulk_remove_files(
       debug(dbg_stupidlyverbose, "removal_bulk info this pkg");
       /* We need the postrm and list files for --purge. */
       if (!strcmp(p+1,LISTFILE)) continue;
-    if (!strcmp(p+1,POSTRMFILE)) { *out_foundpostrm=1; continue; }
+      if (!strcmp(p + 1, POSTRMFILE)) {
+        *out_foundpostrm = true;
+        continue;
+      }
       debug(dbg_stupidlyverbose, "removal_bulk info not postrm or list");
       fnvb.used= infodirbaseused;
       varbufaddstr(&fnvb,de->d_name);
@@ -302,7 +305,7 @@ static void removal_bulk_remove_files(
     pop_cleanup(ehflag_normaltidy); /* closedir */
     
     pkg->status= stat_configfiles;
-    pkg->installed.essential= 0;
+    pkg->installed.essential = false;
     modstatdb_note(pkg);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 }
@@ -508,7 +511,7 @@ void removal_bulk(struct pkginfo *pkg) {
    */
 
   int pkgnameused;
-  int foundpostrm= 0;
+  bool foundpostrm = false;
   const char *postrmfilename;
 
   debug(dbg_general,"removal_bulk package %s",pkg->name);
@@ -521,8 +524,10 @@ void removal_bulk(struct pkginfo *pkg) {
     struct stat stab;
 
     postrmfilename= pkgadminfile(pkg,POSTRMFILE);
-    if (!lstat(postrmfilename,&stab)) foundpostrm= 1;
-    else if (errno == ENOENT) foundpostrm= 0;
+    if (!lstat(postrmfilename, &stab))
+      foundpostrm = true;
+    else if (errno == ENOENT)
+      foundpostrm = false;
     else ohshite(_("unable to check existence of `%.250s'"),postrmfilename);
 
   }

+ 2 - 2
src/trigcmd.c

@@ -98,7 +98,7 @@ static const char *admindir = ADMINDIR;
 static int f_noact, f_check;
 
 static const char *bypackage, *activate;
-static int done_trig, ctrig;
+static bool done_trig, ctrig;
 
 static void
 noawait(const struct cmdinfo *ci, const char *value)
@@ -120,7 +120,7 @@ tdm_add_trig_begin(const char *trig)
 	if (!ctrig || done_trig)
 		return;
 	yespackage(bypackage);
-	done_trig = 1;
+	done_trig = true;
 }
 
 static void

+ 3 - 3
src/trigproc.c

@@ -151,13 +151,13 @@ struct trigcycleperpkg {
 	struct trigpend *then_trigs;
 };
 
-static int tortoise_advance;
+static bool tortoise_advance;
 static struct trigcyclenode *tortoise, *hare;
 
 void
 trigproc_reset_cycle(void)
 {
-	tortoise_advance = 0;
+	tortoise_advance = false;
 	tortoise = hare = NULL;
 }
 
@@ -391,7 +391,7 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
 /*========== hook setup ==========*/
 
 static struct filenamenode *
-th_proper_nn_find(const char *name, int nonew)
+th_proper_nn_find(const char *name, bool nonew)
 {
 	return findnamenode(name, nonew ? fnn_nonew : 0);
 }

+ 5 - 4
utils/start-stop-daemon.c

@@ -1305,7 +1305,8 @@ set_what_stop(const char *str)
 static int
 run_stop_schedule(void)
 {
-	int r, position, n_killed, n_notkilled, value, ratio, anykilled, retry_nr;
+	int r, position, n_killed, n_notkilled, value, ratio, retry_nr;
+	bool anykilled;
 	struct timeval stopat, before, after, interval, maxinterval;
 
 	if (testmode) {
@@ -1327,7 +1328,7 @@ run_stop_schedule(void)
 	else
 		fatal("internal error, no match option, please report");
 
-	anykilled = 0;
+	anykilled = false;
 	retry_nr = 0;
 
 	if (schedule == NULL) {
@@ -1335,7 +1336,7 @@ run_stop_schedule(void)
 		if (n_notkilled > 0 && quietmode <= 0)
 			printf("%d pids were not killed\n", n_notkilled);
 		if (n_killed)
-			anykilled = 1;
+			anykilled = true;
 		goto x_finished;
 	}
 
@@ -1352,7 +1353,7 @@ run_stop_schedule(void)
 			if (!n_killed)
 				goto x_finished;
 			else
-				anykilled = 1;
+				anykilled = true;
 			goto next_item;
 		case sched_timeout:
  /* We want to keep polling for the processes, to see if they've exited,