The following commit has been merged in the master branch:
commit e62eaa93a1eb43c00aa5b9d58ca4ab975dcd53a5
Author: Guillem Jover <guil...@debian.org>
Date:   Sat Jul 17 19:12:24 2010 +0200

    Use varbuf_trunc instead of directly assigning to member 'used'

diff --git a/src/archives.c b/src/archives.c
index 5430be9..2b5b87e 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -285,16 +285,16 @@ set_selinux_path_context(const char *matchpath, const 
char *path, mode_t mode)
 }
 
 void setupfnamevbs(const char *filename) {
-  fnamevb.used= fnameidlu;
+  varbuf_trunc(&fnamevb, fnameidlu);
   varbufaddstr(&fnamevb,filename);
   varbufaddc(&fnamevb,0);
 
-  fnametmpvb.used= fnameidlu;
+  varbuf_trunc(&fnametmpvb, fnameidlu);
   varbufaddstr(&fnametmpvb,filename);
   varbufaddstr(&fnametmpvb,DPKGTEMPEXT);
   varbufaddc(&fnametmpvb,0);
 
-  fnamenewvb.used= fnameidlu;
+  varbuf_trunc(&fnamenewvb, fnameidlu);
   varbufaddstr(&fnamenewvb,filename);
   varbufaddstr(&fnamenewvb,DPKGNEWEXT);
   varbufaddc(&fnamenewvb,0);
@@ -790,7 +790,8 @@ int tarobject(struct TarInfo *ti) {
       if (r < 0)
         ohshite(_("unable to read link `%.255s'"), ti->Name);
       assert(r == stab.st_size);
-      symlinkfn.used= r; varbufaddc(&symlinkfn,0);
+      varbuf_trunc(&symlinkfn, r);
+      varbufaddc(&symlinkfn, '\0');
       if (symlink(symlinkfn.buf,fnametmpvb.buf))
         ohshite(_("unable to make backup symlink for `%.255s'"),ti->Name);
       if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
diff --git a/src/configure.c b/src/configure.c
index e717cfc..8300738 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -415,7 +415,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, 
const char *in)
                                return -1;
                        }
                        assert(r == stab.st_size); /* XXX: debug */
-                       target.used = r;
+                       varbuf_trunc(&target, r);
                        varbufaddc(&target, '\0');
 
                        debug(dbg_conffdetail,
@@ -439,7 +439,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, 
const char *in)
                                }
                                if (result->buf[r] == '/')
                                        r++;
-                               result->used = r;
+                               varbuf_trunc(result, r);
                                debug(dbg_conffdetail,
                                      "conffderef readlink relative to '%.*s'",
                                      (int)result->used, result->buf);
diff --git a/src/processarc.c b/src/processarc.c
index 6a177f9..d955e8a 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -688,7 +688,7 @@ void process_archive(const char *filename) {
     usenode = namenodetouse(namenode, pkg);
     trig_file_activate(usenode, pkg);
 
-    fnamevb.used= fnameidlu;
+    varbuf_trunc(&fnamevb, fnameidlu);
     varbufaddstr(&fnamevb, usenode->name);
     varbufaddc(&fnamevb,0);
 
@@ -854,7 +854,7 @@ void process_archive(const char *filename) {
     if (strlen(p) > MAXCONTROLFILENAME)
       ohshit(_("old version of package has overly-long info file name starting 
`%.250s'"),
              de->d_name);
-    infofnvb.used= infodirlen;
+    varbuf_trunc(&infofnvb, infodirlen);
     varbufaddstr(&infofnvb,de->d_name);
     varbufaddc(&infofnvb,0);
     strcpy(cidirrest,p);
@@ -1120,7 +1120,7 @@ void process_archive(const char *filename) {
       if (strlen(otherpkg->name) != (size_t)(p-de->d_name) ||
           strncmp(de->d_name,otherpkg->name,p-de->d_name)) continue;
       debug(dbg_stupidlyverbose, "process_archive info this pkg");
-      fnvb.used= infodirbaseused;
+      varbuf_trunc(&fnvb, infodirbaseused);
       varbufaddstr(&fnvb,de->d_name);
       varbufaddc(&fnvb,0);
       if (unlink(fnvb.buf))
@@ -1218,7 +1218,7 @@ void process_archive(const char *filename) {
    */
   for (cfile= newfileslist; cfile; cfile= cfile->next) {
     if (cfile->namenode->flags & fnnf_new_conff) continue;
-    fnametmpvb.used= fnameidlu;
+    varbuf_trunc(&fnametmpvb, fnameidlu);
     varbufaddstr(&fnametmpvb,namenodetouse(cfile->namenode,pkg)->name);
     varbufaddstr(&fnametmpvb,DPKGTEMPEXT);
     varbufaddc(&fnametmpvb,0);
diff --git a/src/querycmd.c b/src/querycmd.c
index 0cb54ca..d0cfe86 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -258,7 +258,8 @@ searchfiles(const char *const *argv)
       varbufaddstr(&path, thisarg);
       varbufaddc(&path, '\0');
 
-      path.used = path_rtrim_slash_slashdot(path.buf);
+      varbuf_trunc(&path, path_rtrim_slash_slashdot(path.buf));
+
       thisarg = path.buf;
     }
 
@@ -528,7 +529,7 @@ control_path_pkg(struct pkginfo *pkg)
     if (strlen(p) > MAXCONTROLFILENAME)
       continue;
 
-    db_path.used = db_path_len;
+    varbuf_trunc(&db_path, db_path_len);
     varbufaddstr(&db_path, db_de->d_name);
     varbufaddc(&db_path, '\0');
 
diff --git a/src/remove.c b/src/remove.c
index 571e1b0..2508ba9 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -66,7 +66,9 @@ static void checkforremoval(struct pkginfo *pkgtoremove,
     before= raemsgs->used;
     ok= dependencies_ok(depender,pkgtoremove,raemsgs);
     if (ok == 0 && depender->clientdata->istobe == itb_remove) ok= 1;
-    if (ok == 1) raemsgs->used= before; /* Don't burble about reasons for 
deferral */
+    if (ok == 1)
+      /* Don't burble about reasons for deferral. */
+      varbuf_trunc(raemsgs, before);
     if (ok < *rokp) *rokp= ok;
   }
 }
@@ -221,13 +223,13 @@ static void removal_bulk_remove_files(
       
       ensure_pathname_nonexisting(fnvb.buf);
       
-      fnvb.used= before;
+      varbuf_trunc(&fnvb, before);
       varbufaddstr(&fnvb,DPKGNEWEXT);
       varbufaddc(&fnvb,0);
       debug(dbg_eachfiledetail, "removal_bulk cleaning new `%s'", fnvb.buf);
       ensure_pathname_nonexisting(fnvb.buf);
       
-      fnvb.used= before;
+      varbuf_trunc(&fnvb, before);
       varbufaddc(&fnvb,0);
       if (!stat(fnvb.buf,&stab) && S_ISDIR(stab.st_mode)) {
         debug(dbg_eachfiledetail, "removal_bulk is a directory");
@@ -289,7 +291,7 @@ static void removal_bulk_remove_files(
         continue;
       }
       debug(dbg_stupidlyverbose, "removal_bulk info not postrm or list");
-      fnvb.used= infodirbaseused;
+      varbuf_trunc(&fnvb, infodirbaseused);
       varbufaddstr(&fnvb,de->d_name);
       varbufaddc(&fnvb,0);
       if (unlink(fnvb.buf))
@@ -483,7 +485,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo 
*pkg) {
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry not it");
         continue;
       yes_remove:
-        removevb.used= removevbbase;
+        varbuf_trunc(&removevb, removevbbase);
         varbufaddstr(&removevb,de->d_name); varbufaddc(&removevb,0);
         debug(dbg_conffdetail, "removal_bulk conffile dsd entry removing `%s'",
               removevb.buf);
@@ -563,7 +565,7 @@ void removal_bulk(struct pkginfo *pkg) {
     debug(dbg_general, "removal_bulk purge done, removing list `%s'",fnvb.buf);
     if (unlink(fnvb.buf) && errno != ENOENT) ohshite(_("cannot remove old 
files list"));
     
-    fnvb.used= pkgnameused;
+    varbuf_trunc(&fnvb, pkgnameused);
     varbufaddstr(&fnvb,"." POSTRMFILE);
     varbufaddc(&fnvb,0);
     debug(dbg_general, "removal_bulk purge done, removing postrm 
`%s'",fnvb.buf);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to