Parcourir la source

Use NULL instead of 0

Guillem Jover il y a 18 ans
Parent
commit
02680ecbbb
21 fichiers modifiés avec 322 ajouts et 244 suppressions
  1. 42 0
      ChangeLog
  2. 6 4
      dpkg-deb/build.c
  3. 2 2
      dpkg-deb/extract.c
  4. 5 5
      dpkg-deb/info.c
  5. 27 25
      dpkg-deb/main.c
  6. 2 1
      dpkg-split/join.c
  7. 2 1
      dpkg-split/queue.c
  8. 6 6
      lib/dpkg.h
  9. 22 18
      src/archives.c
  10. 4 4
      src/configure.c
  11. 8 5
      src/depcon.c
  12. 18 15
      src/enquiry.c
  13. 2 2
      src/errors.c
  14. 34 29
      src/filesdb.c
  15. 8 6
      src/help.c
  16. 44 40
      src/main.c
  17. 9 9
      src/packages.c
  18. 52 44
      src/processarc.c
  19. 16 16
      src/remove.c
  20. 3 2
      src/update.c
  21. 10 10
      utils/start-stop-daemon.c

+ 42 - 0
ChangeLog

@@ -1,3 +1,45 @@
+2008-01-16  Guillem Jover  <guillem@debian.org>
+
+	* dpkg-deb/build.c (do_build): Use NULL instead of 0.
+	* dpkg-deb/extract.c (extracthalf, do_fsystarfile): Likewise.
+	* dpkg-deb/info.c (info_prepare, info_spew): Likewise.
+	(do_contents, do_field): Likewise.
+	* dpkg-deb/main.c (cipaction, action, cmdinfos, main): Likewise.
+	* dpkg-split/join.c (do_join): Likewise.
+	* dpkg-split/queue.c (do_auto): Likewise.
+	* lib/dpkg.h (standard_startup, standard_shutdown): Likewise.
+	* src/archives.c (destroyobstack, deconfigure, addfiletolist)
+	(tarobject, check_breaks, check_conflict, archivefiles)
+	(newconff_append): Likewise.
+	* src/configure.c (deferred_configure, conffderef, md5hash): Likewise.
+	* src/depcon.c (findbreakcyclerecursive, findbreakcycle)
+	(depisok): Likewise.
+	* src/enquiry.c (limiteddescription, badstatinfos, unpackchk)
+	(assertversion, assertpredep, assertepoch, assertlongfilenames)
+	(assertmulticonrep, predeppackage, cmpversions): Likewise.
+	* src/errors.c (reports, print_error_perpackage): Likewise.
+	* src/filesdb.c (diversions, diversionsfile, statoverridefile)
+	(ensure_packagefiles_available, ensure_allinstfiles_available)
+	(write_filelist_except, reversefilelist_init, reversefilelist_next)
+	(ensure_diversions, iterfilestart, iterfilenext, filesdbinit)
+	(findnamenode): Likewise.
+	* src/help.c (checkpath, ensure_package_clientdata
+	(vbuildarglist, cu_restorescriptsignals, script_catchsignals)
+	(clear_istobes): Likewise.
+	* src/main.c (cipaction, ignoredepends, forceinfos)
+	(ACTION, OBSOLETE, ACTIONBACKEND, cmdinfos)
+	(execbackend, commandfd, main): Likewise.
+	* src/packages.c (queuehead, add_to_queue, packages, process_queue)
+	(breakses_ok, dependencies_ok): Likewise.
+	* src/processarc.c (process_archive): Likewise.
+	* src/remove.c (deferred_remove, removal_bulk_remove_files)
+	(removal_bulk_remove_leftover_dirs, removal_bulk_remove_configfiles)
+	(removal_bulk): Likewise.
+	* src/update.c (updateavailable): Likewise.
+	* utils/start-stop-daemon.c (xgettimeofday, run_stop_schedule)
+	(parse_options): Likewise.
+	(pid_is_cmd, pid_is_user, pid_is_exec) [HAVE_KVM_H]: Likewise.
+
 2008-01-15  Raphael Hertzog  <hertzog@debian.org>
 2008-01-15  Raphael Hertzog  <hertzog@debian.org>
 
 
 	* scripts/dpkg-shlibdeps.pl (filter_deps): Fix filtering of
 	* scripts/dpkg-shlibdeps.pl (filter_deps): Fix filtering of

+ 6 - 4
dpkg-deb/build.c

@@ -169,7 +169,7 @@ static void free_filist(struct _finfo* fi) {
  */
  */
 void do_build(const char *const *argv) {
 void do_build(const char *const *argv) {
   static const char *const maintainerscripts[]= {
   static const char *const maintainerscripts[]= {
-    PREINSTFILE, POSTINSTFILE, PRERMFILE, POSTRMFILE, 0
+    PREINSTFILE, POSTINSTFILE, PRERMFILE, POSTRMFILE, NULL
   };
   };
   
   
   char *m;
   char *m;
@@ -197,7 +197,8 @@ void do_build(const char *const *argv) {
   strcpy(tfbuf,envbuf);
   strcpy(tfbuf,envbuf);
   strcat(tfbuf,"/dpkg.XXXXXX");
   strcat(tfbuf,"/dpkg.XXXXXX");
   subdir= 0;
   subdir= 0;
-  if ((debar= *argv++) !=0) {
+  debar = *argv++;
+  if (debar != NULL) {
     if (*argv) badusage(_("--build takes at most two arguments"));
     if (*argv) badusage(_("--build takes at most two arguments"));
     if (debar) {
     if (debar) {
       if (stat(debar,&debarstab)) {
       if (stat(debar,&debarstab)) {
@@ -340,7 +341,8 @@ void do_build(const char *const *argv) {
    * build something. Lets start by making the ar-wrapper.
    * build something. Lets start by making the ar-wrapper.
    */
    */
   if (!(ar=fopen(debar,"wb"))) ohshite(_("unable to create `%.255s'"),debar);
   if (!(ar=fopen(debar,"wb"))) ohshite(_("unable to create `%.255s'"),debar);
-  if (setvbuf(ar, 0, _IONBF, 0)) ohshite(_("unable to unbuffer `%.255s'"),debar);
+  if (setvbuf(ar, NULL, _IONBF, 0))
+    ohshite(_("unable to unbuffer `%.255s'"), debar);
   /* Fork a tar to package the control-section of the package */
   /* Fork a tar to package the control-section of the package */
   m_pipe(p1);
   m_pipe(p1);
   if (!(c1= m_fork())) {
   if (!(c1= m_fork())) {
@@ -379,7 +381,7 @@ void do_build(const char *const *argv) {
     if (fprintf(ar, "%-8s\n%ld\n", OLDARCHIVEVERSION, (long)controlstab.st_size) == EOF)
     if (fprintf(ar, "%-8s\n%ld\n", OLDARCHIVEVERSION, (long)controlstab.st_size) == EOF)
       werr(debar);
       werr(debar);
   } else {
   } else {
-    thetime= time(0);
+    thetime = time(NULL);
     if (fprintf(ar,
     if (fprintf(ar,
                 "!<arch>\n"
                 "!<arch>\n"
                 "debian-binary   %-12lu0     0     100644  %-10ld`\n"
                 "debian-binary   %-12lu0     0     100644  %-10ld`\n"

+ 2 - 2
dpkg-deb/extract.c

@@ -93,7 +93,7 @@ void extracthalf(const char *debar, const char *directory,
   size_t ctrllennum, memberlen= 0;
   size_t ctrllennum, memberlen= 0;
   int dummy, l= 0;
   int dummy, l= 0;
   pid_t c1=0,c2,c3;
   pid_t c1=0,c2,c3;
-  unsigned char *ctrlarea= 0;
+  unsigned char *ctrlarea = NULL;
   int p1[2], p2[2];
   int p1[2], p2[2];
   FILE *ar, *pi;
   FILE *ar, *pi;
   struct stat stab;
   struct stat stab;
@@ -344,7 +344,7 @@ void do_fsystarfile(const char *const *argv) {
     badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
     badusage(_("--%s needs a .deb filename argument"),cipaction->olong);
   if (*argv)
   if (*argv)
     badusage(_("--%s takes only one argument (.deb filename)"),cipaction->olong);
     badusage(_("--%s takes only one argument (.deb filename)"),cipaction->olong);
-  extracthalf(debar,0,0,0);
+  extracthalf(debar, NULL, NULL, 0);
 }
 }
    
    
 void do_control(const char *const *argv) { controlextractvextract(1, "x", argv); }
 void do_control(const char *const *argv) { controlextractvextract(1, "x", argv); }

+ 5 - 5
dpkg-deb/info.c

@@ -76,7 +76,7 @@ static void info_prepare(const char *const **argvp,
     ohshite(_("failed to exec rm -rf"));
     ohshite(_("failed to exec rm -rf"));
   }
   }
   waitsubproc(c1,"rm -rf",0);
   waitsubproc(c1,"rm -rf",0);
-  push_cleanup(cu_info_prepare,-1, 0,0, 1, (void*)dbuf);
+  push_cleanup(cu_info_prepare, -1, NULL, 0, 1, (void *)dbuf);
   extracthalf(*debarp, dbuf, "mx", admininfo);
   extracthalf(*debarp, dbuf, "mx", admininfo);
 }
 }
 
 
@@ -92,7 +92,7 @@ static void info_spew(const char *debar, const char *directory,
   FILE *co;
   FILE *co;
   int re= 0;
   int re= 0;
 
 
-  while ((component= *argv++) != 0) {
+  while ((component = *argv++) != NULL) {
     pathlen = strlen(directory) + strlen(component) + 2;
     pathlen = strlen(directory) + strlen(component) + 2;
     controlfile = (void *) realloc((void *) controlfile, pathlen);
     controlfile = (void *) realloc((void *) controlfile, pathlen);
     if (!controlfile)
     if (!controlfile)
@@ -256,9 +256,9 @@ void do_field(const char *const *argv) {
 
 
   info_prepare(&argv,&debar,&directory,1);
   info_prepare(&argv,&debar,&directory,1);
   if (*argv) {
   if (*argv) {
-    info_field(debar, directory, argv, argv[1]!=0);
+    info_field(debar, directory, argv, argv[1] != NULL);
   } else {
   } else {
-    static const char *const controlonly[]= { "control", 0 };
+    static const char *const controlonly[] = { "control", NULL };
     info_spew(debar,directory, controlonly);
     info_spew(debar,directory, controlonly);
   }
   }
 }
 }
@@ -267,7 +267,7 @@ void do_contents(const char *const *argv) {
   const char *debar;
   const char *debar;
   
   
   if (!(debar= *argv++) || *argv) badusage(_("--contents takes exactly one argument"));
   if (!(debar= *argv++) || *argv) badusage(_("--contents takes exactly one argument"));
-  extracthalf(debar, 0, "tv", 0);
+  extracthalf(debar, NULL, "tv", 0);
 }
 }
 /* vi: sw=2
 /* vi: sw=2
  */
  */

+ 27 - 25
dpkg-deb/main.c

@@ -118,8 +118,8 @@ const char printforhelp[]=
 int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
 int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
 const char* compression=NULL;
 const char* compression=NULL;
 enum compress_type compress_type = compress_type_gzip;
 enum compress_type compress_type = compress_type_gzip;
-const struct cmdinfo *cipaction=0;
-dofunction *action=0;
+const struct cmdinfo *cipaction = NULL;
+dofunction *action = NULL;
 
 
 static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
 static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
 static void helponly(const struct cmdinfo *cip, const char *value) {
 static void helponly(const struct cmdinfo *cip, const char *value) {
@@ -149,27 +149,29 @@ static dofunction *const dofunctions[]= {
  * same order as dofunctions:
  * same order as dofunctions:
  */
  */
 static const struct cmdinfo cmdinfos[]= {
 static const struct cmdinfo cmdinfos[]= {
-  { "build",        'b',  0,  0, 0,               setaction        },
-  { "contents",     'c',  0,  0, 0,               setaction        },
-  { "control",      'e',  0,  0, 0,               setaction        },
-  { "info",         'I',  0,  0, 0,               setaction        },
-  { "field",        'f',  0,  0, 0,               setaction        },
-  { "extract",      'x',  0,  0, 0,               setaction        },
-  { "vextract",     'X',  0,  0, 0,               setaction        },
-  { "fsys-tarfile",  0,   0,  0, 0,               setaction        },
-  { "show",         'W',  0,  0, 0,               setaction        },
-  { "new",           0,   0,  &oldformatflag, 0,  0,            0  },
-  { "old",           0,   0,  &oldformatflag, 0,  0,            1  },
-  { "debug",        'D',  0,  &debugflag,     0,  0,            1  },
-  { "nocheck",       0,   0,  &nocheckflag,   0,  0,            1  },
-  { "compression",  'z',  1,  0,   &compression,  0,            1  },
-  { "compress_type",'Z',  1,  0, 0,               setcompresstype  },
-  { "showformat",    0,   1,  0, &showformat,     0                },
-  { "help",         'h',  0,  0, 0,               helponly         },
-  { "version",       0,   0,  0, 0,               versiononly      },
-  { "licence",       0,   0,  0, 0,               showcopyright    }, /* UK spelling */
-  { "license",       0,   0,  0, 0,               showcopyright    }, /* US spelling */
-  {  0,              0                                             }
+  { "build",         'b', 0, NULL,           NULL,         setaction        },
+  { "contents",      'c', 0, NULL,           NULL,         setaction        },
+  { "control",       'e', 0, NULL,           NULL,         setaction        },
+  { "info",          'I', 0, NULL,           NULL,         setaction        },
+  { "field",         'f', 0, NULL,           NULL,         setaction        },
+  { "extract",       'x', 0, NULL,           NULL,         setaction        },
+  { "vextract",      'X', 0, NULL,           NULL,         setaction        },
+  { "fsys-tarfile",  0,   0, NULL,           NULL,         setaction        },
+  { "show",          'W', 0, NULL,           NULL,         setaction        },
+  { "new",           0,   0, &oldformatflag, NULL,         NULL,          0 },
+  { "old",           0,   0, &oldformatflag, NULL,         NULL,          1 },
+  { "debug",         'D', 0, &debugflag,     NULL,         NULL,          1 },
+  { "nocheck",       0,   0, &nocheckflag,   NULL,         NULL,          1 },
+  { "compression",   'z', 1, NULL,           &compression, NULL,          1 },
+  { "compress_type", 'Z', 1, NULL,           NULL,         setcompresstype  },
+  { "showformat",    0,   1, NULL,           &showformat,  NULL             },
+  { "help",          'h', 0, NULL,           NULL,         helponly         },
+  { "version",       0,   0, NULL,           NULL,         versiononly      },
+  /* UK spelling. */
+  { "licence",       0,   0, NULL,           NULL,         showcopyright    },
+  /* US spelling. */
+  { "license",       0,   0, NULL,           NULL,         showcopyright    },
+  {  NULL,           0,   0, NULL,           NULL,         NULL             }
 };
 };
 
 
 static void setaction(const struct cmdinfo *cip, const char *value) {
 static void setaction(const struct cmdinfo *cip, const char *value) {
@@ -198,12 +200,12 @@ int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
   jmp_buf ejbuf;
 
 
   setlocale(LC_NUMERIC, "POSIX");
   setlocale(LC_NUMERIC, "POSIX");
-  standard_startup(&ejbuf, argc, &argv, NULL, 0, cmdinfos);
+  standard_startup(&ejbuf, argc, &argv, NULL, NULL, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
   if (!cipaction) badusage(_("need an action option"));
 
 
   unsetenv("GZIP");
   unsetenv("GZIP");
   action(argv);
   action(argv);
-  standard_shutdown(0);
+  standard_shutdown(NULL);
   exit(0);
   exit(0);
 }
 }
 
 

+ 2 - 1
dpkg-split/join.c

@@ -114,7 +114,8 @@ void do_join(const char *const *argv) {
     if (!refi || pq->info.thispartn < refi->thispartn) refi= &pq->info;
     if (!refi || pq->info.thispartn < refi->thispartn) refi= &pq->info;
   assert(refi);
   assert(refi);
   partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn);
   partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn);
-  for (i=0; i<refi->maxpartn; i++) partlist[i]= 0;
+  for (i = 0; i < refi->maxpartn; i++)
+    partlist[i] = NULL;
   for (pq= queue; pq; pq= pq->nextinqueue) {
   for (pq= queue; pq; pq= pq->nextinqueue) {
     pi= &pq->info;
     pi= &pq->info;
     addtopartlist(partlist,pi,refi);
     addtopartlist(partlist,pi,refi);

+ 2 - 1
dpkg-split/queue.c

@@ -120,7 +120,8 @@ void do_auto(const char *const *argv) {
   fclose(part);
   fclose(part);
   scandepot();
   scandepot();
   partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn);
   partlist= nfmalloc(sizeof(struct partinfo*)*refi->maxpartn);
-  for (i=0; i<refi->maxpartn; i++) partlist[i]= 0;
+  for (i = 0; i < refi->maxpartn; i++)
+    partlist[i] = NULL;
   for (pq= queue; pq; pq= pq->nextinqueue) {
   for (pq= queue; pq; pq= pq->nextinqueue) {
     pi= &pq->info;
     pi= &pq->info;
     if (!partmatches(pi,refi)) continue;
     if (!partmatches(pi,refi)) continue;

+ 6 - 6
lib/dpkg.h

@@ -175,7 +175,7 @@ extern const char printforhelp[];
   if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
   if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
     error_unwind(ehflag_bombout); exit(2);\
     error_unwind(ehflag_bombout); exit(2);\
   }\
   }\
-  push_error_handler(ejbuf,print_error_fatal,0);\
+  push_error_handler(ejbuf, print_error_fatal, NULL); \
   umask(022); /* Make sure all our status databases are readable. */\
   umask(022); /* Make sure all our status databases are readable. */\
   if (loadcfg)\
   if (loadcfg)\
     loadcfgfile(prog, cmdinfos);\
     loadcfgfile(prog, cmdinfos);\
@@ -183,7 +183,7 @@ extern const char printforhelp[];
 } while (0)
 } while (0)
 
 
 #define standard_shutdown(freemem) do {\
 #define standard_shutdown(freemem) do {\
-  set_error_display(0,0);\
+  set_error_display(NULL, NULL); \
   error_unwind(ehflag_normaltidy);\
   error_unwind(ehflag_normaltidy);\
   if (freemem)\
   if (freemem)\
     nffreeall();\
     nffreeall();\
@@ -284,14 +284,14 @@ struct buffer_data {
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 	    if(errno != ESPIPE) ohshite(__VA_ARGS__); \
 	    if(errno != ESPIPE) ohshite(__VA_ARGS__); \
 	    buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
 	    buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-				     0, BUFFER_WRITE_NULL, NULL, \
+	                             NULL, BUFFER_WRITE_NULL, NULL, \
 				     limit, __VA_ARGS__);\
 				     limit, __VA_ARGS__);\
 	}
 	}
 # define stream_null_copy(file, limit, ...) \
 # define stream_null_copy(file, limit, ...) \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 	    if(errno != EBADF) ohshite(__VA_ARGS__); \
 	    if(errno != EBADF) ohshite(__VA_ARGS__); \
 	    buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
 	    buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-				     0, BUFFER_WRITE_NULL, NULL, \
+	                             NULL, BUFFER_WRITE_NULL, NULL, \
 				     limit, __VA_ARGS__);\
 				     limit, __VA_ARGS__);\
 	}
 	}
 # define stream_fd_copy(file, fd, limit, ...)\
 # define stream_fd_copy(file, fd, limit, ...)\
@@ -323,14 +323,14 @@ struct buffer_data {
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 	    if(errno != ESPIPE) ohshite(desc); \
 	    if(errno != ESPIPE) ohshite(desc); \
 	    buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
 	    buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-				     0, BUFFER_WRITE_NULL, NULL, \
+	                             NULL, BUFFER_WRITE_NULL, NULL, \
 				     limit, desc);\
 				     limit, desc);\
 	}
 	}
 # define stream_null_copy(file, limit, desc...) \
 # define stream_null_copy(file, limit, desc...) \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 	    if(errno != EBADF) ohshite(desc); \
 	    if(errno != EBADF) ohshite(desc); \
 	    buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
 	    buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-				     0, BUFFER_WRITE_NULL, NULL, \
+	                             NULL, BUFFER_WRITE_NULL, NULL, \
 				     limit, desc);\
 				     limit, desc);\
 	}
 	}
 # define stream_fd_copy(file, fd, limit, desc...)\
 # define stream_fd_copy(file, fd, limit, desc...)\

+ 22 - 18
src/archives.c

@@ -149,7 +149,7 @@ static void ensureobstackinit(void) {
 /* destroy the obstack */
 /* destroy the obstack */
 static void destroyobstack(void) {
 static void destroyobstack(void) {
   if (tarobs_init) {
   if (tarobs_init) {
-    obstack_free(&tar_obs, 0);
+    obstack_free(&tar_obs, NULL);
     tarobs_init= 0;
     tarobs_init= 0;
   }
   }
 }
 }
@@ -234,7 +234,7 @@ int fnameidlu;
 struct varbuf fnamevb;
 struct varbuf fnamevb;
 struct varbuf fnametmpvb;
 struct varbuf fnametmpvb;
 struct varbuf fnamenewvb;
 struct varbuf fnamenewvb;
-struct packageinlist *deconfigure= 0;
+struct packageinlist *deconfigure = NULL;
 
 
 static time_t currenttime;
 static time_t currenttime;
 
 
@@ -322,7 +322,9 @@ struct fileinlist *addfiletolist(struct tarcontext *tc,
   
   
   nifd= obstack_alloc(&tar_obs, sizeof(struct fileinlist));
   nifd= obstack_alloc(&tar_obs, sizeof(struct fileinlist));
   nifd->namenode= namenode;
   nifd->namenode= namenode;
-  nifd->next= 0; *tc->newfilesp= nifd; tc->newfilesp= &nifd->next;
+  nifd->next = NULL;
+  *tc->newfilesp = nifd;
+  tc->newfilesp = &nifd->next;
   return nifd;
   return nifd;
 }
 }
 
 
@@ -583,7 +585,7 @@ int tarobject(struct TarInfo *ti) {
   if (keepexisting) {
   if (keepexisting) {
     obstack_free(&tar_obs, nifd);
     obstack_free(&tar_obs, nifd);
     tc->newfilesp= oldnifd;
     tc->newfilesp= oldnifd;
-    *oldnifd = 0;
+    *oldnifd = NULL;
 
 
     /* We need to advance the tar file to the next object, so read the
     /* We need to advance the tar file to the next object, so read the
      * file data and set it to oblivion.
      * file data and set it to oblivion.
@@ -602,7 +604,7 @@ int tarobject(struct TarInfo *ti) {
    * if something goes wrong.  Watch out for the CLEANUP comments to
    * if something goes wrong.  Watch out for the CLEANUP comments to
    * keep an eye on what's installed on the disk at each point.
    * keep an eye on what's installed on the disk at each point.
    */
    */
-  push_cleanup(cu_installnew,~ehflag_normaltidy, 0,0, 1,(void*)nifd);
+  push_cleanup(cu_installnew, ~ehflag_normaltidy, NULL, 0, 1, (void *)nifd);
 
 
   /* CLEANUP: Now we either have the old file on the disk, or not, in
   /* CLEANUP: Now we either have the old file on the disk, or not, in
    * its original filename.
    * its original filename.
@@ -648,7 +650,7 @@ int tarobject(struct TarInfo *ti) {
      */
      */
     fd= open(fnamenewvb.buf, (O_CREAT|O_EXCL|O_WRONLY), 0);
     fd= open(fnamenewvb.buf, (O_CREAT|O_EXCL|O_WRONLY), 0);
     if (fd < 0) ohshite(_("unable to create `%.255s'"),ti->Name);
     if (fd < 0) ohshite(_("unable to create `%.255s'"),ti->Name);
-    push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,&fd);
+    push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
     debug(dbg_eachfiledetail,"tarobject NormalFile[01] open size=%lu",
     debug(dbg_eachfiledetail,"tarobject NormalFile[01] open size=%lu",
           (unsigned long)ti->Size);
           (unsigned long)ti->Size);
     { char fnamebuf[256];
     { char fnamebuf[256];
@@ -898,7 +900,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
 
 
   varbufinit(&why);
   varbufinit(&why);
 
 
-  fixbydeconf= 0;
+  fixbydeconf = NULL;
   if (depisok(dep, &why, &fixbydeconf, 0)) {
   if (depisok(dep, &why, &fixbydeconf, 0)) {
     varbuffree(&why);
     varbuffree(&why);
     return;
     return;
@@ -918,7 +920,7 @@ void check_breaks(struct dependency *dep, struct pkginfo *pkg,
             fixbydeconf->name, action);
             fixbydeconf->name, action);
 
 
     ok= try_deconfigure_can(force_breaks, fixbydeconf, dep->list,
     ok= try_deconfigure_can(force_breaks, fixbydeconf, dep->list,
-                            action, 0, why.buf);
+                            action, NULL, why.buf);
     if (ok == 1) {
     if (ok == 1) {
       fprintf(stderr, _("dpkg: yes, will deconfigure %s (broken by %s).\n"),
       fprintf(stderr, _("dpkg: yes, will deconfigure %s (broken by %s).\n"),
               fixbydeconf->name, pkg->name);
               fixbydeconf->name, pkg->name);
@@ -957,7 +959,7 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
   varbufinit(&conflictwhy);
   varbufinit(&conflictwhy);
   varbufinit(&removalwhy);
   varbufinit(&removalwhy);
 
 
-  fixbyrm= 0;
+  fixbyrm = NULL;
   if (depisok(dep, &conflictwhy, &fixbyrm, 0)) {
   if (depisok(dep, &conflictwhy, &fixbyrm, 0)) {
     varbuffree(&conflictwhy);
     varbuffree(&conflictwhy);
     varbuffree(&removalwhy);
     varbuffree(&removalwhy);
@@ -981,14 +983,15 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
         fprintf(stderr,
         fprintf(stderr,
                 _("%s is not properly installed - ignoring any dependencies on it.\n"),
                 _("%s is not properly installed - ignoring any dependencies on it.\n"),
                 fixbyrm->name);
                 fixbyrm->name);
-        pdep= 0;
+        pdep = NULL;
       } else {
       } else {
         for (pdep= fixbyrm->installed.depended;
         for (pdep= fixbyrm->installed.depended;
              pdep;
              pdep;
              pdep= pdep->nextrev) {
              pdep= pdep->nextrev) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
             continue;
             continue;
-          if (depisok(pdep->up, &removalwhy, 0,0)) continue;
+          if (depisok(pdep->up, &removalwhy, NULL, 0))
+            continue;
           varbufaddc(&removalwhy,0);
           varbufaddc(&removalwhy,0);
           if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
           if (!try_remove_can(pdep,fixbyrm,removalwhy.buf))
             break;
             break;
@@ -1004,7 +1007,8 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
                  pdep= pdep->nextrev) {
                  pdep= pdep->nextrev) {
               if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
               if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends)
                 continue;
                 continue;
-              if (depisok(pdep->up, &removalwhy, 0,0)) continue;
+              if (depisok(pdep->up, &removalwhy, NULL, 0))
+                continue;
               varbufaddc(&removalwhy,0);
               varbufaddc(&removalwhy,0);
               fprintf(stderr, _("dpkg"
               fprintf(stderr, _("dpkg"
                       ": may have trouble removing %s, as it provides %s ...\n"),
                       ": may have trouble removing %s, as it provides %s ...\n"),
@@ -1117,7 +1121,7 @@ void archivefiles(const char *const *argv) {
       arglist[i++] = "-type";
       arglist[i++] = "-type";
       arglist[i++] = "f";
       arglist[i++] = "f";
       arglist[i++] = "-print0";
       arglist[i++] = "-print0";
-      arglist[i++] = 0;
+      arglist[i++] = NULL;
       execvp(FIND, (char *const *)arglist);
       execvp(FIND, (char *const *)arglist);
       ohshite(_("failed to exec find for --recursive"));
       ohshite(_("failed to exec find for --recursive"));
     }
     }
@@ -1148,7 +1152,7 @@ void archivefiles(const char *const *argv) {
       arglist[i++]= p;
       arglist[i++]= p;
       while ((c= *p++) != 0);
       while ((c= *p++) != 0);
     }
     }
-    arglist[i]= 0;
+    arglist[i] = NULL;
     argp= arglist;
     argp= arglist;
 
 
   } else {
   } else {
@@ -1159,7 +1163,7 @@ void archivefiles(const char *const *argv) {
     
     
   }
   }
 
 
-  currenttime= time(0);
+  currenttime = time(NULL);
 
 
   varbufinit(&fnamevb);
   varbufinit(&fnamevb);
   varbufinit(&fnametmpvb);
   varbufinit(&fnametmpvb);
@@ -1173,7 +1177,7 @@ void archivefiles(const char *const *argv) {
   ensure_diversions();
   ensure_diversions();
   ensure_statoverrides();
   ensure_statoverrides();
   
   
-  while ((thisarg= *argp++) != 0) {
+  while ((thisarg = *argp++) != NULL) {
     if (setjmp(ejbuf)) {
     if (setjmp(ejbuf)) {
       error_unwind(ehflag_bombout);
       error_unwind(ehflag_bombout);
       if (onerr_abort > 0) break;
       if (onerr_abort > 0) break;
@@ -1185,7 +1189,7 @@ void archivefiles(const char *const *argv) {
     if (ferror(stdout)) werr("stdout");
     if (ferror(stdout)) werr("stdout");
     if (ferror(stderr)) werr("stderr");
     if (ferror(stderr)) werr("stderr");
     onerr_abort--;
     onerr_abort--;
-    set_error_display(0,0);
+    set_error_display(NULL, NULL);
     error_unwind(ehflag_normaltidy);
     error_unwind(ehflag_normaltidy);
   }
   }
 
 
@@ -1271,7 +1275,7 @@ struct fileinlist *newconff_append(struct fileinlist ***newconffileslastp_io,
   struct fileinlist *newconff;
   struct fileinlist *newconff;
 
 
   newconff= m_malloc(sizeof(struct fileinlist));
   newconff= m_malloc(sizeof(struct fileinlist));
-  newconff->next= 0;
+  newconff->next = NULL;
   newconff->namenode= namenode;
   newconff->namenode= namenode;
   **newconffileslastp_io= newconff;
   **newconffileslastp_io= newconff;
   *newconffileslastp_io= &newconff->next;
   *newconffileslastp_io= &newconff->next;

+ 4 - 4
src/configure.c

@@ -81,7 +81,7 @@ void deferred_configure(struct pkginfo *pkg) {
 	char *cdr2rest;
 	char *cdr2rest;
 	int ok, r, useredited, distedited;
 	int ok, r, useredited, distedited;
 	struct conffile *conff;
 	struct conffile *conff;
-	char *currenthash= 0, *newdisthash= 0;
+	char *currenthash = NULL, *newdisthash = NULL;
 	struct stat stab;
 	struct stat stab;
 	enum conffopt what;
 	enum conffopt what;
 	static const char *EMPTY_HASH = "-";
 	static const char *EMPTY_HASH = "-";
@@ -100,7 +100,7 @@ void deferred_configure(struct pkginfo *pkg) {
 			sincenothing= 0; 
 			sincenothing= 0; 
 
 
 	varbufinit(&aemsgs);
 	varbufinit(&aemsgs);
-	ok= dependencies_ok(pkg,0,&aemsgs);
+	ok = dependencies_ok(pkg, NULL, &aemsgs);
 	if (ok == 1) {
 	if (ok == 1) {
 		varbuffree(&aemsgs);
 		varbuffree(&aemsgs);
 		pkg->clientdata->istobe= itb_installnew;
 		pkg->clientdata->istobe= itb_installnew;
@@ -313,7 +313,7 @@ void deferred_configure(struct pkginfo *pkg) {
  * Returns 0 if everything went ok, -1 otherwise.
  * Returns 0 if everything went ok, -1 otherwise.
  */
  */
 int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) {
 int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) {
-	static char*	linkreadbuf	= 0;
+	static char *linkreadbuf = NULL;
 	static int	linkreadbufsize	= 0;
 	static int	linkreadbufsize	= 0;
 	struct stat	stab;
 	struct stat	stab;
 	int		r, need;
 	int		r, need;
@@ -405,7 +405,7 @@ static void md5hash(struct pkginfo *pkg, char **hashbuf, const char *fn) {
 	fd=open(fn,O_RDONLY);
 	fd=open(fn,O_RDONLY);
 
 
 	if (fd>=0) {
 	if (fd>=0) {
-		push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,&fd);
+		push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
 		fd_md5(fd, hashbuf, -1, _("md5hash"));
 		fd_md5(fd, hashbuf, -1, _("md5hash"));
 		pop_cleanup(ehflag_normaltidy); /* fd= open(cdr.buf) */
 		pop_cleanup(ehflag_normaltidy); /* fd= open(cdr.buf) */
 		close(fd);
 		close(fd);

+ 8 - 5
src/depcon.c

@@ -108,7 +108,7 @@ static int findbreakcyclerecursive(struct pkginfo *pkg, struct cyclesofarlink *s
   }
   }
   thislink.pkg= pkg;
   thislink.pkg= pkg;
   thislink.back= sofar;
   thislink.back= sofar;
-  thislink.possi= 0;
+  thislink.possi = NULL;
   for (dep= pkg->installed.depends; dep; dep= dep->next) {
   for (dep= pkg->installed.depends; dep; dep= dep->next) {
     if (dep->type != dep_depends && dep->type != dep_predepends) continue;
     if (dep->type != dep_depends && dep->type != dep_predepends) continue;
     for (possi= dep->list; possi; possi= possi->next) {
     for (possi= dep->list; possi; possi= possi->next) {
@@ -144,7 +144,7 @@ int findbreakcycle(struct pkginfo *pkg) {
     tpkg->color = white;
     tpkg->color = white;
   }
   }
 
 
-  return findbreakcyclerecursive(pkg, 0);
+  return findbreakcyclerecursive(pkg, NULL);
 }
 }
 
 
 void describedepcon(struct varbuf *addto, struct dependency *dep) {
 void describedepcon(struct varbuf *addto, struct dependency *dep) {
@@ -217,7 +217,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
 	 dep->type == dep_recommends || dep->type == dep_suggests ||
 	 dep->type == dep_recommends || dep->type == dep_suggests ||
 	 dep->type == dep_enhances);
 	 dep->type == dep_enhances);
   
   
-  if (canfixbyremove) *canfixbyremove= 0;
+  if (canfixbyremove)
+    *canfixbyremove = NULL;
 
 
   /* The dependency is always OK if we're trying to remove the depend*ing*
   /* The dependency is always OK if we're trying to remove the depend*ing*
    * package.
    * package.
@@ -450,7 +451,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
                 provider->up->up->name, possi->ed->name);
                 provider->up->up->name, possi->ed->name);
         varbufaddstr(whynot, linebuf);
         varbufaddstr(whynot, linebuf);
         /* We can't remove the one we're about to install: */
         /* We can't remove the one we're about to install: */
-        if (canfixbyremove) *canfixbyremove= 0;
+        if (canfixbyremove)
+          *canfixbyremove = NULL;
         return 0;
         return 0;
       }
       }
 
 
@@ -499,7 +501,8 @@ int depisok(struct dependency *dep, struct varbuf *whynot,
     }
     }
 
 
     if (!nconflicts) return 1;
     if (!nconflicts) return 1;
-    if (nconflicts>1) *canfixbyremove= 0;
+    if (nconflicts > 1)
+      *canfixbyremove = NULL;
     return 0;
     return 0;
 
 
   } /* if (dependency) {...} else {...} */
   } /* if (dependency) {...} else {...} */

+ 18 - 15
src/enquiry.c

@@ -52,7 +52,7 @@ static void limiteddescription(struct pkginfo *pkg, int maxl,
   const char *pdesc, *p;
   const char *pdesc, *p;
   int l;
   int l;
   
   
-  pdesc= pkg->installed.valid ? pkg->installed.description : 0;
+  pdesc = pkg->installed.valid ? pkg->installed.description : NULL;
   if (!pdesc) pdesc= _("(no description available)");
   if (!pdesc) pdesc= _("(no description available)");
   p= strchr(pdesc,'\n');
   p= strchr(pdesc,'\n');
   if (!p) p= pdesc+strlen(pdesc);
   if (!p) p= pdesc+strlen(pdesc);
@@ -97,7 +97,7 @@ static const struct badstatinfo badstatinfos[]= {
     "installation.  The installation can probably be completed by retrying it;\n"
     "installation.  The installation can probably be completed by retrying it;\n"
     "the packages can be removed using dselect or dpkg --remove:\n")
     "the packages can be removed using dselect or dpkg --remove:\n")
   }, {
   }, {
-    0
+    NULL
   }
   }
 };
 };
 
 
@@ -175,7 +175,7 @@ void unpackchk(const char *const *argv) {
   modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
   modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
 
 
   totalcount= 0;
   totalcount= 0;
-  sectionentries= 0;
+  sectionentries = NULL;
   sects= 0;
   sects= 0;
   it= iterpkgstart(); 
   it= iterpkgstart(); 
   while ((pkg= iterpkgnext(it))) {
   while ((pkg= iterpkgnext(it))) {
@@ -201,7 +201,8 @@ void unpackchk(const char *const *argv) {
   if (totalcount <= 12) {
   if (totalcount <= 12) {
     it= iterpkgstart(); 
     it= iterpkgstart(); 
     while ((pkg= iterpkgnext(it))) {
     while ((pkg= iterpkgnext(it))) {
-      if (!yettobeunpacked(pkg,0)) continue;
+      if (!yettobeunpacked(pkg, NULL))
+        continue;
       describebriefly(pkg);
       describebriefly(pkg);
     }
     }
     iterpkgend(it);
     iterpkgend(it);
@@ -248,7 +249,7 @@ static void assertversion(const char *const *argv,
   if (verrev_buf->epoch == ~0UL) {
   if (verrev_buf->epoch == ~0UL) {
     verrev_buf->epoch= 0;
     verrev_buf->epoch= 0;
     verrev_buf->version= nfstrsave(reqversion);
     verrev_buf->version= nfstrsave(reqversion);
-    verrev_buf->revision= 0;
+    verrev_buf->revision = NULL;
   }
   }
   pkg= findpackage("dpkg");
   pkg= findpackage("dpkg");
   switch (pkg->status) {
   switch (pkg->status) {
@@ -267,22 +268,22 @@ static void assertversion(const char *const *argv,
 }
 }
 
 
 void assertpredep(const char *const *argv) {
 void assertpredep(const char *const *argv) {
-  static struct versionrevision predepversion = {~0UL,0,0};
+  static struct versionrevision predepversion = { ~0UL, NULL, NULL };
   assertversion(argv,&predepversion,"1.1.0");
   assertversion(argv,&predepversion,"1.1.0");
 }
 }
 
 
 void assertepoch(const char *const *argv) {
 void assertepoch(const char *const *argv) {
-  static struct versionrevision epochversion = {~0UL,0,0};
+  static struct versionrevision epochversion = { ~0UL, NULL, NULL };
   assertversion(argv,&epochversion,"1.4.0.7");
   assertversion(argv,&epochversion,"1.4.0.7");
 }
 }
 
 
 void assertlongfilenames(const char *const *argv) {
 void assertlongfilenames(const char *const *argv) {
-  static struct versionrevision epochversion = {~0UL,0,0};
+  static struct versionrevision epochversion = { ~0UL, NULL, NULL };
   assertversion(argv,&epochversion,"1.4.1.17");
   assertversion(argv,&epochversion,"1.4.1.17");
 }
 }
 
 
 void assertmulticonrep(const char *const *argv) {
 void assertmulticonrep(const char *const *argv) {
-  static struct versionrevision epochversion = {~0UL,0,0};
+  static struct versionrevision epochversion = { ~0UL, NULL, NULL };
   assertversion(argv,&epochversion,"1.4.1.19");
   assertversion(argv,&epochversion,"1.4.1.19");
 }
 }
 
 
@@ -300,7 +301,7 @@ void predeppackage(const char *const *argv) {
   static struct varbuf vb;
   static struct varbuf vb;
   
   
   struct pkgiterator *it;
   struct pkgiterator *it;
-  struct pkginfo *pkg= 0, *startpkg, *trypkg;
+  struct pkginfo *pkg = NULL, *startpkg, *trypkg;
   struct dependency *dep;
   struct dependency *dep;
   struct deppossi *possi, *provider;
   struct deppossi *possi, *provider;
 
 
@@ -309,7 +310,7 @@ void predeppackage(const char *const *argv) {
   modstatdb_init(admindir,msdbrw_readonly);
   modstatdb_init(admindir,msdbrw_readonly);
   clear_istobes(); /* We use clientdata->istobe to detect loops */
   clear_istobes(); /* We use clientdata->istobe to detect loops */
 
 
-  for (it=iterpkgstart(), dep=0;
+  for (it = iterpkgstart(), dep = NULL;
        !dep && (pkg=iterpkgnext(it));
        !dep && (pkg=iterpkgnext(it));
        ) {
        ) {
     if (pkg->want != want_install) continue; /* Ignore packages user doesn't want */
     if (pkg->want != want_install) continue; /* Ignore packages user doesn't want */
@@ -317,7 +318,8 @@ void predeppackage(const char *const *argv) {
     pkg->clientdata->istobe= itb_preinstall;
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep,&vb,0,1)) continue;
+      if (depisok(dep, &vb, NULL, 1))
+        continue;
       break; /* This will leave dep non-NULL, and so exit the loop. */
       break; /* This will leave dep non-NULL, and so exit the loop. */
     }
     }
     pkg->clientdata->istobe= itb_normal;
     pkg->clientdata->istobe= itb_normal;
@@ -334,7 +336,7 @@ void predeppackage(const char *const *argv) {
    */
    */
   do {
   do {
     /* We search for a package which would satisfy dep, and put it in pkg */
     /* We search for a package which would satisfy dep, and put it in pkg */
-    for (possi=dep->list, pkg=0;
+    for (possi = dep->list, pkg = NULL;
          !pkg && possi;
          !pkg && possi;
          possi=possi->next) {
          possi=possi->next) {
       trypkg= possi->ed;
       trypkg= possi->ed;
@@ -363,7 +365,8 @@ void predeppackage(const char *const *argv) {
     pkg->clientdata->istobe= itb_preinstall;
     pkg->clientdata->istobe= itb_preinstall;
     for (dep= pkg->available.depends; dep; dep= dep->next) {
     for (dep= pkg->available.depends; dep; dep= dep->next) {
       if (dep->type != dep_predepends) continue;
       if (dep->type != dep_predepends) continue;
-      if (depisok(dep,&vb,0,1)) continue;
+      if (depisok(dep, &vb, NULL, 1))
+        continue;
       break; /* This will leave dep non-NULL, and so exit the loop. */
       break; /* This will leave dep non-NULL, and so exit the loop. */
     }
     }
   } while (dep);
   } while (dep);
@@ -407,7 +410,7 @@ void cmpversions(const char *const *argv) {
     { ">",         1,0,0, 1,0,0  }, /*                  */
     { ">",         1,0,0, 1,0,0  }, /*                  */
     { ">=",        1,0,0, 1,0,0  },
     { ">=",        1,0,0, 1,0,0  },
     { ">>",        1,1,0, 1,1,0  },
     { ">>",        1,1,0, 1,1,0  },
-    {  0                         }
+    { NULL                       }
   };
   };
 
 
   const struct relationinfo *rip;
   const struct relationinfo *rip;

+ 2 - 2
src/errors.c

@@ -46,7 +46,7 @@ struct error_report {
   const char *what;
   const char *what;
 };
 };
 
 
-static struct error_report *reports=0;
+static struct error_report *reports = NULL;
 static struct error_report **lastreport= &reports;
 static struct error_report **lastreport= &reports;
 static struct error_report emergency;
 static struct error_report emergency;
 
 
@@ -81,7 +81,7 @@ void print_error_perpackage(const char *emsg, const char *arg) {
     nr= &emergency;
     nr= &emergency;
   }
   }
   nr->what= arg;
   nr->what= arg;
-  nr->next= 0;
+  nr->next = NULL;
   *lastreport= nr;
   *lastreport= nr;
   lastreport= &nr->next;
   lastreport= &nr->next;
     
     

+ 34 - 29
src/filesdb.c

@@ -42,9 +42,9 @@
 
 
 static int allpackagesdone= 0;
 static int allpackagesdone= 0;
 static int nfiles= 0;
 static int nfiles= 0;
-static struct diversion *diversions= 0;
-static FILE *diversionsfile= 0;
-static FILE *statoverridefile= 0;
+static struct diversion *diversions = NULL;
+static FILE *diversionsfile = NULL;
+static FILE *statoverridefile = NULL;
 
 
 void note_must_reread_files_inpackage(struct pkginfo *pkg) {
 void note_must_reread_files_inpackage(struct pkginfo *pkg) {
   allpackagesdone= 0;
   allpackagesdone= 0;
@@ -95,7 +95,7 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
            * the list is null-pointer-terminated.
            * the list is null-pointer-terminated.
            */
            */
           packageslump->pkgs[search]= packageslump->pkgs[findlast];
           packageslump->pkgs[search]= packageslump->pkgs[findlast];
-          packageslump->pkgs[findlast]= 0;
+          packageslump->pkgs[findlast] = NULL;
           /* This may result in an empty link in the list.  This is OK. */
           /* This may result in an empty link in the list.  This is OK. */
           goto xit_search_to_delete_from_perfilenodelist;
           goto xit_search_to_delete_from_perfilenodelist;
         }
         }
@@ -105,7 +105,7 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
      * we shouldn't free them.
      * we shouldn't free them.
      */
      */
   }
   }
-  pkg->clientdata->files= 0;
+  pkg->clientdata->files = NULL;
 
 
   /* Packages which aren't installed don't have a files list. */
   /* Packages which aren't installed don't have a files list. */
   if (pkg->status == stat_notinstalled) {
   if (pkg->status == stat_notinstalled) {
@@ -128,12 +128,12 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
               _("dpkg: serious warning: files list file for package `%.250s' missing,"
               _("dpkg: serious warning: files list file for package `%.250s' missing,"
               " assuming package has no files currently installed.\n"), pkg->name);
               " assuming package has no files currently installed.\n"), pkg->name);
     }
     }
-    pkg->clientdata->files= 0;
+    pkg->clientdata->files = NULL;
     pkg->clientdata->fileslistvalid= 1;
     pkg->clientdata->fileslistvalid= 1;
     return;
     return;
   }
   }
 
 
-  push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,&fd);
+  push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
   
   
    if(fstat(fd, &stat_buf))
    if(fstat(fd, &stat_buf))
      ohshite("unable to stat files list file for package `%.250s'",pkg->name);
      ohshite("unable to stat files list file for package `%.250s'",pkg->name);
@@ -159,7 +159,7 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
       *ptr = 0;
       *ptr = 0;
       newent= nfmalloc(sizeof(struct fileinlist));
       newent= nfmalloc(sizeof(struct fileinlist));
       newent->namenode= findnamenode(thisline, fnn_nocopy);
       newent->namenode= findnamenode(thisline, fnn_nocopy);
-      newent->next= 0;
+      newent->next = NULL;
       *lendp= newent;
       *lendp= newent;
       lendp= &newent->next;
       lendp= &newent->next;
       thisline = nextline;
       thisline = nextline;
@@ -177,7 +177,8 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
     if (packageslump) {
     if (packageslump) {
       for (; putat < PERFILEPACKAGESLUMP && packageslump->pkgs[putat];
       for (; putat < PERFILEPACKAGESLUMP && packageslump->pkgs[putat];
            putat++);
            putat++);
-      if (putat >= PERFILEPACKAGESLUMP) packageslump= 0;
+      if (putat >= PERFILEPACKAGESLUMP)
+        packageslump = NULL;
     }
     }
     if (!packageslump) {
     if (!packageslump) {
       packageslump= nfmalloc(sizeof(struct filepackages));
       packageslump= nfmalloc(sizeof(struct filepackages));
@@ -186,7 +187,8 @@ void ensure_packagefiles_available(struct pkginfo *pkg) {
       putat= 0;
       putat= 0;
     }
     }
     packageslump->pkgs[putat]= pkg;
     packageslump->pkgs[putat]= pkg;
-    if (++putat < PERFILEPACKAGESLUMP) packageslump->pkgs[putat]= 0;
+    if (++putat < PERFILEPACKAGESLUMP)
+      packageslump->pkgs[putat] = NULL;
   }      
   }      
   pkg->clientdata->fileslistvalid= 1;
   pkg->clientdata->fileslistvalid= 1;
 }
 }
@@ -201,7 +203,8 @@ void ensure_allinstfiles_available(void) {
     printf(_("(Reading database ... "));
     printf(_("(Reading database ... "));
   }
   }
   it= iterpkgstart();
   it= iterpkgstart();
-  while ((pkg= iterpkgnext(it)) != 0) ensure_packagefiles_available(pkg);
+  while ((pkg = iterpkgnext(it)) != NULL)
+    ensure_packagefiles_available(pkg);
   iterpkgend(it);
   iterpkgend(it);
   allpackagesdone= 1;
   allpackagesdone= 1;
 
 
@@ -238,7 +241,7 @@ void write_filelist_except(struct pkginfo *pkg, struct fileinlist *list, int lea
   file= fopen(newvb.buf,"w+");
   file= fopen(newvb.buf,"w+");
   if (!file)
   if (!file)
     ohshite(_("unable to create updated files list file for package %s"),pkg->name);
     ohshite(_("unable to create updated files list file for package %s"),pkg->name);
-  push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)file);
+  push_cleanup(cu_closefile, ehflag_bombout, NULL, 0, 1, (void *)file);
   while (list) {
   while (list) {
     if (!(leaveout && (list->namenode->flags & fnnf_elide_other_lists))) {
     if (!(leaveout && (list->namenode->flags & fnnf_elide_other_lists))) {
       fputs(list->namenode->name,file);
       fputs(list->namenode->name,file);
@@ -271,7 +274,7 @@ void reversefilelist_init(struct reversefilelistiter *iterptr,
    */
    */
   struct fileinlist *newent;
   struct fileinlist *newent;
   
   
-  iterptr->todo= 0;
+  iterptr->todo = NULL;
   while (files) {
   while (files) {
     newent= m_malloc(sizeof(struct fileinlist));
     newent= m_malloc(sizeof(struct fileinlist));
     newent->namenode= files->namenode;
     newent->namenode= files->namenode;
@@ -286,7 +289,8 @@ struct filenamenode *reversefilelist_next(struct reversefilelistiter *iterptr) {
   struct fileinlist *todo;
   struct fileinlist *todo;
 
 
   todo= iterptr->todo;
   todo= iterptr->todo;
-  if (!todo) return 0;
+  if (!todo)
+    return NULL;
   ret= todo->namenode;
   ret= todo->namenode;
   iterptr->todo= todo->next;
   iterptr->todo= todo->next;
   free(todo);
   free(todo);
@@ -460,10 +464,10 @@ void ensure_diversions(void) {
   setcloexec(fileno(diversionsfile), vb.buf);
   setcloexec(fileno(diversionsfile), vb.buf);
 
 
   for (ov= diversions; ov; ov= ov->next) {
   for (ov= diversions; ov; ov= ov->next) {
-    ov->useinstead->divert->camefrom->divert= 0;
-    ov->useinstead->divert= 0;
+    ov->useinstead->divert->camefrom->divert = NULL;
+    ov->useinstead->divert = NULL;
   }
   }
-  diversions= 0;
+  diversions = NULL;
   if (!file) { onerr_abort--; return; }
   if (!file) { onerr_abort--; return; }
 
 
   while (fgets(linebuf,sizeof(linebuf),file)) {
   while (fgets(linebuf,sizeof(linebuf),file)) {
@@ -475,7 +479,7 @@ void ensure_diversions(void) {
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [i]"));
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [i]"));
     linebuf[l]= 0;
     linebuf[l]= 0;
     oialtname->camefrom= findnamenode(linebuf, 0);
     oialtname->camefrom= findnamenode(linebuf, 0);
-    oialtname->useinstead= 0;    
+    oialtname->useinstead = NULL;
 
 
     if (!fgets(linebuf,sizeof(linebuf),file)) {
     if (!fgets(linebuf,sizeof(linebuf),file)) {
       if (ferror(file)) ohshite(_("read error in diversions [ii]"));
       if (ferror(file)) ohshite(_("read error in diversions [ii]"));
@@ -486,7 +490,7 @@ void ensure_diversions(void) {
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [ii]"));
     if (linebuf[--l] != '\n') ohshit(_("diversions file has too-long line or EOF [ii]"));
     linebuf[l]= 0;
     linebuf[l]= 0;
     oicontest->useinstead= findnamenode(linebuf, 0);
     oicontest->useinstead= findnamenode(linebuf, 0);
-    oicontest->camefrom= 0;
+    oicontest->camefrom = NULL;
     
     
     if (!fgets(linebuf,sizeof(linebuf),file)) {
     if (!fgets(linebuf,sizeof(linebuf),file)) {
       if (ferror(file)) ohshite(_("read error in diversions [iii]"));
       if (ferror(file)) ohshite(_("read error in diversions [iii]"));
@@ -498,7 +502,7 @@ void ensure_diversions(void) {
     linebuf[l]= 0;
     linebuf[l]= 0;
 
 
     oicontest->pkg= oialtname->pkg=
     oicontest->pkg= oialtname->pkg=
-      strcmp(linebuf,":") ? findpackage(linebuf) : 0;
+      strcmp(linebuf, ":") ? findpackage(linebuf) : NULL;
 
 
     if (oialtname->camefrom->divert || oicontest->useinstead->divert)
     if (oialtname->camefrom->divert || oicontest->useinstead->divert)
       ohshit(_("conflicting diversions involving `%.250s' or `%.250s'"),
       ohshit(_("conflicting diversions involving `%.250s' or `%.250s'"),
@@ -531,7 +535,7 @@ static struct filenamenode *bins[BINS];
 struct fileiterator *iterfilestart(void) {
 struct fileiterator *iterfilestart(void) {
   struct fileiterator *i;
   struct fileiterator *i;
   i= m_malloc(sizeof(struct fileiterator));
   i= m_malloc(sizeof(struct fileiterator));
-  i->namenode= 0;
+  i->namenode = NULL;
   i->nbinn= 0;
   i->nbinn= 0;
   return i;
   return i;
 }
 }
@@ -540,7 +544,8 @@ struct filenamenode *iterfilenext(struct fileiterator *i) {
   struct filenamenode *r= NULL;
   struct filenamenode *r= NULL;
 
 
   while (!i->namenode) {
   while (!i->namenode) {
-    if (i->nbinn >= BINS) return 0;
+    if (i->nbinn >= BINS)
+      return NULL;
     i->namenode= bins[i->nbinn++];
     i->namenode= bins[i->nbinn++];
   }
   }
   r= i->namenode;
   r= i->namenode;
@@ -559,8 +564,8 @@ void filesdbinit(void) {
   for (i=0; i<BINS; i++)
   for (i=0; i<BINS; i++)
     for (fnn= bins[i]; fnn; fnn= fnn->next) {
     for (fnn= bins[i]; fnn; fnn= fnn->next) {
       fnn->flags= 0;
       fnn->flags= 0;
-      fnn->oldhash= 0;
-      fnn->filestat= 0;
+      fnn->oldhash = NULL;
+      fnn->filestat = NULL;
     }
     }
 }
 }
 
 
@@ -587,7 +592,7 @@ struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
   if (*pointerp) return *pointerp;
   if (*pointerp) return *pointerp;
 
 
   newnode= nfmalloc(sizeof(struct filenamenode));
   newnode= nfmalloc(sizeof(struct filenamenode));
-  newnode->packages= 0;
+  newnode->packages = NULL;
   if((flags & fnn_nocopy) && name > orig_name && name[-1] == '/')
   if((flags & fnn_nocopy) && name > orig_name && name[-1] == '/')
     newnode->name = name - 1;
     newnode->name = name - 1;
   else {
   else {
@@ -596,10 +601,10 @@ struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
     newnode->name= newname;
     newnode->name= newname;
   }
   }
   newnode->flags= 0;
   newnode->flags= 0;
-  newnode->next= 0;
-  newnode->divert= 0;
-  newnode->statoverride= 0;
-  newnode->filestat= 0;
+  newnode->next = NULL;
+  newnode->divert = NULL;
+  newnode->statoverride = NULL;
+  newnode->filestat = NULL;
   *pointerp= newnode;
   *pointerp= newnode;
   nfiles++;
   nfiles++;
 
 

+ 8 - 6
src/help.c

@@ -73,7 +73,9 @@ void checkpath(void) {
 #if WITH_START_STOP_DAEMON
 #if WITH_START_STOP_DAEMON
     "start-stop-daemon",
     "start-stop-daemon",
 #endif    
 #endif    
-    "install-info", "update-rc.d", 0
+    "install-info",
+    "update-rc.d",
+    NULL
   };
   };
 
 
   struct stat stab;
   struct stat stab;
@@ -116,7 +118,7 @@ void ensure_package_clientdata(struct pkginfo *pkg) {
   pkg->clientdata= nfmalloc(sizeof(struct perpackagestate));
   pkg->clientdata= nfmalloc(sizeof(struct perpackagestate));
   pkg->clientdata->istobe= itb_normal;
   pkg->clientdata->istobe= itb_normal;
   pkg->clientdata->fileslistvalid= 0;
   pkg->clientdata->fileslistvalid= 0;
-  pkg->clientdata->files= 0;
+  pkg->clientdata->files = NULL;
 }
 }
 
 
 void cu_closepipe(int argc, void **argv) {
 void cu_closepipe(int argc, void **argv) {
@@ -209,7 +211,7 @@ static char *const *vbuildarglist(const char *scriptname, va_list ap) {
     if (!nextarg) break;
     if (!nextarg) break;
     bufs[i++]= nextarg;
     bufs[i++]= nextarg;
   }
   }
-  bufs[i]= 0;
+  bufs[i] = NULL;
   return bufs;
   return bufs;
 }    
 }    
 
 
@@ -229,7 +231,7 @@ static struct sigaction script_uncatchsignal[NSCRIPTCATCHSIGNALS];
 static void cu_restorescriptsignals(int argc, void **argv) {
 static void cu_restorescriptsignals(int argc, void **argv) {
   int i;
   int i;
   for (i=0; i<NSCRIPTCATCHSIGNALS; i++) {
   for (i=0; i<NSCRIPTCATCHSIGNALS; i++) {
-    if (sigaction(script_catchsignallist[i],&script_uncatchsignal[i],0)) {
+    if (sigaction(script_catchsignallist[i], &script_uncatchsignal[i], NULL)) {
       fprintf(stderr,_("error un-catching signal %s: %s\n"),
       fprintf(stderr,_("error un-catching signal %s: %s\n"),
               strsignal(script_catchsignallist[i]),strerror(errno));
               strsignal(script_catchsignallist[i]),strerror(errno));
       onerr_abort++;
       onerr_abort++;
@@ -250,7 +252,7 @@ static void script_catchsignals(void) {
     if (sigaction(script_catchsignallist[i],&catchsig,&script_uncatchsignal[i]))
     if (sigaction(script_catchsignallist[i],&catchsig,&script_uncatchsignal[i]))
       ohshite(_("unable to ignore signal %s before running script"),
       ohshite(_("unable to ignore signal %s before running script"),
               strsignal(script_catchsignallist[i]));
               strsignal(script_catchsignallist[i]));
-  push_cleanup(cu_restorescriptsignals,~0, 0,0, 0);
+  push_cleanup(cu_restorescriptsignals, ~0, NULL, 0, 0);
   onerr_abort--;
   onerr_abort--;
 }
 }
 
 
@@ -392,7 +394,7 @@ void clear_istobes(void) {
   struct pkginfo *pkg;
   struct pkginfo *pkg;
 
 
   it= iterpkgstart();
   it= iterpkgstart();
-  while ((pkg= iterpkgnext(it)) != 0) {
+  while ((pkg = iterpkgnext(it)) != NULL) {
     ensure_package_clientdata(pkg);
     ensure_package_clientdata(pkg);
     pkg->clientdata->istobe= itb_normal;
     pkg->clientdata->istobe= itb_normal;
     pkg->clientdata->replacingfilesandsaid= 0;
     pkg->clientdata->replacingfilesandsaid= 0;

+ 44 - 40
src/main.c

@@ -147,7 +147,7 @@ const char printforhelp[]= N_(
 "\n"
 "\n"
 "Options marked [*] produce a lot of output - pipe it through `less' or `more' !");
 "Options marked [*] produce a lot of output - pipe it through `less' or `more' !");
 
 
-const struct cmdinfo *cipaction= 0;
+const struct cmdinfo *cipaction = NULL;
 int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
 int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
 int f_autodeconf=0, f_nodebsig=0;
 int f_autodeconf=0, f_nodebsig=0;
 unsigned long f_debug=0;
 unsigned long f_debug=0;
@@ -162,7 +162,7 @@ int fc_badverify = 0;
 int errabort = 50;
 int errabort = 50;
 const char *admindir= ADMINDIR;
 const char *admindir= ADMINDIR;
 const char *instdir= "";
 const char *instdir= "";
-struct packageinlist *ignoredependss=0;
+struct packageinlist *ignoredependss = NULL;
 
 
 static const struct forceinfo {
 static const struct forceinfo {
   const char *name;
   const char *name;
@@ -190,7 +190,7 @@ static const struct forceinfo {
   { "bad-verify",          &fc_badverify                },
   { "bad-verify",          &fc_badverify                },
   /* FIXME: obsolete options, remove in the future. */
   /* FIXME: obsolete options, remove in the future. */
   { "auto-select",         NULL                         },
   { "auto-select",         NULL                         },
-  {  0                                                  }
+  {  NULL                                               }
 };
 };
 
 
 static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
 static void helponly(const struct cmdinfo *cip, const char *value) NONRETURNING;
@@ -268,7 +268,7 @@ static void ignoredepends(const struct cmdinfo *cip, const char *value) {
   }
   }
   p= copy;
   p= copy;
   while (*p) {
   while (*p) {
-    pnerr= illegal_packagename(p,0);
+    pnerr = illegal_packagename(p, NULL);
     if (pnerr) ohshite(_("--ignore-depends requires a legal package name. "
     if (pnerr) ohshite(_("--ignore-depends requires a legal package name. "
                        "`%.250s' is not; %s"), p, pnerr);
                        "`%.250s' is not; %s"), p, pnerr);
     ni= m_malloc(sizeof(struct packageinlist));
     ni= m_malloc(sizeof(struct packageinlist));
@@ -384,11 +384,11 @@ static const struct cmdinfo cmdinfos[]= {
    * have a very similar structure.
    * have a very similar structure.
    */
    */
 #define ACTION(longopt,shortopt,code,function) \
 #define ACTION(longopt,shortopt,code,function) \
- { longopt, shortopt, 0,0,0, setaction, code, 0, (voidfnp)function }
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
 #define OBSOLETE(longopt,shortopt) \
 #define OBSOLETE(longopt,shortopt) \
- { longopt, shortopt, 0,0,0, setobsolete, 0, 0, 0 }
+ { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
 #define ACTIONBACKEND(longopt,shortop, backend) \
 #define ACTIONBACKEND(longopt,shortop, backend) \
- { longopt, shortop, 0,0,0, setaction, 0, (void*)backend, (voidfnp)execbackend }
+ { longopt, shortop, 0, NULL, NULL, setaction, 0, (void *)backend, (voidfnp)execbackend }
 
 
   ACTION( "install",                        'i', act_install,              archivefiles    ),
   ACTION( "install",                        'i', act_install,              archivefiles    ),
   ACTION( "unpack",                          0,  act_unpack,               archivefiles    ),
   ACTION( "unpack",                          0,  act_unpack,               archivefiles    ),
@@ -422,34 +422,38 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION( "command-fd",                   'c', act_commandfd,   commandfd     ),
   ACTION( "command-fd",                   'c', act_commandfd,   commandfd     ),
 */
 */
   
   
-  { "status-fd",	  0,   1,  0,              0,  setpipe, 0, &status_pipes },
-  { "log",                0,   1,  0, &log_file,       0                             },
-  { "pending",           'a',  0,  &f_pending,     0,  0,             1              },
-  { "recursive",         'R',  0,  &f_recursive,   0,  0,             1              },
-  { "no-act",             0,   0,  &f_noact,       0,  0,             1              },
-  { "dry-run",            0,   0,  &f_noact,       0,  0,             1              },
-  { "simulate",           0,   0,  &f_noact,       0,  0,             1              },
-  { "no-debsig",          0,   0,  &f_nodebsig,    0,  0,             1              },
-  {  0,                  'G',  0,  &fc_downgrade,  0,  0, /* alias for --refuse */ 0 },
-  { "selected-only",     'O',  0,  &f_alsoselect,  0,  0,             0              },
-  { "no-also-select",    'N',  0,  &f_alsoselect,  0,0,0 /* fixme: remove sometime */ },
-  { "skip-same-version", 'E',  0,  &f_skipsame,    0,  0,             1              },
-  { "auto-deconfigure",  'B',  0,  &f_autodeconf,  0,  0,             1              },
+  { "status-fd",         0,   1, NULL,          NULL,      setpipe, 0, &status_pipes },
+  { "log",               0,   1, NULL,          &log_file, NULL,    0 },
+  { "pending",           'a', 0, &f_pending,    NULL,      NULL,    1 },
+  { "recursive",         'R', 0, &f_recursive,  NULL,      NULL,    1 },
+  { "no-act",            0,   0, &f_noact,      NULL,      NULL,    1 },
+  { "dry-run",           0,   0, &f_noact,      NULL,      NULL,    1 },
+  { "simulate",          0,   0, &f_noact,      NULL,      NULL,    1 },
+  { "no-debsig",         0,   0, &f_nodebsig,   NULL,      NULL,    1 },
+  /* Alias ('G') for --refuse. */
+  {  NULL,               'G', 0, &fc_downgrade, NULL,      NULL,    0 },
+  { "selected-only",     'O', 0, &f_alsoselect, NULL,      NULL,    0 },
+  /* FIXME: Remove ('N') sometime. */
+  { "no-also-select",    'N', 0, &f_alsoselect, NULL,      NULL,    0 },
+  { "skip-same-version", 'E', 0, &f_skipsame,   NULL,      NULL,    1 },
+  { "auto-deconfigure",  'B', 0, &f_autodeconf, NULL,      NULL,    1 },
   OBSOLETE( "largemem", 0 ),
   OBSOLETE( "largemem", 0 ),
   OBSOLETE( "smallmem", 0 ),
   OBSOLETE( "smallmem", 0 ),
-  { "root",               0,   1,  0, 0,               setroot                       },
-  { "abort-after",        0,   1,  &errabort,      0,  setinteger,    0              },
-  { "admindir",           0,   1,  0, &admindir,       0                             },
-  { "instdir",            0,   1,  0, &instdir,        0                             },
-  { "ignore-depends",     0,   1,  0, 0,               ignoredepends                 },
-  { "force",              0,   2,  0, 0,               setforce,      1              },
-  { "refuse",             0,   2,  0, 0,               setforce,      0              },
-  { "no-force",           0,   2,  0, 0,               setforce,      0              },
-  { "debug",             'D',  1,  0, 0,               setdebug                      },
-  { "help",              'h',  0,  0, 0,               helponly                      },
-  { "version",            0,   0,  0, 0,               versiononly                   },
-  { "licence",/* UK spelling */ 0,0,0,0,               showcopyright                 },
-  { "license",/* US spelling */ 0,0,0,0,               showcopyright                 },
+  { "root",              0,   1, NULL,          NULL,      setroot,       0 },
+  { "abort-after",       0,   1, &errabort,     NULL,      setinteger,    0 },
+  { "admindir",          0,   1, NULL,          &admindir, NULL,          0 },
+  { "instdir",           0,   1, NULL,          &instdir,  NULL,          0 },
+  { "ignore-depends",    0,   1, NULL,          NULL,      ignoredepends, 0 },
+  { "force",             0,   2, NULL,          NULL,      setforce,      1 },
+  { "refuse",            0,   2, NULL,          NULL,      setforce,      0 },
+  { "no-force",          0,   2, NULL,          NULL,      setforce,      0 },
+  { "debug",             'D', 1, NULL,          NULL,      setdebug,      0 },
+  { "help",              'h', 0, NULL,          NULL,      helponly,      0 },
+  { "version",           0,   0, NULL,          NULL,      versiononly,   0 },
+  /* UK spelling. */
+  { "licence",           0,   0, NULL,          NULL,      showcopyright, 0 },
+  /* US spelling. */
+  { "license",           0,   0, NULL,          NULL,      showcopyright, 0 },
   ACTIONBACKEND( "build",		'b', BACKEND),
   ACTIONBACKEND( "build",		'b', BACKEND),
   ACTIONBACKEND( "contents",		'c', BACKEND),
   ACTIONBACKEND( "contents",		'c', BACKEND),
   ACTIONBACKEND( "control",		'e', BACKEND),
   ACTIONBACKEND( "control",		'e', BACKEND),
@@ -460,7 +464,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTIONBACKEND( "old",			0,  BACKEND),
   ACTIONBACKEND( "old",			0,  BACKEND),
   ACTIONBACKEND( "vextract",		'X', BACKEND),
   ACTIONBACKEND( "vextract",		'X', BACKEND),
   ACTIONBACKEND( "fsys-tarfile",	0,   BACKEND),
   ACTIONBACKEND( "fsys-tarfile",	0,   BACKEND),
-  {  0,                   0                                                          }
+  { NULL,                0,   0, NULL,          NULL,      NULL,          0 }
 };
 };
 
 
 void execbackend(const char *const *argv) {
 void execbackend(const char *const *argv) {
@@ -471,7 +475,7 @@ void execbackend(const char *const *argv) {
   const char *const *arg = argv;
   const char *const *arg = argv;
   int pass_admindir = 0;
   int pass_admindir = 0;
 
 
-  while (*arg != 0) {
+  while (*arg != NULL) {
     arg++; argc++;
     arg++; argc++;
   }
   }
 
 
@@ -516,7 +520,7 @@ void execbackend(const char *const *argv) {
     if (!nargv[i])
     if (!nargv[i])
       ohshite(_("couldn't strdup in execbackend"));
       ohshite(_("couldn't strdup in execbackend"));
   }
   }
-  nargv[i] = 0;
+  nargv[i] = NULL;
 
 
   execvp(cipaction->parg, nargv);
   execvp(cipaction->parg, nargv);
   ohshite(_("failed to exec %s"), (char *)cipaction->parg);
   ohshite(_("failed to exec %s"), (char *)cipaction->parg);
@@ -550,7 +554,7 @@ void commandfd(const char *const *argv) {
     const char **oldargs= NULL;
     const char **oldargs= NULL;
     int argc= 1, mode= 0;
     int argc= 1, mode= 0;
     lno= 0;
     lno= 0;
-    push_error_handler(&ejbuf,print_error_fatal,0);
+    push_error_handler(&ejbuf, print_error_fatal, NULL);
 
 
     do { c= getc(in); if (c == '\n') lno++; } while (c != EOF && isspace(c));
     do { c= getc(in); if (c == '\n') lno++; } while (c != EOF && isspace(c));
     if (c == EOF) break;
     if (c == EOF) break;
@@ -597,7 +601,7 @@ printf("line=`%*s'\n",(int)linevb.used,linevb.buf);
       ptr++;
       ptr++;
     }
     }
     *ptr= 0;
     *ptr= 0;
-    newargs[argc++] = 0;
+    newargs[argc++] = NULL;
 
 
 /* We strdup each argument, but never free it, because the error messages
 /* We strdup each argument, but never free it, because the error messages
  * contain references back to these strings.  Freeing them, and reusing
  * contain references back to these strings.  Freeing them, and reusing
@@ -613,7 +617,7 @@ printf("line=`%*s'\n",(int)linevb.used,linevb.buf);
 
 
     actionfunction= (void (*)(const char* const*))cipaction->farg;
     actionfunction= (void (*)(const char* const*))cipaction->farg;
     actionfunction(newargs);
     actionfunction(newargs);
-    set_error_display(0,0);
+    set_error_display(NULL, NULL);
     error_unwind(ehflag_normaltidy);
     error_unwind(ehflag_normaltidy);
   }
   }
 }
 }
@@ -626,7 +630,7 @@ int main(int argc, const char *const *argv) {
   standard_startup(&ejbuf, argc, &argv, DPKG, 1, cmdinfos);
   standard_startup(&ejbuf, argc, &argv, DPKG, 1, cmdinfos);
   if (!cipaction) badusage(_("need an action option"));
   if (!cipaction) badusage(_("need an action option"));
 
 
-  setvbuf(stdout,0,_IONBF,0);
+  setvbuf(stdout, NULL, _IONBF, 0);
   filesdbinit();
   filesdbinit();
 
 
   actionfunction= (void (*)(const char* const*))cipaction->farg;
   actionfunction= (void (*)(const char* const*))cipaction->farg;

+ 9 - 9
src/packages.c

@@ -45,7 +45,7 @@ struct pkginqueue {
   struct pkginfo *pkg;
   struct pkginfo *pkg;
 };
 };
 
 
-static struct pkginqueue *queuehead= 0, **queuetail= &queuehead;
+static struct pkginqueue *queuehead = NULL, **queuetail = &queuehead;
 
 
 int queuelen=0, sincenothing=0, dependtry=0;
 int queuelen=0, sincenothing=0, dependtry=0;
 
 
@@ -54,7 +54,7 @@ void add_to_queue(struct pkginfo *pkg) {
 
 
   newent= m_malloc(sizeof(struct pkginqueue));
   newent= m_malloc(sizeof(struct pkginqueue));
   newent->pkg= pkg;
   newent->pkg= pkg;
-  newent->next= 0;
+  newent->next = NULL;
   *queuetail= newent;
   *queuetail= newent;
   queuetail= &newent->next;
   queuetail= &newent->next;
 
 
@@ -79,7 +79,7 @@ void packages(const char *const *argv) {
       badusage(_("--%s --pending does not take any non-option arguments"),cipaction->olong);
       badusage(_("--%s --pending does not take any non-option arguments"),cipaction->olong);
 
 
     it= iterpkgstart();
     it= iterpkgstart();
-    while ((pkg= iterpkgnext(it)) != 0) {
+    while ((pkg = iterpkgnext(it)) != NULL) {
       switch (cipaction->arg) {
       switch (cipaction->arg) {
       case act_configure:
       case act_configure:
         if (pkg->status != stat_unpacked && pkg->status != stat_halfconfigured)
         if (pkg->status != stat_unpacked && pkg->status != stat_halfconfigured)
@@ -108,7 +108,7 @@ void packages(const char *const *argv) {
     if (!*argv)
     if (!*argv)
       badusage(_("--%s needs at least one package name argument"), cipaction->olong);
       badusage(_("--%s needs at least one package name argument"), cipaction->olong);
     
     
-    while ((thisarg= *argv++) != 0) {
+    while ((thisarg = *argv++) != NULL) {
       pkg= findpackage(thisarg);
       pkg= findpackage(thisarg);
       if (pkg->status == stat_notinstalled) {
       if (pkg->status == stat_notinstalled) {
         l= strlen(pkg->name);
         l= strlen(pkg->name);
@@ -158,7 +158,7 @@ void process_queue(void) {
       default:
       default:
         internerr("unknown action in duplicate");
         internerr("unknown action in duplicate");
       }
       }
-      rundown->pkg= 0;
+      rundown->pkg = NULL;
    } else {
    } else {
       rundown->pkg->clientdata->istobe= istobe;
       rundown->pkg->clientdata->istobe= istobe;
     }
     }
@@ -206,7 +206,7 @@ void process_queue(void) {
     }
     }
     if (ferror(stdout)) werr("stdout");
     if (ferror(stdout)) werr("stdout");
     if (ferror(stderr)) werr("stderr");
     if (ferror(stderr)) werr("stderr");
-    set_error_display(0,0);
+    set_error_display(NULL, NULL);
     error_unwind(ehflag_normaltidy);
     error_unwind(ehflag_normaltidy);
   }
   }
 }    
 }    
@@ -401,7 +401,7 @@ int breakses_ok(struct pkginfo *pkg, struct varbuf *aemsgs) {
 
 
   debug(dbg_depcon, "    checking Breaks");
   debug(dbg_depcon, "    checking Breaks");
 
 
-  breaks_check_target(aemsgs, &ok, pkg, pkg, 0);
+  breaks_check_target(aemsgs, &ok, pkg, pkg, NULL);
 
 
   for (dep= pkg->installed.depends; dep; dep= dep->next) {
   for (dep= pkg->installed.depends; dep; dep= dep->next) {
     if (dep->type != dep_provides) continue;
     if (dep->type != dep_provides) continue;
@@ -437,7 +437,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
         debug(dbg_depcondetail,"      break cycle so ok and found");
         debug(dbg_depcondetail,"      break cycle so ok and found");
         found= 3; break;
         found= 3; break;
       }
       }
-      thisf= deppossi_ok_found(possi->ed,pkg,removing,0,
+      thisf = deppossi_ok_found(possi->ed, pkg, removing, NULL,
                                &matched,possi,&interestingwarnings,&oemsgs);
                                &matched,possi,&interestingwarnings,&oemsgs);
       if (thisf > found) found= thisf;
       if (thisf > found) found= thisf;
       if (found != 3 && possi->verrel == dvr_none) {
       if (found != 3 && possi->verrel == dvr_none) {
@@ -448,7 +448,7 @@ int dependencies_ok(struct pkginfo *pkg, struct pkginfo *removing,
             if (provider->up->type != dep_provides) continue;
             if (provider->up->type != dep_provides) continue;
             debug(dbg_depcondetail,"     checking provider %s",provider->up->up->name);
             debug(dbg_depcondetail,"     checking provider %s",provider->up->up->name);
             thisf= deppossi_ok_found(provider->up->up,pkg,removing,possi->ed,
             thisf= deppossi_ok_found(provider->up->up,pkg,removing,possi->ed,
-                                     &matched,0,&interestingwarnings,&oemsgs);
+                                     &matched, NULL, &interestingwarnings, &oemsgs);
             if (thisf > found) found= thisf;
             if (thisf > found) found= thisf;
           }
           }
         }
         }

+ 52 - 44
src/processarc.c

@@ -57,7 +57,7 @@ void process_archive(const char *filename) {
    */
    */
   static int p1[2];
   static int p1[2];
   static char cidirtmpnambuf[L_tmpnam+100];
   static char cidirtmpnambuf[L_tmpnam+100];
-  static char *cidirbuf=0, *reasmbuf=0;
+  static char *cidirbuf = NULL, *reasmbuf = NULL;
   static struct fileinlist *newconffiles, *newfileslist;
   static struct fileinlist *newconffiles, *newfileslist;
   static enum pkgstatus oldversionstatus;
   static enum pkgstatus oldversionstatus;
   static struct varbuf infofnvb, fnvb, depprobwhy;
   static struct varbuf infofnvb, fnvb, depprobwhy;
@@ -110,7 +110,7 @@ void process_archive(const char *filename) {
     }
     }
     if (unlink(reasmbuf) && errno != ENOENT)
     if (unlink(reasmbuf) && errno != ENOENT)
       ohshite(_("error ensuring `%.250s' doesn't exist"),reasmbuf);
       ohshite(_("error ensuring `%.250s' doesn't exist"),reasmbuf);
-    push_cleanup(cu_pathname,~0, 0,0, 1,(void*)reasmbuf);
+    push_cleanup(cu_pathname, ~0, NULL, 0, 1, (void *)reasmbuf);
     c1= m_fork();
     c1= m_fork();
     if (!c1) {
     if (!c1) {
       execlp(SPLITTER, SPLITTER, "-Qao", reasmbuf, filename, NULL);
       execlp(SPLITTER, SPLITTER, "-Qao", reasmbuf, filename, NULL);
@@ -180,7 +180,7 @@ void process_archive(const char *filename) {
   assert(*cidir && cidirrest[-1] == '/'); cidirrest[-1]= 0;
   assert(*cidir && cidirrest[-1] == '/'); cidirrest[-1]= 0;
   ensure_pathname_nonexisting(cidir); cidirrest[-1]= '/';
   ensure_pathname_nonexisting(cidir); cidirrest[-1]= '/';
   
   
-  push_cleanup(cu_cidir,~0, 0,0, 2,(void*)cidir,(void*)cidirrest);
+  push_cleanup(cu_cidir, ~0, NULL, 0, 2, (void *)cidir, (void *)cidirrest);
   c1= m_fork();
   c1= m_fork();
   if (!c1) {
   if (!c1) {
     cidirrest[-1]= 0;
     cidirrest[-1]= 0;
@@ -194,8 +194,8 @@ void process_archive(const char *filename) {
           &pkg,NULL,NULL);
           &pkg,NULL,NULL);
   if (!pkg->files) {
   if (!pkg->files) {
     pkg->files= nfmalloc(sizeof(struct filedetails));
     pkg->files= nfmalloc(sizeof(struct filedetails));
-    pkg->files->next= 0;
-    pkg->files->name= pkg->files->msdosname= pkg->files->md5sum= 0;
+    pkg->files->next = NULL;
+    pkg->files->name = pkg->files->msdosname = pkg->files->md5sum = NULL;
   }
   }
   /* Always nfmalloc.  Otherwise, we may overwrite some other field(like md5sum). */
   /* Always nfmalloc.  Otherwise, we may overwrite some other field(like md5sum). */
   pkg->files->size= nfmalloc(30);
   pkg->files->size= nfmalloc(30);
@@ -223,7 +223,7 @@ void process_archive(const char *filename) {
     deconpiltemp= deconpil->next;
     deconpiltemp= deconpil->next;
     free(deconpil);
     free(deconpil);
   }
   }
-  deconfigure= 0;
+  deconfigure = NULL;
   clear_istobes();
   clear_istobes();
 
 
   if (!wanttoinstall(pkg,&pkg->available.version,1)) {
   if (!wanttoinstall(pkg,&pkg->available.version,1)) {
@@ -264,7 +264,7 @@ void process_archive(const char *filename) {
       /* Ignore these here. */
       /* Ignore these here. */
       break;
       break;
     case dep_predepends:
     case dep_predepends:
-      if (!depisok(dsearch,&depprobwhy,0,1)) {
+      if (!depisok(dsearch, &depprobwhy, NULL, 1)) {
         varbufaddc(&depprobwhy,0);
         varbufaddc(&depprobwhy,0);
         fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
         fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
                 pfilename, pkg->name, depprobwhy.buf);
                 pfilename, pkg->name, depprobwhy.buf);
@@ -302,12 +302,13 @@ void process_archive(const char *filename) {
   /* OK, we're going ahead.  First we read the conffiles, and copy the
   /* OK, we're going ahead.  First we read the conffiles, and copy the
    * hashes across.
    * hashes across.
    */
    */
-  newconffiles= 0; newconffileslastp= &newconffiles;
-  push_cleanup(cu_fileslist,~0, 0, 0, 0);
+  newconffiles = NULL;
+  newconffileslastp = &newconffiles;
+  push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   strcpy(cidirrest,CONFFILESFILE);
   strcpy(cidirrest,CONFFILESFILE);
   conff= fopen(cidir,"r");
   conff= fopen(cidir,"r");
   if (conff) {
   if (conff) {
-    push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)conff);
+    push_cleanup(cu_closefile, ehflag_bombout, NULL, 0, 1, (void *)conff);
     while (fgets(conffilenamebuf,MAXCONFFILENAME-2,conff)) {
     while (fgets(conffilenamebuf,MAXCONFFILENAME-2,conff)) {
       p= conffilenamebuf + strlen(conffilenamebuf);
       p= conffilenamebuf + strlen(conffilenamebuf);
       assert(p != conffilenamebuf);
       assert(p != conffilenamebuf);
@@ -332,7 +333,7 @@ void process_archive(const char *filename) {
        * having that file.  If several packages are listed as owning
        * having that file.  If several packages are listed as owning
        * the file we pick one at random.
        * the file we pick one at random.
        */
        */
-      searchconff= 0;
+      searchconff = NULL;
       for (packageslump= newconff->namenode->packages;
       for (packageslump= newconff->namenode->packages;
            packageslump;
            packageslump;
            packageslump= packageslump->more) {
            packageslump= packageslump->more) {
@@ -390,7 +391,7 @@ void process_archive(const char *filename) {
     pkg->eflag |= eflagf_reinstreq;
     pkg->eflag |= eflagf_reinstreq;
     pkg->status= stat_halfconfigured;
     pkg->status= stat_halfconfigured;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
-    push_cleanup(cu_prermupgrade,~ehflag_normaltidy, 0,0, 1,(void*)pkg);
+    push_cleanup(cu_prermupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     maintainer_script_alternative(pkg, PRERMFILE, "pre-removal", cidir, cidirrest,
     maintainer_script_alternative(pkg, PRERMFILE, "pre-removal", cidir, cidirrest,
                                   "upgrade", "failed-upgrade");
                                   "upgrade", "failed-upgrade");
     pkg->status= stat_unpacked;
     pkg->status= stat_unpacked;
@@ -441,7 +442,7 @@ void process_archive(const char *filename) {
           conflictor[i]->status == stat_installed)) continue;
           conflictor[i]->status == stat_installed)) continue;
     conflictor[i]->status= stat_halfconfigured;
     conflictor[i]->status= stat_halfconfigured;
     modstatdb_note(conflictor[i]);
     modstatdb_note(conflictor[i]);
-    push_cleanup(cu_prerminfavour,~ehflag_normaltidy, 0,0,
+    push_cleanup(cu_prerminfavour, ~ehflag_normaltidy, NULL, 0,
                  2,(void*)conflictor[i],(void*)pkg);
                  2,(void*)conflictor[i],(void*)pkg);
     maintainer_script_installed(conflictor[i], PRERMFILE, "pre-removal",
     maintainer_script_installed(conflictor[i], PRERMFILE, "pre-removal",
                                 "remove", "in-favour", pkg->name,
                                 "remove", "in-favour", pkg->name,
@@ -458,19 +459,19 @@ void process_archive(const char *filename) {
   pkg->status= stat_halfinstalled;
   pkg->status= stat_halfinstalled;
   modstatdb_note(pkg);
   modstatdb_note(pkg);
   if (oldversionstatus == stat_notinstalled) {
   if (oldversionstatus == stat_notinstalled) {
-    push_cleanup(cu_preinstverynew,~ehflag_normaltidy, 0,0,
+    push_cleanup(cu_preinstverynew, ~ehflag_normaltidy, NULL, 0,
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
                           "install", NULL);
                           "install", NULL);
   } else if (oldversionstatus == stat_configfiles) {
   } else if (oldversionstatus == stat_configfiles) {
-    push_cleanup(cu_preinstnew,~ehflag_normaltidy, 0,0,
+    push_cleanup(cu_preinstnew, ~ehflag_normaltidy, NULL, 0,
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
                  3,(void*)pkg,(void*)cidir,(void*)cidirrest);
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
                           "install", versiondescribe(&pkg->installed.version,
                           "install", versiondescribe(&pkg->installed.version,
                                                      vdew_nonambig),
                                                      vdew_nonambig),
                           NULL);
                           NULL);
   } else {
   } else {
-    push_cleanup(cu_preinstupgrade,~ehflag_normaltidy, 0,0,
+    push_cleanup(cu_preinstupgrade, ~ehflag_normaltidy, NULL, 0,
                  4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus);
                  4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus);
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
     maintainer_script_new(pkg->name, PREINSTFILE, "pre-installation", cidir, cidirrest,
                           "upgrade", versiondescribe(&pkg->installed.version,
                           "upgrade", versiondescribe(&pkg->installed.version,
@@ -552,7 +553,7 @@ void process_archive(const char *filename) {
    */
    */
 
 
   m_pipe(p1);
   m_pipe(p1);
-  push_cleanup(cu_closepipe,ehflag_bombout, 0,0, 1,(void*)&p1[0]);
+  push_cleanup(cu_closepipe, ehflag_bombout, NULL, 0, 1, (void *)&p1[0]);
   c1= m_fork();
   c1= m_fork();
   if (!c1) {
   if (!c1) {
     m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
     m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
@@ -561,11 +562,12 @@ void process_archive(const char *filename) {
   }
   }
   close(p1[1]);
   close(p1[1]);
 
 
-  newfileslist= 0; tc.newfilesp= &newfileslist;
-  push_cleanup(cu_fileslist,~0, 0, 0, 0);
+  newfileslist = NULL;
+  tc.newfilesp = &newfileslist;
+  push_cleanup(cu_fileslist, ~0, NULL, 0, 0);
   tc.pkg= pkg;
   tc.pkg= pkg;
   tc.backendpipe= p1[0];
   tc.backendpipe= p1[0];
-  push_cleanup(cu_closefd,~ehflag_bombout, 0,0, 1,&tc.backendpipe);
+  push_cleanup(cu_closefd, ~ehflag_bombout, NULL, 0, 1, &tc.backendpipe);
 
 
   r= TarExtractor((void*)&tc, &tf);
   r= TarExtractor((void*)&tc, &tf);
   if (r) {
   if (r) {
@@ -585,7 +587,7 @@ void process_archive(const char *filename) {
      */
      */
     pkg->status= stat_halfinstalled;
     pkg->status= stat_halfinstalled;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
-    push_cleanup(cu_postrmupgrade,~ehflag_normaltidy, 0,0, 1,(void*)pkg);
+    push_cleanup(cu_postrmupgrade, ~ehflag_normaltidy, NULL, 0, 1, (void *)pkg);
     maintainer_script_alternative(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
     maintainer_script_alternative(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
                                   "upgrade", "failed-upgrade");
                                   "upgrade", "failed-upgrade");
   }
   }
@@ -658,7 +660,7 @@ void process_archive(const char *filename) {
        * the process a little leaner. We are only worried about new ones
        * the process a little leaner. We are only worried about new ones
        * since ones that stayed the same don't really apply here.
        * since ones that stayed the same don't really apply here.
        */
        */
-      struct fileinlist *sameas= 0;
+      struct fileinlist *sameas = NULL;
       /* If we can't stat the old or new file, or it's a directory,
       /* If we can't stat the old or new file, or it's a directory,
        * we leave it up to the normal code
        * we leave it up to the normal code
        */
        */
@@ -749,8 +751,8 @@ void process_archive(const char *filename) {
   varbufaddc(&infofnvb,0);
   varbufaddc(&infofnvb,0);
   dsd= opendir(infofnvb.buf);
   dsd= opendir(infofnvb.buf);
   if (!dsd) ohshite(_("cannot read info directory"));
   if (!dsd) ohshite(_("cannot read info directory"));
-  push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
-  while ((de= readdir(dsd)) != 0) {
+  push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
+  while ((de = readdir(dsd)) != NULL) {
     debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
     debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
     if (de->d_name[0] == '.') continue; /* ignore dotfiles, including `.' and `..' */
     if (de->d_name[0] == '.') continue; /* ignore dotfiles, including `.' and `..' */
     p= strrchr(de->d_name,'.'); if (!p) continue; /* ignore anything odd */
     p= strrchr(de->d_name,'.'); if (!p) continue; /* ignore anything odd */
@@ -784,7 +786,7 @@ void process_archive(const char *filename) {
   *cidirrest= 0; /* the directory itself */
   *cidirrest= 0; /* the directory itself */
   dsd= opendir(cidir);
   dsd= opendir(cidir);
   if (!dsd) ohshite(_("unable to open temp control directory"));
   if (!dsd) ohshite(_("unable to open temp control directory"));
-  push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
+  push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
   while ((de= readdir(dsd))) {
   while ((de= readdir(dsd))) {
     if (strchr(de->d_name,'.')) {
     if (strchr(de->d_name,'.')) {
       debug(dbg_scripts,"process_archive tmp.ci script/file `%s' contains dot",
       debug(dbg_scripts,"process_archive tmp.ci script/file `%s' contains dot",
@@ -835,17 +837,20 @@ void process_archive(const char *filename) {
    * links (linking our deppossi's into the reverse chains)
    * links (linking our deppossi's into the reverse chains)
    * can be done by copy_dependency_links.
    * can be done by copy_dependency_links.
    */
    */
-  newdeplist= 0; newdeplistlastp= &newdeplist;
+  newdeplist = NULL;
+  newdeplistlastp = &newdeplist;
   for (dep= pkg->available.depends; dep; dep= dep->next) {
   for (dep= pkg->available.depends; dep; dep= dep->next) {
     newdep= nfmalloc(sizeof(struct dependency));
     newdep= nfmalloc(sizeof(struct dependency));
     newdep->up= pkg;
     newdep->up= pkg;
-    newdep->next= 0;
-    newdep->list= 0; newpossilastp= &newdep->list;
+    newdep->next = NULL;
+    newdep->list = NULL;
+    newpossilastp = &newdep->list;
     for (possi= dep->list; possi; possi= possi->next) {
     for (possi= dep->list; possi; possi= possi->next) {
       newpossi= nfmalloc(sizeof(struct deppossi));
       newpossi= nfmalloc(sizeof(struct deppossi));
       newpossi->up= newdep;
       newpossi->up= newdep;
       newpossi->ed= possi->ed;
       newpossi->ed= possi->ed;
-      newpossi->next= 0; newpossi->nextrev= newpossi->backrev= 0;
+      newpossi->next = NULL;
+      newpossi->nextrev = newpossi->backrev = NULL;
       newpossi->verrel= possi->verrel;
       newpossi->verrel= possi->verrel;
       if (possi->verrel != dvr_none)
       if (possi->verrel != dvr_none)
         newpossi->version= possi->version;
         newpossi->version= possi->version;
@@ -883,10 +888,11 @@ void process_archive(const char *filename) {
   pkg->installed.bugs = pkg->available.bugs;                                   
   pkg->installed.bugs = pkg->available.bugs;                                   
 
 
   /* We have to generate our own conffiles structure. */
   /* We have to generate our own conffiles structure. */
-  pkg->installed.conffiles= 0; iconffileslastp= &pkg->installed.conffiles;
+  pkg->installed.conffiles = NULL;
+  iconffileslastp = &pkg->installed.conffiles;
   for (cfile= newconffiles; cfile; cfile= cfile->next) {
   for (cfile= newconffiles; cfile; cfile= cfile->next) {
     newiconff= nfmalloc(sizeof(struct conffile));
     newiconff= nfmalloc(sizeof(struct conffile));
-    newiconff->next= 0;
+    newiconff->next = NULL;
     newiconff->name= nfstrsave(cfile->namenode->name);
     newiconff->name= nfstrsave(cfile->namenode->name);
     newiconff->hash= nfstrsave(cfile->namenode->oldhash);
     newiconff->hash= nfstrsave(cfile->namenode->oldhash);
     newiconff->obsolete= !!(cfile->namenode->flags & fnnf_obs_conff);
     newiconff->obsolete= !!(cfile->namenode->flags & fnnf_obs_conff);
@@ -910,7 +916,7 @@ void process_archive(const char *filename) {
    * with them !).
    * with them !).
    */
    */
   it= iterpkgstart();
   it= iterpkgstart();
-  while ((otherpkg= iterpkgnext(it)) != 0) {
+  while ((otherpkg = iterpkgnext(it)) != NULL) {
     ensure_package_clientdata(otherpkg);
     ensure_package_clientdata(otherpkg);
     if (otherpkg == pkg ||
     if (otherpkg == pkg ||
         otherpkg->status == stat_notinstalled ||
         otherpkg->status == stat_notinstalled ||
@@ -940,7 +946,8 @@ void process_archive(const char *filename) {
          pdep= pdep->nextrev) {
          pdep= pdep->nextrev) {
       if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
       if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
           pdep->up->type != dep_recommends) continue;
           pdep->up->type != dep_recommends) continue;
-      if (depisok(pdep->up, &depprobwhy, 0,0)) continue;
+      if (depisok(pdep->up, &depprobwhy, NULL, 0))
+        continue;
       varbufaddc(&depprobwhy,0);
       varbufaddc(&depprobwhy,0);
       debug(dbg_veryverbose,"process_archive cannot disappear: %s",depprobwhy.buf);
       debug(dbg_veryverbose,"process_archive cannot disappear: %s",depprobwhy.buf);
       break;
       break;
@@ -957,7 +964,8 @@ void process_archive(const char *filename) {
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
           if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
               pdep->up->type != dep_recommends)
               pdep->up->type != dep_recommends)
             continue;
             continue;
-          if (depisok(pdep->up, &depprobwhy, 0,0)) continue;
+          if (depisok(pdep->up, &depprobwhy, NULL, 0))
+            continue;
           varbufaddc(&depprobwhy,0);
           varbufaddc(&depprobwhy,0);
           debug(dbg_veryverbose,"process_archive cannot disappear (provides %s): %s",
           debug(dbg_veryverbose,"process_archive cannot disappear (provides %s): %s",
                 providecheck->list->ed->name, depprobwhy.buf);
                 providecheck->list->ed->name, depprobwhy.buf);
@@ -990,11 +998,11 @@ void process_archive(const char *filename) {
     infodirbaseused= fnvb.used;
     infodirbaseused= fnvb.used;
     varbufaddc(&fnvb,0);
     varbufaddc(&fnvb,0);
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
-    push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
+    push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
 
 
     debug(dbg_general, "process_archive disappear cleaning info directory");
     debug(dbg_general, "process_archive disappear cleaning info directory");
       
       
-    while ((de= readdir(dsd)) != 0) {
+    while ((de = readdir(dsd)) != NULL) {
       debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
       debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
       if (de->d_name[0] == '.') continue;
       if (de->d_name[0] == '.') continue;
       p= strrchr(de->d_name,'.'); if (!p) continue;
       p= strrchr(de->d_name,'.'); if (!p) continue;
@@ -1014,15 +1022,15 @@ void process_archive(const char *filename) {
     otherpkg->want= want_purge;
     otherpkg->want= want_purge;
     otherpkg->eflag= eflagv_ok;
     otherpkg->eflag= eflagv_ok;
 
 
-    otherpkg->installed.depends= 0;
+    otherpkg->installed.depends = NULL;
     otherpkg->installed.essential= 0;
     otherpkg->installed.essential= 0;
-    otherpkg->installed.description= otherpkg->installed.maintainer= 0;
-    otherpkg->installed.installedsize= otherpkg->installed.source= 0;
-    otherpkg->installed.origin= otherpkg->installed.bugs= 0;
-    otherpkg->installed.architecture= 0;
-    otherpkg->installed.conffiles= 0;
+    otherpkg->installed.description = otherpkg->installed.maintainer = NULL;
+    otherpkg->installed.installedsize = otherpkg->installed.source = NULL;
+    otherpkg->installed.origin = otherpkg->installed.bugs = NULL;
+    otherpkg->installed.architecture = NULL;
+    otherpkg->installed.conffiles = NULL;
     blankversion(&otherpkg->installed.version);
     blankversion(&otherpkg->installed.version);
-    otherpkg->installed.arbs= 0;
+    otherpkg->installed.arbs = NULL;
     otherpkg->clientdata->fileslistvalid= 0;
     otherpkg->clientdata->fileslistvalid= 0;
 
 
     modstatdb_note(otherpkg);
     modstatdb_note(otherpkg);
@@ -1053,7 +1061,7 @@ void process_archive(const char *filename) {
               cfile->namenode->name, divpkg ? divpkg->name : "<local>");
               cfile->namenode->name, divpkg ? divpkg->name : "<local>");
       }        
       }        
     } else {
     } else {
-      divpkg= 0;
+      divpkg = NULL;
       debug(dbg_eachfile, "process_archive looking for overwriting `%s'",
       debug(dbg_eachfile, "process_archive looking for overwriting `%s'",
             cfile->namenode->name);
             cfile->namenode->name);
     }
     }

+ 16 - 16
src/remove.c

@@ -169,7 +169,7 @@ void deferred_remove(struct pkginfo *pkg) {
     oldpkgstatus= pkg->status;
     oldpkgstatus= pkg->status;
     pkg->status= stat_halfconfigured;
     pkg->status= stat_halfconfigured;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
-    push_cleanup(cu_prermremove, ~ehflag_normaltidy, 0, 0, 2,
+    push_cleanup(cu_prermremove, ~ehflag_normaltidy, NULL, 0, 2,
                  (void *)pkg, (void *)&oldpkgstatus);
                  (void *)pkg, (void *)&oldpkgstatus);
     maintainer_script_installed(pkg, PRERMFILE, "pre-removal",
     maintainer_script_installed(pkg, PRERMFILE, "pre-removal",
                                 "remove", NULL);
                                 "remove", NULL);
@@ -208,7 +208,7 @@ static void removal_bulk_remove_files(
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
     push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 
 
     reversefilelist_init(&rlistit,pkg->clientdata->files);
     reversefilelist_init(&rlistit,pkg->clientdata->files);
-    leftover= 0;
+    leftover = NULL;
     while ((namenode= reversefilelist_next(&rlistit))) {
     while ((namenode= reversefilelist_next(&rlistit))) {
       debug(dbg_eachfile, "removal_bulk `%s' flags=%o",
       debug(dbg_eachfile, "removal_bulk `%s' flags=%o",
             namenode->name, namenode->flags);
             namenode->name, namenode->flags);
@@ -291,12 +291,12 @@ static void removal_bulk_remove_files(
     infodirbaseused= fnvb.used;
     infodirbaseused= fnvb.used;
     varbufaddc(&fnvb,0);
     varbufaddc(&fnvb,0);
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
     dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
-    push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
+    push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
   *out_foundpostrm= 0;
   *out_foundpostrm= 0;
 
 
     debug(dbg_general, "removal_bulk cleaning info directory");
     debug(dbg_general, "removal_bulk cleaning info directory");
 
 
-    while ((de= readdir(dsd)) != 0) {
+    while ((de = readdir(dsd)) != NULL) {
     char *p;
     char *p;
 
 
       debug(dbg_veryverbose, "removal_bulk info file `%s'", de->d_name);
       debug(dbg_veryverbose, "removal_bulk info file `%s'", de->d_name);
@@ -335,7 +335,7 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
   push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
   push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
 
 
   reversefilelist_init(&rlistit,pkg->clientdata->files);
   reversefilelist_init(&rlistit,pkg->clientdata->files);
-  leftover= 0;
+  leftover = NULL;
   while ((namenode= reversefilelist_next(&rlistit))) {
   while ((namenode= reversefilelist_next(&rlistit))) {
     debug(dbg_eachfile, "removal_bulk `%s' flags=%o",
     debug(dbg_eachfile, "removal_bulk `%s' flags=%o",
           namenode->name, namenode->flags);
           namenode->name, namenode->flags);
@@ -391,7 +391,7 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
 }
 }
 
 
 static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
 static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
-  static const char *const removeconffexts[]= { REMOVECONFFEXTS, 0 };
+  static const char *const removeconffexts[] = { REMOVECONFFEXTS, NULL };
   int r, removevbbase;
   int r, removevbbase;
   int conffnameused, conffbasenamelen;
   int conffnameused, conffbasenamelen;
   char *conffbasename;
   char *conffbasename;
@@ -416,7 +416,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
      * are involved in diversions, except if we are the package doing the
      * are involved in diversions, except if we are the package doing the
      * diverting.
      * diverting.
      */
      */
-    for (lconffp= &pkg->installed.conffiles; (conff= *lconffp) != 0; ) {
+    for (lconffp = &pkg->installed.conffiles; (conff = *lconffp) != NULL; ) {
       for (searchfile= pkg->clientdata->files;
       for (searchfile= pkg->clientdata->files;
            searchfile && strcmp(searchfile->namenode->name,conff->name);
            searchfile && strcmp(searchfile->namenode->name,conff->name);
            searchfile= searchfile->next);
            searchfile= searchfile->next);
@@ -471,11 +471,11 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
                 fnvb.buf, conff->name);
                 fnvb.buf, conff->name);
       }
       }
       debug(dbg_conffdetail, "removal_bulk conffile cleaning dsd %s", fnvb.buf);
       debug(dbg_conffdetail, "removal_bulk conffile cleaning dsd %s", fnvb.buf);
-      push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
+      push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
       *p= '/';
       *p= '/';
       conffbasenamelen= strlen(++p);
       conffbasenamelen= strlen(++p);
       conffbasename= fnvb.buf+conffnameused-conffbasenamelen;
       conffbasename= fnvb.buf+conffnameused-conffbasenamelen;
-      while ((de= readdir(dsd)) != 0) {
+      while ((de = readdir(dsd)) != NULL) {
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry=`%s'"
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry=`%s'"
               " conffbasename=`%s' conffnameused=%d conffbasenamelen=%d",
               " conffbasename=`%s' conffnameused=%d conffbasenamelen=%d",
               de->d_name, conffbasename, conffnameused, conffbasenamelen);
               de->d_name, conffbasename, conffnameused, conffbasenamelen);
@@ -509,7 +509,7 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
     
     
     }
     }
     
     
-    pkg->installed.conffiles= 0;
+    pkg->installed.conffiles = NULL;
     modstatdb_note(pkg);
     modstatdb_note(pkg);
         
         
     maintainer_script_installed(pkg, POSTRMFILE, "post-removal",
     maintainer_script_installed(pkg, POSTRMFILE, "post-removal",
@@ -586,14 +586,14 @@ void removal_bulk(struct pkginfo *pkg) {
     /* This will mess up reverse links, but if we follow them
     /* This will mess up reverse links, but if we follow them
      * we won't go back because pkg->status is stat_notinstalled.
      * we won't go back because pkg->status is stat_notinstalled.
      */
      */
-    pkg->installed.depends= 0;
+    pkg->installed.depends = NULL;
     pkg->installed.essential= 0;
     pkg->installed.essential= 0;
-    pkg->installed.description= pkg->installed.maintainer= 0;
-    pkg->installed.source= pkg->installed.installedsize= 0;
-    pkg->installed.origin= pkg->installed.bugs= 0;
-    pkg->installed.architecture= 0;
+    pkg->installed.description = pkg->installed.maintainer = NULL;
+    pkg->installed.source = pkg->installed.installedsize = NULL;
+    pkg->installed.origin = pkg->installed.bugs = NULL;
+    pkg->installed.architecture = NULL;
     blankversion(&pkg->installed.version);
     blankversion(&pkg->installed.version);
-    pkg->installed.arbs= 0;
+    pkg->installed.arbs = NULL;
   }
   }
       
       
   pkg->eflag= eflagv_ok;
   pkg->eflag= eflagv_ok;

+ 3 - 2
src/update.c

@@ -79,10 +79,11 @@ void updateavailable(const char *const *argv) {
   varbufaddc(&vb,0);
   varbufaddc(&vb,0);
 
 
   if (cipaction->arg == act_avmerge)
   if (cipaction->arg == act_avmerge)
-    parsedb(vb.buf, pdb_recordavailable|pdb_rejectstatus, 0,0,0);
+    parsedb(vb.buf, pdb_recordavailable | pdb_rejectstatus, NULL, NULL, NULL);
 
 
   if (cipaction->arg != act_avclear)
   if (cipaction->arg != act_avclear)
-    count+= parsedb(sourcefile, pdb_recordavailable|pdb_rejectstatus, 0,0,0);
+    count += parsedb(sourcefile, pdb_recordavailable | pdb_rejectstatus,
+                     NULL, NULL, NULL);
 
 
   if (!f_noact) {
   if (!f_noact) {
     writedb(vb.buf,1,0);
     writedb(vb.buf,1,0);

+ 10 - 10
utils/start-stop-daemon.c

@@ -241,7 +241,7 @@ xmalloc(int size)
 static void
 static void
 xgettimeofday(struct timeval *tv)
 xgettimeofday(struct timeval *tv)
 {
 {
-	if (gettimeofday(tv,0) != 0)
+	if (gettimeofday(tv, NULL) != 0)
 		fatal("gettimeofday failed: %s", strerror(errno));
 		fatal("gettimeofday failed: %s", strerror(errno));
 }
 }
 
 
@@ -544,7 +544,7 @@ parse_options(int argc, char * const *argv)
 
 
 	for (;;) {
 	for (;;) {
 		c = getopt_long(argc, argv, "HKSVa:n:op:qr:s:tu:vx:c:N:k:bmR:g:d:",
 		c = getopt_long(argc, argv, "HKSVa:n:op:qr:s:tu:vx:c:N:k:bmR:g:d:",
-				longopts, (int *) 0);
+				longopts, NULL);
 		if (c == -1)
 		if (c == -1)
 			break;
 			break;
 		switch (c) {
 		switch (c) {
@@ -907,11 +907,11 @@ pid_is_cmd(pid_t pid, const char *name)
  
  
  
  
         kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
         kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-        if (kd == 0)
+        if (kd == NULL)
                 errx(1, "%s", errbuf);
                 errx(1, "%s", errbuf);
-        if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0)
+        if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == NULL)
                 errx(1, "%s", kvm_geterr(kd));
                 errx(1, "%s", kvm_geterr(kd));
-	if ((pid_argv_p = kvm_getargv(kd, kp, argv_len)) == 0)
+	if ((pid_argv_p = kvm_getargv(kd, kp, argv_len)) == NULL)
 		errx(1, "%s", kvm_geterr(kd)); 
 		errx(1, "%s", kvm_geterr(kd)); 
 
 
 	start_argv_0_p = *pid_argv_p;
 	start_argv_0_p = *pid_argv_p;
@@ -947,9 +947,9 @@ pid_is_user(pid_t pid, uid_t uid)
 
 
 
 
 	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
 	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-	if (kd == 0)
+	if (kd == NULL)
 		errx(1, "%s", errbuf);
 		errx(1, "%s", errbuf);
-	if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0)
+	if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == NULL)
 		errx(1, "%s", kvm_geterr(kd));
 		errx(1, "%s", kvm_geterr(kd));
 	if (kp->kp_proc.p_cred )
 	if (kp->kp_proc.p_cred )
 		kvm_read(kd, (u_long)&(kp->kp_proc.p_cred->p_ruid),
 		kvm_read(kd, (u_long)&(kp->kp_proc.p_cred->p_ruid),
@@ -968,9 +968,9 @@ pid_is_exec(pid_t pid, const char *name)
 	char errbuf[_POSIX2_LINE_MAX], *pidexec;
 	char errbuf[_POSIX2_LINE_MAX], *pidexec;
 
 
 	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
 	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-	if (kd == 0)
+	if (kd == NULL)
 		errx(1, "%s", errbuf);
 		errx(1, "%s", errbuf);
-	if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0)
+	if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == NULL)
 		errx(1, "%s", kvm_geterr(kd));
 		errx(1, "%s", kvm_geterr(kd));
 	pidexec = (&kp->kp_proc)->p_comm;
 	pidexec = (&kp->kp_proc)->p_comm;
 	if (strlen(name) != strlen(pidexec))
 	if (strlen(name) != strlen(pidexec))
@@ -1203,7 +1203,7 @@ run_stop_schedule(void)
 				    interval.tv_usec <= MIN_POLL_INTERVAL)
 				    interval.tv_usec <= MIN_POLL_INTERVAL)
 				        interval.tv_usec = MIN_POLL_INTERVAL;
 				        interval.tv_usec = MIN_POLL_INTERVAL;
 
 
-				r = select(0,0,0,0,&interval);
+				r = select(0, NULL, NULL, NULL, &interval);
 				if (r < 0 && errno != EINTR)
 				if (r < 0 && errno != EINTR)
 					fatal("select() failed for pause: %s",
 					fatal("select() failed for pause: %s",
 					      strerror(errno));
 					      strerror(errno));