+2008-06-04 Guillem Jover <guillem@debian.org>
+
+ * lib/dpkg-db.h (VARBUF_INIT): New macro.
+ * lib/compression.c (decompress_cat, compress_cat): Use VARBUF_INIT
+ instead of varbufinit to initialize the variables.
+ * lib/dump.c (writerecord, writedb): Likewise.
+ * lib/mlib.c (buffer_copy_setup_dual): Likewise.
+ * lib/showpkg.c (show1package): Likewise.
+ * src/archives.c (check_breaks, check_conflict): Likewise.
+ * src/configure.c (deferred_configure): Likewise.
+ * src/depcon.c (describedepcon): Likewise.
+ * src/main.c (commandfd): Likewise.
+ * src/packages.c (breaks_check_one, dependencies_ok): Likewise.
+ * src/query.c (searchfiles): Likewise.
+ * src/remove.c (deferred_remove): Likewise.
+ * src/select.c (setselections): Likewise.
+
2008-06-04 Guillem Jover <guillem@debian.org>
* src/archives.c (archivefiles): Use varbufreset instead of varbufinit
void decompress_cat(enum compress_type type, int fd_in, int fd_out, char *desc, ...) {
va_list al;
- struct varbuf v;
-
- varbufinit(&v);
+ struct varbuf v = VARBUF_INIT;
va_start(al,desc);
varbufvprintf(&v, desc, al);
void compress_cat(enum compress_type type, int fd_in, int fd_out, const char *compression, char *desc, ...) {
va_list al;
- struct varbuf v;
+ struct varbuf v = VARBUF_INIT;
char combuf[6];
- varbufinit(&v);
-
va_start(al,desc);
varbufvprintf(&v, desc, al);
va_end(al);
struct varbuf;
+#define VARBUF_INIT { 0, 0, NULL }
+
extern void varbufaddc(struct varbuf *v, int c);
extern void varbufdupc(struct varbuf *v, int c, ssize_t s);
int varbufprintf(struct varbuf *v, const char *fmt, ...) PRINTFFORMAT(2,3);
extern void varbufaddbuf(struct varbuf *v, const void *s, const int l);
/* varbufinit must be called exactly once before the use of each varbuf
- * (including before any call to varbuffree).
+ * (including before any call to varbuffree), or the variable must be
+ * initialized with VARBUF_INIT.
*
* However, varbufs allocated `static' are properly initialised anyway and
* do not need varbufinit; multiple consecutive calls to varbufinit before
void writerecord(FILE *file, const char *filename,
const struct pkginfo *pigp, const struct pkginfoperfile *pifp) {
- struct varbuf vb;
+ struct varbuf vb = VARBUF_INIT;
- varbufinit(&vb);
varbufrecord(&vb,pigp,pifp);
varbufaddc(&vb,'\0');
if (fputs(vb.buf,file) < 0)
char *oldfn, *newfn;
const char *which;
FILE *file;
- struct varbuf vb;
+ struct varbuf vb = VARBUF_INIT;
int old_umask;
which= available ? "available" : "status";
strcpy(oldfn,filename); strcat(oldfn,OLDDBEXT);
newfn= m_malloc(strlen(filename)+sizeof(NEWDBEXT));
strcpy(newfn,filename); strcat(newfn,NEWDBEXT);
- varbufinit(&vb);
old_umask = umask(022);
file= fopen(newfn,"w");
{\
va_list al;\
buffer_arg a1, a2;\
- struct varbuf v;\
+ struct varbuf v = VARBUF_INIT;\
off_t ret;\
a1.name1 = n1; a2.name2 = n2;\
- varbufinit(&v);\
va_start(al,desc);\
varbufvprintf(&v, desc, al);\
va_end(al);\
void show1package(const struct lstitem* head, struct pkginfo *pkg) {
- struct varbuf vb, fb, wb;
+ struct varbuf vb = VARBUF_INIT, fb = VARBUF_INIT, wb = VARBUF_INIT;
/* Make sure we have package info available, even if it's all empty. */
if (!pkg->installed.valid)
blankpackageperfile(&pkg->installed);
- varbufinit(&vb);
- varbufinit(&fb);
- varbufinit(&wb);
-
while (head) {
int ok;
char fmt[16];
void check_breaks(struct dependency *dep, struct pkginfo *pkg,
const char *pfilename) {
struct pkginfo *fixbydeconf;
- struct varbuf why;
+ struct varbuf why = VARBUF_INIT;
int ok;
- varbufinit(&why);
-
fixbydeconf = NULL;
if (depisok(dep, &why, &fixbydeconf, 0)) {
varbuffree(&why);
const char *pfilename) {
struct pkginfo *fixbyrm;
struct deppossi *pdep, flagdeppossi;
- struct varbuf conflictwhy, removalwhy;
+ struct varbuf conflictwhy = VARBUF_INIT, removalwhy = VARBUF_INIT;
struct dependency *providecheck;
-
- varbufinit(&conflictwhy);
- varbufinit(&removalwhy);
fixbyrm = NULL;
if (depisok(dep, &conflictwhy, &fixbyrm, 0)) {
* Try 4 (only if --force-depends).
* Do anyway.
*/
- struct varbuf aemsgs, cdr, cdr2;
+ struct varbuf aemsgs = VARBUF_INIT;
+ struct varbuf cdr = VARBUF_INIT, cdr2 = VARBUF_INIT;
char *cdr2rest;
int ok, r, useredited, distedited;
struct conffile *conff;
if (findbreakcycle(pkg))
sincenothing= 0;
- varbufinit(&aemsgs);
ok = dependencies_ok(pkg, NULL, &aemsgs);
if (ok == 1) {
varbuffree(&aemsgs);
* If `*.dpkg-new' no longer exists we assume that we've already
* processed this one.
*/
- varbufinit(&cdr);
- varbufinit(&cdr2);
for (conff= pkg->installed.conffiles; conff; conff= conff->next) {
r= conffderef(pkg, &cdr, conff->name);
if (r == -1) {
void describedepcon(struct varbuf *addto, struct dependency *dep) {
const char *fmt;
- struct varbuf depstr;
+ struct varbuf depstr = VARBUF_INIT;
switch (dep->type) {
case dep_depends:
internerr("unknown deptype");
}
- varbufinit(&depstr);
varbufdependency(&depstr, dep);
varbufaddc(&depstr, 0);
void commandfd(const char *const *argv) {
jmp_buf ejbuf;
- struct varbuf linevb;
+ struct varbuf linevb = VARBUF_INIT;
const char * pipein;
const char **newargs;
char *ptr, *endptr;
if (setjmp(ejbuf)) { /* expect warning about possible clobbering of argv */
error_unwind(ehflag_bombout); exit(2);
}
- varbufinit(&linevb);
+
for (;;lno= 0) {
const char **oldargs= NULL;
int argc= 1, mode= 0;
struct pkginfo *broken,
struct pkginfo *breaker,
struct pkginfo *virtbroken) {
- struct varbuf depmsg;
+ struct varbuf depmsg = VARBUF_INIT;
debug(dbg_depcondetail, " checking breaker %s virtbroken %s",
breaker->name, virtbroken ? virtbroken->name : "<none>");
if (ignore_depends(breaker)) return;
if (virtbroken && ignore_depends(virtbroken)) return;
- varbufinit(&depmsg);
varbufdependency(&depmsg, breaks->up);
varbufaddc(&depmsg, 0);
varbufprintf(aemsgs, _(" %s (%s) breaks %s and is %s.\n"),
int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
struct varbuf *aemsgs) {
int ok, matched, found, thisf, interestingwarnings, anycannotfixbytrig;
- struct varbuf oemsgs;
+ struct varbuf oemsgs = VARBUF_INIT;
struct dependency *dep;
struct deppossi *possi, *provider;
struct pkginfo *possfixbytrig, *canfixbytrig;
- varbufinit(&oemsgs);
interestingwarnings= 0;
ok= 2; /* 2=ok, 1=defer, 0=halt */
debug(dbg_depcon,"checking dependencies of %s (- %s)",
const char *thisarg;
int found;
struct varbuf path;
- static struct varbuf vb;
+ static struct varbuf vb = VARBUF_INIT;
if (!*argv)
badusage(_("--search needs at least one file name pattern argument"));
- varbufinit(&path);
-
modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
ensure_allinstfiles_available_quiet();
ensure_diversions();
}
void deferred_remove(struct pkginfo *pkg) {
- struct varbuf raemsgs;
+ struct varbuf raemsgs = VARBUF_INIT;
int rok;
struct dependency *dep;
if (!f_noact) modstatdb_note(pkg);
debug(dbg_general,"checking dependencies for remove `%s'",pkg->name);
- varbufinit(&raemsgs);
rok= 2;
checkforremoval(pkg,pkg,&rok,&raemsgs);
for (dep= pkg->installed.depends; dep; dep= dep->next) {
struct pkginfo *pkg;
const char *e;
int c, lno;
- struct varbuf namevb;
- struct varbuf selvb;
+ struct varbuf namevb = VARBUF_INIT;
+ struct varbuf selvb = VARBUF_INIT;
if (*argv)
badusage(_("--%s takes no arguments"), cipaction->olong);
modstatdb_init(admindir,msdbrw_write);
- varbufinit(&namevb);
- varbufinit(&selvb);
lno= 1;
for (;;) {
varbufreset(&namevb);