Commit f38e413b authored by Neil Conway's avatar Neil Conway

Code cleanup: in C89, there is no point casting the first argument to

memset() or MemSet() to a char *. For one, memset()'s first argument is
a void *, and further void * can be implicitly coerced to/from any other
pointer type.
parent 35e16515
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.45 2004/12/31 21:59:13 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.46 2005/05/11 01:26:01 neilc Exp $
* *
* NOTES * NOTES
* Overflow pages look like ordinary relation pages. * Overflow pages look like ordinary relation pages.
...@@ -509,7 +509,7 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno) ...@@ -509,7 +509,7 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno)
/* set all of the bits to 1 */ /* set all of the bits to 1 */
freep = HashPageGetBitmap(pg); freep = HashPageGetBitmap(pg);
MemSet((char *) freep, 0xFF, BMPGSZ_BYTE(metap)); MemSet(freep, 0xFF, BMPGSZ_BYTE(metap));
/* write out the new bitmap page (releasing write lock and pin) */ /* write out the new bitmap page (releasing write lock and pin) */
_hash_wrtbuf(rel, buf); _hash_wrtbuf(rel, buf);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.48 2005/05/10 05:15:07 neilc Exp $ * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.49 2005/05/11 01:26:01 neilc Exp $
* *
* NOTES * NOTES
* Postgres hash pages look like ordinary relation pages. The opaque * Postgres hash pages look like ordinary relation pages. The opaque
...@@ -295,8 +295,8 @@ _hash_metapinit(Relation rel) ...@@ -295,8 +295,8 @@ _hash_metapinit(Relation rel)
metap->hashm_maxbucket = metap->hashm_lowmask = 1; /* nbuckets - 1 */ metap->hashm_maxbucket = metap->hashm_lowmask = 1; /* nbuckets - 1 */
metap->hashm_highmask = 3; /* (nbuckets << 1) - 1 */ metap->hashm_highmask = 3; /* (nbuckets << 1) - 1 */
MemSet((char *) metap->hashm_spares, 0, sizeof(metap->hashm_spares)); MemSet(metap->hashm_spares, 0, sizeof(metap->hashm_spares));
MemSet((char *) metap->hashm_mapp, 0, sizeof(metap->hashm_mapp)); MemSet(metap->hashm_mapp, 0, sizeof(metap->hashm_mapp));
metap->hashm_spares[1] = 1; /* the first bitmap page is only spare */ metap->hashm_spares[1] = 1; /* the first bitmap page is only spare */
metap->hashm_ovflpoint = 1; metap->hashm_ovflpoint = 1;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.41 2004/12/31 21:59:13 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.42 2005/05/11 01:26:01 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -56,7 +56,7 @@ _hash_formitem(IndexTuple itup) ...@@ -56,7 +56,7 @@ _hash_formitem(IndexTuple itup)
(sizeof(HashItemData) - sizeof(IndexTupleData)); (sizeof(HashItemData) - sizeof(IndexTupleData));
hitem = (HashItem) palloc(nbytes_hitem); hitem = (HashItem) palloc(nbytes_hitem);
memcpy((char *) &(hitem->hash_itup), (char *) itup, tuplen); memcpy(&(hitem->hash_itup), itup, tuplen);
return hitem; return hitem;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.150 2005/04/29 22:28:24 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.151 2005/05/11 01:26:02 neilc Exp $
* *
* NOTES * NOTES
* Outside modules can create a lock table and acquire/release * Outside modules can create a lock table and acquire/release
...@@ -551,8 +551,8 @@ LockAcquire(LOCKMETHODID lockmethodid, LOCKTAG *locktag, ...@@ -551,8 +551,8 @@ LockAcquire(LOCKMETHODID lockmethodid, LOCKTAG *locktag,
ProcQueueInit(&(lock->waitProcs)); ProcQueueInit(&(lock->waitProcs));
lock->nRequested = 0; lock->nRequested = 0;
lock->nGranted = 0; lock->nGranted = 0;
MemSet((char *) lock->requested, 0, sizeof(int) * MAX_LOCKMODES); MemSet(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
MemSet((char *) lock->granted, 0, sizeof(int) * MAX_LOCKMODES); MemSet(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
LOCK_PRINT("LockAcquire: new", lock, lockmode); LOCK_PRINT("LockAcquire: new", lock, lockmode);
} }
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.222 2005/05/06 17:24:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.223 2005/05/11 01:26:02 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -297,7 +297,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp) ...@@ -297,7 +297,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
/* /*
* clear all fields of reldesc * clear all fields of reldesc
*/ */
MemSet((char *) relation, 0, sizeof(RelationData)); MemSet(relation, 0, sizeof(RelationData));
relation->rd_targblock = InvalidBlockNumber; relation->rd_targblock = InvalidBlockNumber;
/* make sure relation is marked as having no open file yet */ /* make sure relation is marked as having no open file yet */
...@@ -315,7 +315,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp) ...@@ -315,7 +315,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
*/ */
relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE); relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
memcpy((char *) relationForm, (char *) relp, CLASS_TUPLE_SIZE); memcpy(relationForm, relp, CLASS_TUPLE_SIZE);
/* initialize relation tuple form */ /* initialize relation tuple form */
relation->rd_rel = relationForm; relation->rd_rel = relationForm;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.98 2005/04/14 20:03:26 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.99 2005/05/11 01:26:02 neilc Exp $
* *
* NOTES * NOTES
* These routines allow the parser/planner/executor to perform * These routines allow the parser/planner/executor to perform
...@@ -455,7 +455,7 @@ InitCatalogCache(void) ...@@ -455,7 +455,7 @@ InitCatalogCache(void)
Assert(!CacheInitialized); Assert(!CacheInitialized);
MemSet((char *) SysCache, 0, sizeof(SysCache)); MemSet(SysCache, 0, sizeof(SysCache));
for (cacheId = 0; cacheId < SysCacheSize; cacheId++) for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.79 2004/12/31 22:01:31 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.80 2005/05/11 01:26:02 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -126,7 +126,7 @@ load_external_function(char *filename, char *funcname, ...@@ -126,7 +126,7 @@ load_external_function(char *filename, char *funcname,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
MemSet((char *) file_scanner, 0, sizeof(DynamicFileList)); MemSet(file_scanner, 0, sizeof(DynamicFileList));
strcpy(file_scanner->filename, fullname); strcpy(file_scanner->filename, fullname);
file_scanner->device = stat_buf.st_dev; file_scanner->device = stat_buf.st_dev;
#ifndef WIN32 #ifndef WIN32
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/c.h,v 1.182 2005/04/28 21:47:17 tgl Exp $ * $PostgreSQL: pgsql/src/include/c.h,v 1.183 2005/05/11 01:26:02 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -630,7 +630,7 @@ typedef NameData *Name; ...@@ -630,7 +630,7 @@ typedef NameData *Name;
#define MemSet(start, val, len) \ #define MemSet(start, val, len) \
do \ do \
{ \ { \
int32 * _start = (int32 *) (start); \ int32 *_start = (int32 *) (start); \
int _val = (val); \ int _val = (val); \
Size _len = (len); \ Size _len = (len); \
\ \
...@@ -639,12 +639,12 @@ typedef NameData *Name; ...@@ -639,12 +639,12 @@ typedef NameData *Name;
_val == 0 && \ _val == 0 && \
_len <= MEMSET_LOOP_LIMIT) \ _len <= MEMSET_LOOP_LIMIT) \
{ \ { \
int32 * _stop = (int32 *) ((char *) _start + _len); \ int32 *_stop = (int32 *) ((char *) _start + _len); \
while (_start < _stop) \ while (_start < _stop) \
*_start++ = 0; \ *_start++ = 0; \
} \ } \
else \ else \
memset((char *) _start, _val, _len); \ memset(_start, _val, _len); \
} while (0) } while (0)
#define MEMSET_LOOP_LIMIT 1024 #define MEMSET_LOOP_LIMIT 1024
...@@ -658,7 +658,7 @@ typedef NameData *Name; ...@@ -658,7 +658,7 @@ typedef NameData *Name;
#define MemSetAligned(start, val, len) \ #define MemSetAligned(start, val, len) \
do \ do \
{ \ { \
int32 * _start = (int32 *) (start); \ int32 *_start = (int32 *) (start); \
int _val = (val); \ int _val = (val); \
Size _len = (len); \ Size _len = (len); \
\ \
...@@ -666,12 +666,12 @@ typedef NameData *Name; ...@@ -666,12 +666,12 @@ typedef NameData *Name;
_val == 0 && \ _val == 0 && \
_len <= MEMSET_LOOP_LIMIT) \ _len <= MEMSET_LOOP_LIMIT) \
{ \ { \
int32 * _stop = (int32 *) ((char *) _start + _len); \ int32 *_stop = (int32 *) ((char *) _start + _len); \
while (_start < _stop) \ while (_start < _stop) \
*_start++ = 0; \ *_start++ = 0; \
} \ } \
else \ else \
memset((char *) _start, _val, _len); \ memset(_start, _val, _len); \
} while (0) } while (0)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.16 2004/12/31 22:03:50 pgsql Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.17 2005/05/11 01:26:02 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -592,7 +592,7 @@ getRowDescriptions(PGconn *conn) ...@@ -592,7 +592,7 @@ getRowDescriptions(PGconn *conn)
{ {
result->attDescs = (PGresAttDesc *) result->attDescs = (PGresAttDesc *)
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE); pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE);
MemSet((char *) result->attDescs, 0, nfields * sizeof(PGresAttDesc)); MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
} }
/* get type info */ /* get type info */
...@@ -667,7 +667,7 @@ getAnotherTuple(PGconn *conn, bool binary) ...@@ -667,7 +667,7 @@ getAnotherTuple(PGconn *conn, bool binary)
pqResultAlloc(result, nfields * sizeof(PGresAttValue), TRUE); pqResultAlloc(result, nfields * sizeof(PGresAttValue), TRUE);
if (conn->curTuple == NULL) if (conn->curTuple == NULL)
goto outOfMemory; goto outOfMemory;
MemSet((char *) conn->curTuple, 0, nfields * sizeof(PGresAttValue)); MemSet(conn->curTuple, 0, nfields * sizeof(PGresAttValue));
/* /*
* If it's binary, fix the column format indicators. We assume * If it's binary, fix the column format indicators. We assume
...@@ -1409,7 +1409,7 @@ pqBuildStartupPacket2(PGconn *conn, int *packetlen, ...@@ -1409,7 +1409,7 @@ pqBuildStartupPacket2(PGconn *conn, int *packetlen,
if (!startpacket) if (!startpacket)
return NULL; return NULL;
MemSet((char *) startpacket, 0, sizeof(StartupPacket)); MemSet(startpacket, 0, sizeof(StartupPacket));
startpacket->protoVersion = htonl(conn->pversion); startpacket->protoVersion = htonl(conn->pversion);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment