mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Get rid of perror(), substitute some better phrased error messages.
malloc() doesn't set errno, so most uses were buggy anyway.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.90 2004/08/29 05:07:00 momjian Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.91 2004/11/09 15:57:55 petere Exp $ */
|
||||
|
||||
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
||||
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
||||
@@ -154,7 +154,8 @@ main(int argc, char *const argv[])
|
||||
yyout = fopen(optarg, PG_BINARY_W);
|
||||
|
||||
if (yyout == NULL)
|
||||
perror(optarg);
|
||||
fprintf(stderr, "%s: could not open file \"%s\": %s\n",
|
||||
progname, optarg, strerror(errno));
|
||||
else
|
||||
out_option = 1;
|
||||
break;
|
||||
@@ -304,7 +305,8 @@ main(int argc, char *const argv[])
|
||||
yyout = fopen(output_filename, PG_BINARY_W);
|
||||
if (yyout == NULL)
|
||||
{
|
||||
perror(output_filename);
|
||||
fprintf(stderr, "%s: could not open file \"%s\": %s\n",
|
||||
progname, output_filename, strerror(errno));
|
||||
free(output_filename);
|
||||
free(input_filename);
|
||||
continue;
|
||||
@@ -313,7 +315,8 @@ main(int argc, char *const argv[])
|
||||
}
|
||||
|
||||
if (yyin == NULL)
|
||||
perror(argv[fnr]);
|
||||
fprintf(stderr, "%s: could not open file \"%s\": %s\n",
|
||||
progname, argv[fnr], strerror(errno));
|
||||
else
|
||||
{
|
||||
struct cursor *ptr;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.94 2004/10/16 03:10:17 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.95 2004/11/09 15:57:57 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -527,7 +527,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
|
||||
if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) ||
|
||||
!(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1)))
|
||||
{
|
||||
perror("malloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if (!EncryptMD5(password, conn->pguser,
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* didn't really belong there.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.54 2004/08/29 05:07:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.55 2004/11/09 15:57:57 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -110,17 +110,17 @@ PQprint(FILE *fout,
|
||||
nTups = PQntuples(res);
|
||||
if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *))))
|
||||
{
|
||||
perror("calloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
if (!(fieldNotNum = (unsigned char *) calloc(nFields, 1)))
|
||||
{
|
||||
perror("calloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
if (!(fieldMax = (int *) calloc(nFields, sizeof(int))))
|
||||
{
|
||||
perror("calloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
for (numFieldName = 0;
|
||||
@@ -205,7 +205,7 @@ PQprint(FILE *fout,
|
||||
{
|
||||
if (!(fields = (char **) calloc(nFields * (nTups + 1), sizeof(char *))))
|
||||
{
|
||||
perror("calloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -392,7 +392,7 @@ do_field(const PQprintOpt *po, const PGresult *res,
|
||||
fieldMax[j] = plen;
|
||||
if (!(fields[i * nFields + j] = (char *) malloc(plen + 1)))
|
||||
{
|
||||
perror("malloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
strcpy(fields[i * nFields + j], pval);
|
||||
@@ -463,7 +463,7 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
|
||||
border = malloc(tot + 1);
|
||||
if (!border)
|
||||
{
|
||||
perror("malloc");
|
||||
fprintf(stderr, libpq_gettext("out of memory\n"));
|
||||
exit(1);
|
||||
}
|
||||
p = border;
|
||||
|
Reference in New Issue
Block a user