]> granicus.if.org Git - postgresql/commitdiff
Remove dead code in pg_dump.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Jan 2016 16:38:40 +0000 (11:38 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 17 Jan 2016 16:38:40 +0000 (11:38 -0500)
Coverity quite reasonably complained that this check for fout==NULL
occurred after we'd already dereferenced fout.  However, the check
is just dead code since there is no code path by which CreateArchive
can return a null pointer.  Errors such as can't-open-that-file are
reported down inside CreateArchive, and control doesn't return.
So let's silence the warning by removing the dead code, rather than
continuing to pretend it does something.

Coverity didn't complain about this before 5b5fea2a1, so back-patch
to 9.5 like that patch.

src/bin/pg_dump/pg_dump.c

index 9196cf44d981227801990bbcc8ab82bb4cff36a4..59542aa1d3d442aa7556b3ca15c1b9c3c0aeb403 100644 (file)
@@ -617,9 +617,6 @@ main(int argc, char **argv)
        /* Register the cleanup hook */
        on_exit_close_archive(fout);
 
-       if (fout == NULL)
-               exit_horribly(NULL, "could not open output file \"%s\" for writing\n", filename);
-
        /* Let the archiver know how noisy to be */
        fout->verbose = g_verbose;