1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +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

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.30 2003/11/29 19:51:40 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.31 2004/01/07 18:56:24 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,7 +74,7 @@ rtfirst(IndexScanDesc s, ScanDirection dir)
while (n < FirstOffsetNumber || n > maxoff)
{
ReleaseBuffer(b);
if (so->s_stack == (RTSTACK *) NULL)
if (so->s_stack == NULL)
return false;
stk = so->s_stack;
@@ -156,7 +156,7 @@ rtnext(IndexScanDesc s, ScanDirection dir)
while (n < FirstOffsetNumber || n > maxoff)
{
ReleaseBuffer(b);
if (so->s_stack == (RTSTACK *) NULL)
if (so->s_stack == NULL)
return false;
stk = so->s_stack;

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.39 2003/11/29 19:51:40 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.40 2004/01/07 18:56:24 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,7 +74,7 @@ rt_box_size(PG_FUNCTION_ARGS)
/* NB: size is an output argument */
float *size = (float *) PG_GETARG_POINTER(1);
if (a == (BOX *) NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
if (a == NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
*size = 0.0;
else
*size = (float) ((a->high.x - a->low.x) * (a->high.y - a->low.y));

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.81 2003/11/29 19:51:40 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.82 2004/01/07 18:56:24 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -244,7 +244,7 @@ rtinsert(PG_FUNCTION_ARGS)
if (IndexTupleHasNulls(itup))
{
pfree(itup);
PG_RETURN_POINTER((InsertIndexResult) NULL);
PG_RETURN_POINTER(NULL);
}
initRtstate(&rtState, r);
@@ -275,7 +275,7 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE *rtstate)
blk = P_ROOT;
buffer = InvalidBuffer;
stack = (RTSTACK *) NULL;
stack = NULL;
do
{
@@ -360,7 +360,7 @@ rttighten(Relation r,
newd_size;
Buffer b;
if (stk == (RTSTACK *) NULL)
if (stk == NULL)
return;
b = ReadBuffer(r, stk->rts_blk);
@@ -622,7 +622,7 @@ rtintinsert(Relation r,
newdatum;
InsertIndexResult res;
if (stk == (RTSTACK *) NULL)
if (stk == NULL)
{
rtnewroot(r, ltup, rtup);
return;
@@ -912,7 +912,7 @@ rtpicksplit(Relation r,
*/
/* to keep compiler quiet */
cost_vector = (SPLITCOST *) NULL;
cost_vector = NULL;
if (num_tuples_without_seeds > 0)
{
@@ -1172,7 +1172,7 @@ freestack(RTSTACK *s)
{
RTSTACK *p;
while (s != (RTSTACK *) NULL)
while (s != NULL)
{
p = s->rts_parent;
pfree(s);
@@ -1213,7 +1213,7 @@ rtbulkdelete(PG_FUNCTION_ARGS)
*/
/* walk through the entire index */
iscan = index_beginscan(NULL, rel, SnapshotAny, 0, (ScanKey) NULL);
iscan = index_beginscan(NULL, rel, SnapshotAny, 0, NULL);
/* including killed tuples */
iscan->ignore_killed_tuples = false;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.50 2003/11/29 19:51:40 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.51 2004/01/07 18:56:24 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,7 @@ typedef struct RTScanListData
typedef RTScanListData *RTScanList;
/* pointer to list of local scans on rtrees */
static RTScanList RTScans = (RTScanList) NULL;
static RTScanList RTScans = NULL;
Datum
rtbeginscan(PG_FUNCTION_ARGS)
@@ -80,19 +80,19 @@ rtrescan(PG_FUNCTION_ARGS)
ItemPointerSetInvalid(&s->currentMarkData);
p = (RTreeScanOpaque) s->opaque;
if (p != (RTreeScanOpaque) NULL)
if (p != NULL)
{
/* rescan an existing indexscan --- reset state */
freestack(p->s_stack);
freestack(p->s_markstk);
p->s_stack = p->s_markstk = (RTSTACK *) NULL;
p->s_stack = p->s_markstk = NULL;
p->s_flags = 0x0;
}
else
{
/* initialize opaque data */
p = (RTreeScanOpaque) palloc(sizeof(RTreeScanOpaqueData));
p->s_stack = p->s_markstk = (RTSTACK *) NULL;
p->s_stack = p->s_markstk = NULL;
p->s_internalNKey = s->numberOfKeys;
p->s_flags = 0x0;
s->opaque = p;
@@ -156,11 +156,11 @@ rtmarkpos(PG_FUNCTION_ARGS)
else
p->s_flags &= ~RTS_MRKBEFORE;
o = (RTSTACK *) NULL;
o = NULL;
n = p->s_stack;
/* copy the parent stack from the current item data */
while (n != (RTSTACK *) NULL)
while (n != NULL)
{
tmp = (RTSTACK *) palloc(sizeof(RTSTACK));
tmp->rts_child = n->rts_child;
@@ -192,11 +192,11 @@ rtrestrpos(PG_FUNCTION_ARGS)
else
p->s_flags &= ~RTS_CURBEFORE;
o = (RTSTACK *) NULL;
o = NULL;
n = p->s_markstk;
/* copy the parent stack from the current item data */
while (n != (RTSTACK *) NULL)
while (n != NULL)
{
tmp = (RTSTACK *) palloc(sizeof(RTSTACK));
tmp->rts_child = n->rts_child;
@@ -220,7 +220,7 @@ rtendscan(PG_FUNCTION_ARGS)
p = (RTreeScanOpaque) s->opaque;
if (p != (RTreeScanOpaque) NULL)
if (p != NULL)
{
freestack(p->s_stack);
freestack(p->s_markstk);
@@ -250,18 +250,18 @@ rtdropscan(IndexScanDesc s)
RTScanList l;
RTScanList prev;
prev = (RTScanList) NULL;
prev = NULL;
for (l = RTScans;
l != (RTScanList) NULL && l->rtsl_scan != s;
l != NULL && l->rtsl_scan != s;
l = l->rtsl_next)
prev = l;
if (l == (RTScanList) NULL)
if (l == NULL)
elog(ERROR, "rtree scan list corrupted -- could not find 0x%p",
(void *) s);
if (prev == (RTScanList) NULL)
if (prev == NULL)
RTScans = l->rtsl_next;
else
prev->rtsl_next = l->rtsl_next;
@@ -297,7 +297,7 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
Oid relid;
relid = RelationGetRelid(r);
for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
for (l = RTScans; l != NULL; l = l->rtsl_next)
{
if (RelationGetRelid(l->rtsl_scan->indexRelation) == relid)
rtadjone(l->rtsl_scan, op, blkno, offnum);
@@ -414,12 +414,10 @@ adjustiptr(IndexScanDesc s,
* are looking at already in this transaction, we ignore the update
* request.
*/
/*ARGSUSED*/
static void
adjuststack(RTSTACK *stk,
BlockNumber blkno)
adjuststack(RTSTACK *stk, BlockNumber blkno)
{
while (stk != (RTSTACK *) NULL)
while (stk != NULL)
{
if (stk->rts_blk == blkno)
stk->rts_child = FirstOffsetNumber;