In initdb, many global string variables are initialized as empty strings
("") and then checked later with strcmp(), instead of just using NULL.
I think this is probably left over from the shell script conversion.
The style has also spread to pg_basebackup. So here is a patch to clean
that up, and a second patch to clean up some other a bit confusing
business in initdb that seems like old shell script code.
While looking around, I found some useless empty string initializations
in the ecpg test suite as well, and here is another patch for that.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 13071706e5e82e2bebd68ae6b68af471e1141802 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut
Date: Wed, 30 Aug 2017 22:28:36 -0400
Subject: [PATCH 1/3] Remove useless dead code
---
.../ecpg/test/expected/pgtypeslib-dt_test.c| 22 +++---
src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc| 22 +++---
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
index 00d43915b2..69a605c7e6 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
@@ -155,7 +155,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
/* rdate_defmt_asc() */
- date1 = 0; text = "";
+ date1 = 0;
fmt = "yy/mm/dd";
in = "In the year 1995, the month of December, it is the 25th day";
/*0123456789012345678901234567890123456789012345678901234567890
@@ -166,7 +166,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc1: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = ". dd. ";
in = "12/25/95";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -174,7 +174,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc2: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "yy/mm/dd";
in = "95/12/25";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -182,7 +182,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc3: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "yy/mm/dd";
in = "1995, December 25th";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc4: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "dd-mm-yy";
in = "This is 25th day of December, 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -198,7 +198,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc5: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "mmddyy";
in = "Dec. 25th, 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -206,7 +206,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc6: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "mmm. dd. ";
in = "dec 25th 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -214,7 +214,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc7: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "mmm. dd. ";
in = "DEC-25-1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -222,7 +222,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc8: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "mm yy dd.";
in = "12199525";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -230,7 +230,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc9: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = " fierj mm dd.";
in = "19951225";
PGTYPESdate_defmt_asc(&date1, fmt, in);
@@ -238,7 +238,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
printf("date_defmt_asc10: %s\n", text);
free(text);
- date1 = 0; text = "";
+ date1 = 0;
fmt = "mm/dd/yy";
in = "122595";
PGTYPESdate_defmt_asc(&date1, fmt, in);
diff --git a/src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
b/src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
index 768cbd5e6f..35f0b6dda5 100644
--- a/src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
+++ b/src/interfaces/ecpg/test/pgtypeslib/dt_test.pgc
@@ -81,7 +81,7 @@ main(void)
/* rdate_defmt_asc() */
- date1 = 0; text = "";
+ date1 = 0;
fmt = "yy/mm/dd";
in = "In the year 1995, the month of December, it is the 25th day";
/*