Преглед изворни кода

Convert waitsubproc and checksubprocerr to use a flags variable, instead of
separate ints.

Adam Heath пре 25 година
родитељ
комит
d1fb4dd723
10 измењених фајлова са 33 додато и 25 уклоњено
  1. 6 0
      ChangeLog
  2. 5 5
      dpkg-deb/build.c
  3. 4 4
      dpkg-deb/extract.c
  4. 1 1
      dpkg-deb/info.c
  5. 4 2
      include/dpkg.h.in
  6. 6 6
      lib/mlib.c
  7. 1 1
      main/archives.c
  8. 1 1
      main/enquiry.c
  9. 2 2
      main/help.c
  10. 3 3
      main/processarc.c

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+Mon Apr 23 15:39:37 CDT 2001 Adam Heath <doogie@debian.org>
+
+  * dpkg-deb/{build,extract,info}.c, include/dpkg.h.in, lib/mlib.c,
+    main/{archives,enquiry,help,processarc}.c: Convert waitsubproc and
+    checksubprocerr to use a flags variable, instead of separate ints.
+
 Mon Apr 23 15:36:58 CDT 2001 Adam Heath <doogie@debian.org>
 
   * main/depcon.c, debian/changelog: When walking the list of providers of

+ 5 - 5
dpkg-deb/build.c

@@ -394,8 +394,8 @@ void do_build(const char *const *argv) {
     internalGzip(0, 1, "9", _("control"));
   }
   close(p1[0]);
-  waitsubproc(c2,"gzip -9c",0,0);
-  waitsubproc(c1,"tar -cf",0,0);
+  waitsubproc(c2,"gzip -9c",0);
+  waitsubproc(c1,"tar -cf",0);
   if (fstat(gzfd,&controlstab)) ohshite(_("failed to fstat tmpfile (control)"));
   /* We have our first file for the ar-archive. Write a header for it to the
    * package and insert it.
@@ -481,7 +481,7 @@ void do_build(const char *const *argv) {
 	ohshite(_("failed to write filename to tar pipe (data)"));
     }
   close(p3[0]);
-  waitsubproc(c3,"find",0,0);
+  waitsubproc(c3,"find",0);
 
   for (fi= symlist;fi;fi= fi->next)
     if (write(p1[1], fi->fn, strlen(fi->fn)+1) == -1)
@@ -489,8 +489,8 @@ void do_build(const char *const *argv) {
   /* All done, clean up wait for tar and gzip to finish their job */
   close(p1[1]);
   free_filist(symlist);
-  waitsubproc(c2,"gzip -9c from tar -cf",0,0);
-  waitsubproc(c1,"tar -cf",0,0);
+  waitsubproc(c2,"gzip -9c from tar -cf",0);
+  waitsubproc(c1,"tar -cf",0);
   /* Okay, we have data.tar.gz as well now, add it to the ar wrapper */
   if (!oldformatflag) {
     if (fstat(gzfd,&datastab)) ohshite("_(failed to fstat tmpfile (data))");

+ 4 - 4
dpkg-deb/extract.c

@@ -50,7 +50,7 @@ static void movecontrolfiles(const char *thing) {
   if (!(c1= m_fork())) {
     execlp("sh","sh","-c",buf,(char*)0); ohshite(_("failed to exec sh -c mv foo/* &c"));
   }
-  waitsubproc(c1,"sh -c mv foo/* &c",0,0);
+  waitsubproc(c1,"sh -c mv foo/* &c",0);
 }
 
 static void readfail(FILE *a, const char *filename, const char *what) NONRETURNING;
@@ -303,11 +303,11 @@ void extracthalf(const char *debar, const char *directory,
       ohshite(_("failed to exec tar"));
     }
     close(p2[0]);
-    waitsubproc(c3,"tar",0,0);
+    waitsubproc(c3,"tar",0);
   }
   
-  waitsubproc(c2,"gzip -dc",1,0);
-  if (c1 != -1) waitsubproc(c1,"paste",0,0);
+  waitsubproc(c2,"gzip -dc",PROCPIPE);
+  if (c1 != -1) waitsubproc(c1,"paste",0);
   if (oldformat && admininfo) {
     if (versionnum == 0.931F) {
       movecontrolfiles(OLDOLDDEBDIR);

+ 1 - 1
dpkg-deb/info.c

@@ -72,7 +72,7 @@ static void info_prepare(const char *const **argvp,
   if (!(c1= m_fork())) {
     execlp(RM,"rm","-rf",dbuf,(char*)0); ohshite(_("failed to exec rm -rf"));
   }
-  waitsubproc(c1,"rm -rf",0,0);
+  waitsubproc(c1,"rm -rf",0);
   push_cleanup(cu_info_prepare,-1, 0,0, 1, (void*)dbuf);
   extracthalf(*debarp, dbuf, "mx", admininfo);
 }

+ 4 - 2
include/dpkg.h.in

@@ -195,8 +195,10 @@ int m_fork(void);
 void m_dup2(int oldfd, int newfd);
 void m_pipe(int fds[2]);
 
-int checksubprocerr(int status, const char *description, int sigpipeok, int warn);
-int waitsubproc(pid_t pid, const char *description, int sigpipeok, int warn);
+#define PROCPIPE 1
+#define PROCWARN 2
+int checksubprocerr(int status, const char *description, int flags);
+int waitsubproc(pid_t pid, const char *description, int flags);
 
 #define BUFFER_WRITE_BUF 0
 #define BUFFER_WRITE_VBUF 1

+ 6 - 6
lib/mlib.c

@@ -103,17 +103,17 @@ void m_pipe(int *fds) {
   ohshite(_("failed to create pipe"));
 }
 
-int checksubprocerr(int status, const char *description, int sigpipeok, int warn) {
+int checksubprocerr(int status, const char *description, int flags) {
   int n;
   if (WIFEXITED(status)) {
     n= WEXITSTATUS(status); if (!n) return n;
-    if(warn)
+    if(flags & PROCWARN)
       fprintf(stderr, _("dpkg: warning - %s returned error exit status %d\n"),description,n);
     else
       ohshit(_("subprocess %s returned error exit status %d"),description,n);
   } else if (WIFSIGNALED(status)) {
-    n= WTERMSIG(status); if (!n || (sigpipeok && n==SIGPIPE)) return 0;
-    if (warn)
+    n= WTERMSIG(status); if (!n || ((flags & PROCPIPE) && n==SIGPIPE)) return 0;
+    if (flags & PROCWARN)
       ohshit(_("dpkg: warning - %s killed by signal (%s)%s\n"),
            description, strsignal(n), WCOREDUMP(status) ? ", core dumped" : "");
     else
@@ -125,13 +125,13 @@ int checksubprocerr(int status, const char *description, int sigpipeok, int warn
   return -1;
 }
 
-int waitsubproc(pid_t pid, const char *description, int sigpipeok, int warn) {
+int waitsubproc(pid_t pid, const char *description, int flags) {
   pid_t r;
   int status;
 
   while ((r= waitpid(pid,&status,0)) == -1 && errno == EINTR);
   if (r != pid) { onerr_abort++; ohshite(_("wait for %s failed"),description); }
-  return checksubprocerr(status,description,sigpipeok, warn);
+  return checksubprocerr(status,description,flags);
 }
 
 ssize_t buffer_write(buffer_data_t data, void *buf, ssize_t length, const char *desc) {

+ 1 - 1
main/archives.c

@@ -819,7 +819,7 @@ void archivefiles(const char *const *argv) {
     }
     if (ferror(pf)) ohshite(_("error reading find's pipe"));
     if (fclose(pf)) ohshite(_("error closing find's pipe"));
-    waitsubproc(fc,"find",0,0);
+    waitsubproc(fc,"find",0);
 
     if (!nfiles)
       ohshit(_("searched, but found no packages (files matching *.deb)"));

+ 1 - 1
main/enquiry.c

@@ -699,7 +699,7 @@ void printarch(const char *const *argv) {
   }
   close(p1[1]);
   fd_vbuf_copy(fileno(ccpipe), &vb, -1, _("error reading from CC pipe"));
-  waitsubproc(c1,"gcc --print-libgcc-file-name",0,0);
+  waitsubproc(c1,"gcc --print-libgcc-file-name",0);
   if (!vb.used) badlgccfn(ccompiler,"",_("empty output"));
   varbufaddc(&vb,0);
   if (vb.buf[vb.used-2] != '\n') badlgccfn(ccompiler,vb.buf,_("no newline"));

+ 2 - 2
main/help.c

@@ -271,7 +271,7 @@ static int do_script(const char *pkg, const char *scriptname, const char *script
     ohshite(desc,name);
   }
   script_catchsignals(); /* This does a push_cleanup() */
-  r= waitsubproc(c1,name,0,warn);
+  r= waitsubproc(c1,name,PROCWARN);
   pop_cleanup(ehflag_normaltidy);
   return r;
 }
@@ -477,5 +477,5 @@ void ensure_pathname_nonexisting(const char *pathname) {
     ohshite(_("failed to exec rm for cleanup"));
   }
   debug(dbg_eachfile,"ensure_pathname_nonexisting running rm -rf");
-  waitsubproc(c1,"rm cleanup",0,0);
+  waitsubproc(c1,"rm cleanup",0);
 }

+ 3 - 3
main/processarc.c

@@ -132,7 +132,7 @@ void process_archive(const char *filename) {
       /* No, it wasn't a part. */
       break;
     default:
-      checksubprocerr(status,SPLITTER,0,0);
+      checksubprocerr(status,SPLITTER,0);
     }
   }
   
@@ -187,7 +187,7 @@ void process_archive(const char *filename) {
     execlp(BACKEND, BACKEND,"--control",filename,cidir,(char*)0);
     ohshite(_("failed to exec dpkg-deb to extract control information"));
   }
-  waitsubproc(c1,BACKEND " --control",0,0);
+  waitsubproc(c1,BACKEND " --control",0);
   strcpy(cidirrest,CONTROLFILE);
 
   parsedb(cidir, pdb_recordavailable|pdb_rejectstatus|pdb_ignorefiles|pdb_weakclassification,
@@ -552,7 +552,7 @@ void process_archive(const char *filename) {
   }
   fd_null_copy(tc.backendpipe,-1,_("dpkg-deb: zap possible trailing zeros"));
   close(tc.backendpipe);
-  waitsubproc(c1,BACKEND " --fsys-tarfile",1,0);
+  waitsubproc(c1,BACKEND " --fsys-tarfile",PROCPIPE);
 
   if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) {
     /* Packages that were in `installed' and `postinstfailed' have been reduced