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:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.150 2003/12/20 22:18:02 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.151 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -372,7 +372,7 @@ BufferAlloc(Relation reln,
|
||||
* it to disk. Remember to unlock BufMgrLock while doing the IOs.
|
||||
*/
|
||||
inProgress = FALSE;
|
||||
for (buf = (BufferDesc *) NULL; buf == (BufferDesc *) NULL;)
|
||||
for (buf = NULL; buf == NULL;)
|
||||
{
|
||||
buf = StrategyGetBuffer();
|
||||
|
||||
@@ -399,7 +399,7 @@ BufferAlloc(Relation reln,
|
||||
if ((buf->flags & BM_IO_ERROR) != 0)
|
||||
{
|
||||
UnpinBuffer(buf);
|
||||
buf = (BufferDesc *) NULL;
|
||||
buf = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ BufferAlloc(Relation reln,
|
||||
buf->flags &= ~BM_IO_IN_PROGRESS;
|
||||
TerminateBufferIO(buf);
|
||||
UnpinBuffer(buf);
|
||||
buf = (BufferDesc *) NULL;
|
||||
buf = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -476,7 +476,7 @@ BufferAlloc(Relation reln,
|
||||
buf->flags &= ~BM_IO_IN_PROGRESS;
|
||||
TerminateBufferIO(buf);
|
||||
UnpinBuffer(buf);
|
||||
buf = (BufferDesc *) NULL;
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -799,7 +799,7 @@ BufferSync(int percent, int maxpages)
|
||||
bufHdr->flags &= ~BM_JUST_DIRTIED;
|
||||
LWLockRelease(BufMgrLock);
|
||||
|
||||
if (reln == (Relation) NULL)
|
||||
if (reln == NULL)
|
||||
{
|
||||
status = smgrblindwrt(DEFAULT_SMGR,
|
||||
bufHdr->tag.rnode,
|
||||
@@ -849,7 +849,7 @@ BufferSync(int percent, int maxpages)
|
||||
LWLockRelease(BufMgrLock);
|
||||
|
||||
/* drop refcnt obtained by RelationNodeCacheGetRelation */
|
||||
if (reln != (Relation) NULL)
|
||||
if (reln != NULL)
|
||||
RelationDecrementReferenceCount(reln);
|
||||
}
|
||||
|
||||
@@ -1105,7 +1105,7 @@ BufferReplace(BufferDesc *bufHdr)
|
||||
|
||||
reln = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
|
||||
|
||||
if (reln != (Relation) NULL)
|
||||
if (reln != NULL)
|
||||
{
|
||||
status = smgrwrite(DEFAULT_SMGR, reln,
|
||||
bufHdr->tag.blockNum,
|
||||
@@ -1119,7 +1119,7 @@ BufferReplace(BufferDesc *bufHdr)
|
||||
}
|
||||
|
||||
/* drop relcache refcnt incremented by RelationNodeCacheGetRelation */
|
||||
if (reln != (Relation) NULL)
|
||||
if (reln != NULL)
|
||||
RelationDecrementReferenceCount(reln);
|
||||
|
||||
/* Pop the error context stack */
|
||||
@@ -1949,7 +1949,7 @@ LockBufferForCleanup(Buffer buffer)
|
||||
* Note : We assume that nested buffer IO never occur.
|
||||
* i.e at most one io_in_progress lock is held per proc.
|
||||
*/
|
||||
static BufferDesc *InProgressBuf = (BufferDesc *) NULL;
|
||||
static BufferDesc *InProgressBuf = NULL;
|
||||
static bool IsForInput;
|
||||
|
||||
/*
|
||||
@@ -1991,7 +1991,7 @@ TerminateBufferIO(BufferDesc *buf)
|
||||
{
|
||||
Assert(buf == InProgressBuf);
|
||||
LWLockRelease(buf->io_in_progress_lock);
|
||||
InProgressBuf = (BufferDesc *) NULL;
|
||||
InProgressBuf = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2016,7 +2016,7 @@ ContinueBufferIO(BufferDesc *buf, bool forInput)
|
||||
void
|
||||
InitBufferIO(void)
|
||||
{
|
||||
InProgressBuf = (BufferDesc *) NULL;
|
||||
InProgressBuf = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.50 2003/11/29 19:51:56 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.51 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ BufferDesc *
|
||||
LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
|
||||
{
|
||||
int i;
|
||||
BufferDesc *bufHdr = (BufferDesc *) NULL;
|
||||
BufferDesc *bufHdr = NULL;
|
||||
|
||||
/* a low tech search for now -- not optimized for scans */
|
||||
for (i = 0; i < NLocBuffer; i++)
|
||||
@@ -93,7 +93,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
|
||||
Relation bufrel = RelationNodeCacheGetRelation(bufHdr->tag.rnode);
|
||||
|
||||
/* flush this page */
|
||||
if (bufrel == (Relation) NULL)
|
||||
if (bufrel == NULL)
|
||||
{
|
||||
smgrblindwrt(DEFAULT_SMGR,
|
||||
bufHdr->tag.rnode,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.143 2003/12/25 03:52:51 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.144 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -745,7 +745,7 @@ ProcWakeup(PGPROC *proc, int errType)
|
||||
/* Proc should be sleeping ... */
|
||||
if (proc->links.prev == INVALID_OFFSET ||
|
||||
proc->links.next == INVALID_OFFSET)
|
||||
return (PGPROC *) NULL;
|
||||
return NULL;
|
||||
|
||||
/* Save next process before we zap the list link */
|
||||
retProc = (PGPROC *) MAKE_PTR(proc->links.next);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.100 2004/01/06 18:07:31 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.101 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -60,7 +60,7 @@ typedef struct _MdfdVec
|
||||
} MdfdVec;
|
||||
|
||||
static int Nfds = 100; /* initial/current size of Md_fdvec array */
|
||||
static MdfdVec *Md_fdvec = (MdfdVec *) NULL;
|
||||
static MdfdVec *Md_fdvec = NULL;
|
||||
static int Md_Free = -1; /* head of freelist of unused fdvec
|
||||
* entries */
|
||||
static int CurFd = 0; /* first never-used fdvec index */
|
||||
@@ -158,7 +158,7 @@ mdcreate(Relation reln)
|
||||
Md_fdvec[vfd].mdfd_vfd = fd;
|
||||
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
||||
Md_fdvec[vfd].mdfd_chain = NULL;
|
||||
#endif
|
||||
|
||||
return vfd;
|
||||
@@ -322,7 +322,7 @@ mdopen(Relation reln)
|
||||
Md_fdvec[vfd].mdfd_vfd = fd;
|
||||
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
||||
Md_fdvec[vfd].mdfd_chain = NULL;
|
||||
Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
|
||||
#endif
|
||||
|
||||
@@ -359,7 +359,7 @@ mdclose_fd(int fd)
|
||||
MdfdVec *v;
|
||||
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
for (v = &Md_fdvec[fd]; v != (MdfdVec *) NULL;)
|
||||
for (v = &Md_fdvec[fd]; v != NULL;)
|
||||
{
|
||||
MdfdVec *ov = v;
|
||||
|
||||
@@ -372,10 +372,10 @@ mdclose_fd(int fd)
|
||||
pfree(ov);
|
||||
}
|
||||
|
||||
Md_fdvec[fd].mdfd_chain = (MdfdVec *) NULL;
|
||||
Md_fdvec[fd].mdfd_chain = NULL;
|
||||
#else
|
||||
v = &Md_fdvec[fd];
|
||||
if (v != (MdfdVec *) NULL)
|
||||
if (v != NULL)
|
||||
{
|
||||
if (v->mdfd_vfd >= 0)
|
||||
FileClose(v->mdfd_vfd);
|
||||
@@ -553,7 +553,7 @@ mdnblocks(Relation reln)
|
||||
* levels to handle that scenario by closing and re-opening the md
|
||||
* fd.)
|
||||
*/
|
||||
while (v->mdfd_chain != (MdfdVec *) NULL)
|
||||
while (v->mdfd_chain != NULL)
|
||||
{
|
||||
segno++;
|
||||
v = v->mdfd_chain;
|
||||
@@ -572,7 +572,7 @@ mdnblocks(Relation reln)
|
||||
*/
|
||||
segno++;
|
||||
|
||||
if (v->mdfd_chain == (MdfdVec *) NULL)
|
||||
if (v->mdfd_chain == NULL)
|
||||
{
|
||||
/*
|
||||
* Because we pass O_CREAT, we will create the next segment
|
||||
@@ -582,7 +582,7 @@ mdnblocks(Relation reln)
|
||||
* worth.
|
||||
*/
|
||||
v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT);
|
||||
if (v->mdfd_chain == (MdfdVec *) NULL)
|
||||
if (v->mdfd_chain == NULL)
|
||||
elog(ERROR, "could not count blocks of \"%s\": %m",
|
||||
RelationGetRelationName(reln));
|
||||
}
|
||||
@@ -625,7 +625,7 @@ mdtruncate(Relation reln, BlockNumber nblocks)
|
||||
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
priorblocks = 0;
|
||||
while (v != (MdfdVec *) NULL)
|
||||
while (v != NULL)
|
||||
{
|
||||
MdfdVec *ov = v;
|
||||
|
||||
@@ -660,7 +660,7 @@ mdtruncate(Relation reln, BlockNumber nblocks)
|
||||
if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
|
||||
return InvalidBlockNumber;
|
||||
v = v->mdfd_chain;
|
||||
ov->mdfd_chain = (MdfdVec *) NULL;
|
||||
ov->mdfd_chain = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -815,7 +815,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
|
||||
pfree(fullpath);
|
||||
|
||||
if (fd < 0)
|
||||
return (MdfdVec *) NULL;
|
||||
return NULL;
|
||||
|
||||
/* allocate an mdfdvec entry for it */
|
||||
v = (MdfdVec *) MemoryContextAlloc(MdCxt, sizeof(MdfdVec));
|
||||
@@ -824,7 +824,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
|
||||
v->mdfd_vfd = fd;
|
||||
v->mdfd_flags = (uint16) 0;
|
||||
#ifndef LET_OS_MANAGE_FILESIZE
|
||||
v->mdfd_chain = (MdfdVec *) NULL;
|
||||
v->mdfd_chain = NULL;
|
||||
Assert(_mdnblocks(fd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));
|
||||
#endif
|
||||
|
||||
@@ -877,7 +877,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
|
||||
i++, segno--)
|
||||
{
|
||||
|
||||
if (v->mdfd_chain == (MdfdVec *) NULL)
|
||||
if (v->mdfd_chain == NULL)
|
||||
{
|
||||
/*
|
||||
* We will create the next segment only if the target block is
|
||||
@@ -891,7 +891,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
|
||||
*/
|
||||
v->mdfd_chain = _mdfd_openseg(reln, i, (segno == 1) ? O_CREAT : 0);
|
||||
|
||||
if (v->mdfd_chain == (MdfdVec *) NULL)
|
||||
if (v->mdfd_chain == NULL)
|
||||
elog(ERROR, "could not open segment %u of relation \"%s\" (target block %u): %m",
|
||||
i, RelationGetRelationName(reln), blkno);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/mm.c,v 1.35 2003/11/29 19:51:57 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/mm.c,v 1.36 2004/01/07 18:56:27 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -96,7 +96,7 @@ mminit(void)
|
||||
mmsize += MAXALIGN((MMNBUFFERS * sizeof(MMCacheTag)));
|
||||
mmcacheblk = (char *) ShmemInitStruct("Main memory smgr", mmsize, &found);
|
||||
|
||||
if (mmcacheblk == (char *) NULL)
|
||||
if (mmcacheblk == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
return SM_FAIL;
|
||||
@@ -110,7 +110,7 @@ mminit(void)
|
||||
MMNBUFFERS, MMNBUFFERS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
|
||||
if (MMCacheHT == (HTAB *) NULL)
|
||||
if (MMCacheHT == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
return SM_FAIL;
|
||||
@@ -124,7 +124,7 @@ mminit(void)
|
||||
MMNRELATIONS, MMNRELATIONS,
|
||||
&info, (HASH_ELEM | HASH_FUNCTION));
|
||||
|
||||
if (MMRelCacheHT == (HTAB *) NULL)
|
||||
if (MMRelCacheHT == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
return SM_FAIL;
|
||||
@@ -183,7 +183,7 @@ mmcreate(Relation reln)
|
||||
(void *) &tag,
|
||||
HASH_ENTER, &found);
|
||||
|
||||
if (entry == (MMRelHashEntry *) NULL)
|
||||
if (entry == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
ereport(FATAL,
|
||||
@@ -228,7 +228,7 @@ mmunlink(RelFileNode rnode)
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(void *) &MMBlockTags[i],
|
||||
HASH_REMOVE, NULL);
|
||||
if (entry == (MMHashEntry *) NULL)
|
||||
if (entry == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
elog(FATAL, "cache hash table corrupted");
|
||||
@@ -245,7 +245,7 @@ mmunlink(RelFileNode rnode)
|
||||
(void *) &rtag,
|
||||
HASH_REMOVE, NULL);
|
||||
|
||||
if (rentry == (MMRelHashEntry *) NULL)
|
||||
if (rentry == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
elog(FATAL, "rel cache hash table corrupted");
|
||||
@@ -308,7 +308,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT,
|
||||
(void *) &rtag,
|
||||
HASH_FIND, NULL);
|
||||
if (rentry == (MMRelHashEntry *) NULL)
|
||||
if (rentry == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
elog(FATAL, "rel cache hash table corrupted");
|
||||
@@ -319,7 +319,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
entry = (MMHashEntry *) hash_search(MMCacheHT,
|
||||
(void *) &tag,
|
||||
HASH_ENTER, &found);
|
||||
if (entry == (MMHashEntry *) NULL || found)
|
||||
if (entry == NULL || found)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
elog(FATAL, "cache hash table corrupted");
|
||||
@@ -389,7 +389,7 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
(void *) &tag,
|
||||
HASH_FIND, NULL);
|
||||
|
||||
if (entry == (MMHashEntry *) NULL)
|
||||
if (entry == NULL)
|
||||
{
|
||||
/* reading nonexistent pages is defined to fill them with zeroes */
|
||||
LWLockRelease(MMCacheLock);
|
||||
@@ -430,7 +430,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||
(void *) &tag,
|
||||
HASH_FIND, NULL);
|
||||
|
||||
if (entry == (MMHashEntry *) NULL)
|
||||
if (entry == NULL)
|
||||
{
|
||||
LWLockRelease(MMCacheLock);
|
||||
elog(FATAL, "cache hash table missing requested page");
|
||||
|
||||
Reference in New Issue
Block a user