1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-23 03:21:12 +03:00

More janitorial work: remove the explicit casting of NULL literals to a

pointer type when it is not necessary to do so.

For future reference, casting NULL to a pointer type is only necessary
when (a) invoking a function AND either (b) the function has no prototype
OR (c) the function is a varargs function.
This commit is contained in:
Neil Conway
2004-01-07 18:56:30 +00:00
parent afca5d50dc
commit 192ad63bd7
71 changed files with 424 additions and 436 deletions

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.30 2003/12/03 08:49:17 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.31 2004/01/07 18:56:29 neilc Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
@ -190,7 +190,7 @@ free_variable(struct variable * var)
{
struct variable *var_next;
if (var == (struct variable *) NULL)
if (var == NULL)
return;
var_next = var->next;
ECPGfree(var);
@ -206,7 +206,7 @@ free_variable(struct variable * var)
static void
free_statement(struct statement * stmt)
{
if (stmt == (struct statement *) NULL)
if (stmt == NULL)
return;
free_variable(stmt->inlist);
free_variable(stmt->outlist);

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtcl.c,v 1.29 2003/11/29 19:52:11 pgsql Exp $
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtcl.c,v 1.30 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -53,109 +53,109 @@ Pgtcl_Init(Tcl_Interp *interp)
Tcl_CreateCommand(interp,
"pg_conndefaults",
Pg_conndefaults,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_connect",
Pg_connect,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_disconnect",
Pg_disconnect,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_exec",
Pg_exec,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_select",
Pg_select,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_result",
Pg_result,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_execute",
Pg_execute,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_open",
Pg_lo_open,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_close",
Pg_lo_close,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
#ifdef PGTCL_USE_TCLOBJ
Tcl_CreateObjCommand(interp,
"pg_lo_read",
Pg_lo_read,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateObjCommand(interp,
"pg_lo_write",
Pg_lo_write,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
#else
Tcl_CreateCommand(interp,
"pg_lo_read",
Pg_lo_read,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_write",
Pg_lo_write,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
#endif
Tcl_CreateCommand(interp,
"pg_lo_lseek",
Pg_lo_lseek,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_creat",
Pg_lo_creat,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_tell",
Pg_lo_tell,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_unlink",
Pg_lo_unlink,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_import",
Pg_lo_import,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_lo_export",
Pg_lo_export,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_listen",
Pg_listen,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_CreateCommand(interp,
"pg_on_connection_loss",
Pg_on_connection_loss,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
NULL, NULL);
Tcl_PkgProvide(interp, "Pgtcl", "1.4");

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclCmds.c,v 1.76 2003/11/29 19:52:11 pgsql Exp $
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclCmds.c,v 1.77 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -153,7 +153,7 @@ tcl_value(char *value)
char *p;
if (!value)
return (char *) NULL;
return NULL;
#ifdef TCL_ARRAYS_DEBUG
printf("pq_value = '%s'\n", value);
@ -417,8 +417,8 @@ Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv
}
/* Check that it is a PG connection and not something else */
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
return Tcl_UnregisterChannel(interp, conn_chan);
@ -450,7 +450,7 @@ Pg_exec(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
}
conn = PgGetConnectionId(interp, argv[1], &connid);
if (conn == (PGconn *) NULL)
if (conn == NULL)
return TCL_ERROR;
if (connid->res_copyStatus != RES_COPY_NONE)
@ -555,7 +555,7 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
}
result = PgGetResultId(interp, argv[1]);
if (result == (PGresult *) NULL)
if (result == NULL)
{
Tcl_AppendResult(interp, "\n",
argv[1], " is not a valid query result", 0);
@ -878,7 +878,7 @@ Pg_execute(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
* Get the connection and make sure no COPY command is pending
*/
conn = PgGetConnectionId(interp, argv[i++], &connid);
if (conn == (PGconn *) NULL)
if (conn == NULL)
return TCL_ERROR;
if (connid->res_copyStatus != RES_COPY_NONE)
@ -1085,8 +1085,8 @@ Pg_lo_open(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
lobjId = atoi(argv[2]);
@ -1153,8 +1153,8 @@ Pg_lo_close(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
fd = atoi(argv[2]);
@ -1195,8 +1195,8 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int objc,
}
conn = PgGetConnectionId(interp, Tcl_GetStringFromObj(objv[1], NULL),
(Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
NULL);
if (conn == NULL)
return TCL_ERROR;
if (Tcl_GetIntFromObj(interp, objv[2], &fd) != TCL_OK)
@ -1254,8 +1254,8 @@ Pg_lo_read(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
fd = atoi(argv[2]);
@ -1310,8 +1310,8 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int objc,
}
conn = PgGetConnectionId(interp, Tcl_GetStringFromObj(objv[1], NULL),
(Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
NULL);
if (conn == NULL)
return TCL_ERROR;
if (Tcl_GetIntFromObj(interp, objv[2], &fd) != TCL_OK)
@ -1357,8 +1357,8 @@ Pg_lo_write(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
fd = atoi(argv[2]);
@ -1405,8 +1405,8 @@ Pg_lo_lseek(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
fd = atoi(argv[2]);
@ -1457,8 +1457,8 @@ Pg_lo_creat(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
modeStr = strdup(argv[2]);
@ -1477,7 +1477,7 @@ Pg_lo_creat(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[]
return TCL_ERROR;
}
while ((modeWord = strtok((char *) NULL, "|")) != NULL)
while ((modeWord = strtok(NULL, "|")) != NULL)
{
if (strcmp(modeWord, "INV_READ") == 0)
mode |= INV_READ;
@ -1518,8 +1518,8 @@ Pg_lo_tell(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
fd = atoi(argv[2]);
@ -1552,8 +1552,8 @@ Pg_lo_unlink(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
lobjId = atoi(argv[2]);
@ -1594,8 +1594,8 @@ Pg_lo_import(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
filename = argv[2];
@ -1638,8 +1638,8 @@ Pg_lo_export(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[
return TCL_ERROR;
}
conn = PgGetConnectionId(interp, argv[1], (Pg_ConnectionId **) NULL);
if (conn == (PGconn *) NULL)
conn = PgGetConnectionId(interp, argv[1], NULL);
if (conn == NULL)
return TCL_ERROR;
lobjId = atoi(argv[2]);
@ -1702,7 +1702,7 @@ Pg_select(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
}
conn = PgGetConnectionId(interp, argv[1], &connid);
if (conn == (PGconn *) NULL)
if (conn == NULL)
return TCL_ERROR;
if ((result = PQexec(conn, argv[2])) == 0)
@ -1858,7 +1858,7 @@ Pg_listen(ClientData cData, Tcl_Interp *interp, int argc, CONST84 char *argv[])
* allocated by us.
*/
conn = PgGetConnectionId(interp, argv[1], &connid);
if (conn == (PGconn *) NULL)
if (conn == NULL)
return TCL_ERROR;
/*
@ -2032,7 +2032,7 @@ Pg_on_connection_loss(ClientData cData, Tcl_Interp *interp, int argc, CONST84 ch
* Get the command arguments.
*/
conn = PgGetConnectionId(interp, argv[1], &connid);
if (conn == (PGconn *) NULL)
if (conn == NULL)
return TCL_ERROR;
if ((argc > 2) && *argv[2])

View File

@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclId.c,v 1.44 2003/11/29 19:52:11 pgsql Exp $
* $PostgreSQL: pgsql/src/interfaces/libpgtcl/pgtclId.c,v 1.45 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -133,7 +133,7 @@ PgOutputProc(DRIVER_OUTPUT_PROTO)
Tcl_File
PgGetFileProc(ClientData cData, int direction)
{
return (Tcl_File) NULL;
return NULL;
}
#endif
@ -231,7 +231,7 @@ PgGetConnectionId(Tcl_Interp *interp, CONST84 char *id,
Tcl_AppendResult(interp, id, " is not a valid postgresql connection", 0);
if (connid_p)
*connid_p = NULL;
return (PGconn *) NULL;
return NULL;
}
connid = (Pg_ConnectionId *) Tcl_GetChannelInstanceData(conn_chan);

View File

@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.88 2003/12/20 18:45:49 tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.89 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -173,7 +173,7 @@ pg_krb4_authname(char *PQerrormsg)
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"pg_krb4_authname: krb_get_tf_fullname: %s\n",
krb_err_txt[status]);
return (char *) NULL;
return NULL;
}
return name;
}
@ -220,8 +220,8 @@ pg_krb4_sendauth(char *PQerrormsg, int sock,
hostname,
realm,
(u_long) 0,
(MSG_DAT *) NULL,
(CREDENTIALS *) NULL,
NULL,
NULL,
NULL,
laddr,
raddr,
@ -712,8 +712,8 @@ fe_getauthsvc(char *PQerrormsg)
char *
fe_getauthname(char *PQerrormsg)
{
const char *name = (char *) NULL;
char *authn = (char *) NULL;
const char *name = NULL;
char *authn = NULL;
MsgType authsvc;
authsvc = fe_getauthsvc(PQerrormsg);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.265 2003/12/19 21:50:54 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.266 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -279,7 +279,7 @@ PQconnectStart(const char *conninfo)
*/
conn = makeEmptyPGconn();
if (conn == NULL)
return (PGconn *) NULL;
return NULL;
/*
* Parse the conninfo string
@ -532,7 +532,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
*/
conn = makeEmptyPGconn();
if (conn == NULL)
return (PGconn *) NULL;
return NULL;
/*
* Parse an empty conninfo string in order to set up the same defaults
@ -1938,7 +1938,7 @@ makeEmptyPGconn(void)
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData))
return (PGconn *) NULL;
return NULL;
WSASetLastError(0);
#endif
@ -1947,7 +1947,7 @@ makeEmptyPGconn(void)
return conn;
/* Zero all pointers and booleans */
MemSet((char *) conn, 0, sizeof(PGconn));
MemSet(conn, 0, sizeof(PGconn));
conn->noticeHooks.noticeRec = defaultNoticeReceiver;
conn->noticeHooks.noticeProc = defaultNoticeProcessor;
@ -2765,7 +2765,7 @@ char *
PQdb(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->dbName;
}
@ -2773,7 +2773,7 @@ char *
PQuser(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pguser;
}
@ -2781,7 +2781,7 @@ char *
PQpass(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pgpass;
}
@ -2789,7 +2789,7 @@ char *
PQhost(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pghost ? conn->pghost : conn->pgunixsocket;
}
@ -2797,7 +2797,7 @@ char *
PQport(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pgport;
}
@ -2805,7 +2805,7 @@ char *
PQtty(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pgtty;
}
@ -2813,7 +2813,7 @@ char *
PQoptions(const PGconn *conn)
{
if (!conn)
return (char *) NULL;
return NULL;
return conn->pgoptions;
}
@ -2915,7 +2915,7 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
sprintf(qbuf, query, encoding);
res = PQexec(conn, qbuf);
if (res == (PGresult *) NULL)
if (res == NULL)
return -1;
if (res->resultStatus != PGRES_COMMAND_OK)
status = -1;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.45 2003/11/29 19:52:12 pgsql Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.46 2004/01/07 18:56:29 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -58,7 +58,7 @@ lo_open(PGconn *conn, Oid lobjId, int mode)
argv[1].len = 4;
argv[1].u.integer = mode;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -97,7 +97,7 @@ lo_close(PGconn *conn, int fd)
int retval;
int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -135,7 +135,7 @@ lo_read(PGconn *conn, int fd, char *buf, size_t len)
PGresult *res;
int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -177,7 +177,7 @@ lo_write(PGconn *conn, int fd, char *buf, size_t len)
int result_len;
int retval;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -223,7 +223,7 @@ lo_lseek(PGconn *conn, int fd, int offset, int whence)
int retval;
int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -272,7 +272,7 @@ lo_creat(PGconn *conn, int mode)
int retval;
int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return InvalidOid;
@ -310,7 +310,7 @@ lo_tell(PGconn *conn, int fd)
PGresult *res;
int result_len;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -348,7 +348,7 @@ lo_unlink(PGconn *conn, Oid lobjId)
int result_len;
int retval;
if (conn->lobjfuncs == (PGlobjfuncs *) NULL)
if (conn->lobjfuncs == NULL)
{
if (lo_initialize(conn) < 0)
return -1;
@ -534,7 +534,7 @@ lo_initialize(PGconn *conn)
* Allocate the structure to hold the functions OID's
*/
lobjfuncs = (PGlobjfuncs *) malloc(sizeof(PGlobjfuncs));
if (lobjfuncs == (PGlobjfuncs *) NULL)
if (lobjfuncs == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("out of memory\n"));
@ -554,7 +554,7 @@ lo_initialize(PGconn *conn)
or proname = 'lo_tell' \
or proname = 'loread' \
or proname = 'lowrite'");
if (res == (PGresult *) NULL)
if (res == NULL)
{
free(lobjfuncs);
return -1;