The following commit has been merged in the master branch:
commit cb30ab1729f7cd1fa1620f4b9de3d2ed020bc238
Author: Guillem Jover <[EMAIL PROTECTED]>
Date:   Sat Dec 6 19:05:10 2008 +0200

    Properly use internerr to report about programming bugs
    
    Use internerr for internal error conditions which happen only due to
    programming bugs and should never occur, otherwise the code is wrong
    and should be fixed.

diff --git a/ChangeLog b/ChangeLog
index b4fd78a..77e21a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2008-12-08  Guillem Jover  <[EMAIL PROTECTED]>
 
+       * dpkg-deb/build.c (do_build): Use internerr instead of ohshit. Do not
+       mark the string for translation.
+       * src/trigcmd.c (do_check): Use internerr instead of abort.
+       * lib/dump.c (w_status): Likewise.
+       * lib/triglib.c (trig_incorporate): Likewise. Remove <stdlib.h>
+       include.
+       * scripts/Dpkg/IPC.pm (_sanity_check_opts): Use internerr instead of
+       error.
+       (fork_and_exec): Likewise. Do not mark the string for translation.
+       (wait_child): Likewise.
+       * scripts/Dpkg/Source/Archive.pm: Use internerr instead of error from
+       Dpkg::ErrorHandling.
+       (_add_entry, add_file, add_directory): Likewise.
+       * scripts/Dpkg/Source/CompressedFile.pm: Likewise.
+       (get_filename): Likewise.
+       * scripts/Dpkg/Source/Compressor.pm: Likewise.
+       (_sanity_check): Likewise.
+       * scripts/Dpkg/Source/Package.p (do_extract, do_build): Likewise.
+       * scripts/Dpkg/Source/Patch.pm (add_diff_file): Use error instead of
+       internerr.
+
+2008-12-08  Guillem Jover  <[EMAIL PROTECTED]>
+
        * lib/dpkg.h (do_internerr): Reorder arguments. Support format
        strings.
        (internerr): Likewise.
diff --git a/debian/changelog b/debian/changelog
index a8cb538..7b30fae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,6 +37,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Mark program names in dpkg-trigger.1 in bold.
   * Unmark dselect debug messages for translation.
   * Use a the warning function to uniformly print all warning messages.
+  * Properly use internerr to report about programming bugs.
 
   [ Raphael Hertzog ]
   * Enhance dpkg-shlibdeps's error message when a library can't be found to
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index cea3303..d5c8a15 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -491,7 +491,7 @@ void do_build(const char *const *argv) {
       datamember = DATAMEMBER_CAT;
       break;
     default:
-      ohshit(_("Internal error, compress_type `%i' unknown!"), compress_type);
+      internerr("unkown compress_type '%i'", compress_type);
     }
     if (fstat(gzfd, &datastab))
       ohshite(_("failed to fstat tmpfile (data)"));
diff --git a/lib/dump.c b/lib/dump.c
index cb1089d..1c77ea5 100644
--- a/lib/dump.c
+++ b/lib/dump.c
@@ -195,7 +195,7 @@ void w_status(struct varbuf *vb,
     assert(!AW);
     break;
   default:
-    abort();
+    internerr("unknown package status '%d'", pigp->status);
   }
 #undef PEND
 #undef AW
diff --git a/lib/triglib.c b/lib/triglib.c
index 6da8709..fd5f0aa 100644
--- a/lib/triglib.c
+++ b/lib/triglib.c
@@ -26,7 +26,6 @@
 #include <dpkg-i18n.h>
 
 #include <assert.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
 
@@ -755,7 +754,7 @@ trig_incorporate(enum modstatdb_rw cstatus, const char 
*admindir)
                trigdef_yylex();
                break;
        default:
-               abort();
+               internerr("unknown trigdef_update_start return value '%d'", ur);
        }
 
        /* Right, that's it. New (empty) Unincorp can be installed. */
diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm
index af93b34..4975600 100644
--- a/scripts/Dpkg/IPC.pm
+++ b/scripts/Dpkg/IPC.pm
@@ -128,7 +128,7 @@ listed in the array before calling exec.
 sub _sanity_check_opts {
     my (%opts) = @_;
 
-    error("exec parameter is mandatory in fork_and_exec()")
+    internerr("exec parameter is mandatory in fork_and_exec()")
        unless $opts{"exec"};
 
     my $to = my $error_to = my $from = 0;
@@ -137,11 +137,11 @@ sub _sanity_check_opts {
        $error_to++ if $opts{"error_to_$_"};
        $from++ if $opts{"from_$_"};
     }
-    error("not more than one of to_* parameters is allowed")
+    internerr("not more than one of to_* parameters is allowed")
        if $to > 1;
-    error("not more than one of error_to_* parameters is allowed")
+    internerr("not more than one of error_to_* parameters is allowed")
        if $error_to > 1;
-    error("not more than one of from_* parameters is allowed")
+    internerr("not more than one of from_* parameters is allowed")
        if $from > 1;
 
     foreach (qw(to_string error_to_string from_string
@@ -149,16 +149,16 @@ sub _sanity_check_opts {
     {
        if (exists $opts{$_} and
            (!ref($opts{$_}) or ref($opts{$_}) ne 'SCALAR')) {
-           error("parameter $_ must be a scalar reference");
+           internerr("parameter $_ must be a scalar reference");
        }
     }
 
     if (exists $opts{"env"} and ref($opts{"env"}) ne 'HASH') {
-       error("parameter env must be a hash reference");
+       internerr("parameter env must be a hash reference");
     }
 
     if (exists $opts{"delete_env"} and ref($opts{"delete_env"}) ne 'ARRAY') {
-       error("parameter delete_env must be an array reference");
+       internerr("parameter delete_env must be an array reference");
     }
 
     return %opts;
@@ -173,7 +173,7 @@ sub fork_and_exec {
     } elsif (not ref($opts{"exec"})) {
        push @prog, $opts{"exec"};
     } else {
-       error(_g("invalid exec parameter in fork_and_exec()"));
+       internerr("invalid exec parameter in fork_and_exec()");
     }
     my ($from_string_pipe, $to_string_pipe, $error_to_string_pipe);
     if ($opts{"to_string"}) {
@@ -308,7 +308,7 @@ non-zero return code).
 sub wait_child {
     my ($pid, %opts) = @_;
     $opts{"cmdline"} ||= _g("child process");
-    error(_g("no PID set, cannot wait end of process")) unless $pid;
+    internerr("no PID set, cannot wait end of process") unless $pid;
     $pid == waitpid($pid, 0) or syserr(_g("wait for %s"), $opts{"cmdline"});
     unless ($opts{"nocheck"}) {
        subprocerr($opts{"cmdline"}) if $?;
diff --git a/scripts/Dpkg/Source/Archive.pm b/scripts/Dpkg/Source/Archive.pm
index f1dbb65..5d1ae4e 100644
--- a/scripts/Dpkg/Source/Archive.pm
+++ b/scripts/Dpkg/Source/Archive.pm
@@ -52,7 +52,7 @@ sub create {
 
 sub _add_entry {
     my ($self, $file) = @_;
-    error("call create first") unless $self->{"tar_input"};
+    internerr("call create first") unless $self->{"tar_input"};
     $file = $2 if ($file =~ /^\Q$self->{'cwd'}\E\/(.+)$/); # Relative names
     print({ $self->{'tar_input'} } "$file\0") ||
            syserr(_g("write on tar input"));
@@ -64,7 +64,7 @@ sub add_file {
     if ($self->{"chdir"}) {
         $testfile = File::Spec->catfile($self->{"chdir"}, $file);
     }
-    error("add_file() doesn't handle directories") if not -l $testfile and -d 
_;
+    internerr("add_file() doesn't handle directories") if not -l $testfile and 
-d _;
     $self->_add_entry($file);
 }
 
@@ -74,7 +74,7 @@ sub add_directory {
     if ($self->{"chdir"}) {
         $testfile = File::Spec->catdir($self->{"chdir"}, $file);
     }
-    error("add_directory() only handles directories") unless not -l $testfile 
and -d _;
+    internerr("add_directory() only handles directories") unless not -l 
$testfile and -d _;
     $self->_add_entry($file);
 }
 
diff --git a/scripts/Dpkg/Source/CompressedFile.pm 
b/scripts/Dpkg/Source/CompressedFile.pm
index a3df25b..1784cdf 100644
--- a/scripts/Dpkg/Source/CompressedFile.pm
+++ b/scripts/Dpkg/Source/CompressedFile.pm
@@ -83,8 +83,8 @@ sub get_filename {
     my $comp = $self->{"compression"};
     if ($self->{'add_comp_ext'}) {
        if ($comp eq "auto") {
-           error("automatic detection of compression is " .
-                 "incompatible with add_comp_ext");
+           internerr("automatic detection of compression is " .
+                     "incompatible with add_comp_ext");
        } elsif ($comp eq "none") {
            return $self->{"filename"};
        } else {
diff --git a/scripts/Dpkg/Source/Compressor.pm 
b/scripts/Dpkg/Source/Compressor.pm
index 0ab236d..bcaafea 100644
--- a/scripts/Dpkg/Source/Compressor.pm
+++ b/scripts/Dpkg/Source/Compressor.pm
@@ -96,8 +96,8 @@ sub _sanity_check {
         $to++ if $opts{"to_$_"};
         $from++ if $opts{"from_$_"};
     }
-    error("exactly one to_* parameter is needed") if $to != 1;
-    error("exactly one from_* parameter is needed") if $from != 1;
+    internerr("exactly one to_* parameter is needed") if $to != 1;
+    internerr("exactly one from_* parameter is needed") if $from != 1;
     return %opts;
 }
 
diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index fd77325..0794886 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -372,7 +372,8 @@ sub extract {
 }
 
 sub do_extract {
-    error("Dpkg::Source::Package doesn't know how to unpack a source package. 
Use one of the subclasses.");
+    internerr("Dpkg::Source::Package doesn't know how to unpack a " .
+              "source package. Use one of the subclasses.");
 }
 
 # Function used specifically during creation of a source package
@@ -387,7 +388,8 @@ sub build {
 }
 
 sub do_build {
-    error("Dpkg::Source::Package doesn't know how to build a source package. 
Use one of the subclasses.");
+    internerr("Dpkg::Source::Package doesn't know how to build a " .
+              "source package. Use one of the subclasses.");
 }
 
 sub can_build {
diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm
index dcf31ae..15f1c36 100644
--- a/scripts/Dpkg/Source/Patch.pm
+++ b/scripts/Dpkg/Source/Patch.pm
@@ -111,8 +111,7 @@ sub add_diff_file {
                        "original or modified version)"), $new);
         } else {
             chomp;
-            internerr(_g("unknown line from diff -u on %s: `%s'"),
-                      $new, $_);
+            error(_g("unknown line from diff -u on %s: `%s'"), $new, $_);
         }
         print({ $self->{'handle'} } $_) || syserr(_g("failed to write"));
     }
diff --git a/src/trigcmd.c b/src/trigcmd.c
index d9ba7bd..a377438 100644
--- a/src/trigcmd.c
+++ b/src/trigcmd.c
@@ -177,7 +177,7 @@ do_check(void)
        case -2:
                exit(0);
        default:
-               abort();
+               internerr("unknown trigdef_update_start return value '%d'", uf);
        }
 }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to