Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f38e413

Browse files
author
Neil Conway
committed
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.
1 parent 35e1651 commit f38e413

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

src/backend/access/hash/hashovfl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.45 2004/12/31 21:59:13 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.46 2005/05/11 01:26:01 neilc Exp $
1212
*
1313
* NOTES
1414
* Overflow pages look like ordinary relation pages.
@@ -509,7 +509,7 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno)
509509

510510
/* set all of the bits to 1 */
511511
freep = HashPageGetBitmap(pg);
512-
MemSet((char *) freep, 0xFF, BMPGSZ_BYTE(metap));
512+
MemSet(freep, 0xFF, BMPGSZ_BYTE(metap));
513513

514514
/* write out the new bitmap page (releasing write lock and pin) */
515515
_hash_wrtbuf(rel, buf);

src/backend/access/hash/hashpage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.48 2005/05/10 05:15:07 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.49 2005/05/11 01:26:01 neilc Exp $
1212
*
1313
* NOTES
1414
* Postgres hash pages look like ordinary relation pages. The opaque
@@ -295,8 +295,8 @@ _hash_metapinit(Relation rel)
295295
metap->hashm_maxbucket = metap->hashm_lowmask = 1; /* nbuckets - 1 */
296296
metap->hashm_highmask = 3; /* (nbuckets << 1) - 1 */
297297

298-
MemSet((char *) metap->hashm_spares, 0, sizeof(metap->hashm_spares));
299-
MemSet((char *) metap->hashm_mapp, 0, sizeof(metap->hashm_mapp));
298+
MemSet(metap->hashm_spares, 0, sizeof(metap->hashm_spares));
299+
MemSet(metap->hashm_mapp, 0, sizeof(metap->hashm_mapp));
300300

301301
metap->hashm_spares[1] = 1; /* the first bitmap page is only spare */
302302
metap->hashm_ovflpoint = 1;

src/backend/access/hash/hashutil.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.41 2004/12/31 21:59:13 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.42 2005/05/11 01:26:01 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -56,7 +56,7 @@ _hash_formitem(IndexTuple itup)
5656
(sizeof(HashItemData) - sizeof(IndexTupleData));
5757

5858
hitem = (HashItem) palloc(nbytes_hitem);
59-
memcpy((char *) &(hitem->hash_itup), (char *) itup, tuplen);
59+
memcpy(&(hitem->hash_itup), itup, tuplen);
6060

6161
return hitem;
6262
}

src/backend/storage/lmgr/lock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.150 2005/04/29 22:28:24 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.151 2005/05/11 01:26:02 neilc Exp $
1212
*
1313
* NOTES
1414
* Outside modules can create a lock table and acquire/release
@@ -551,8 +551,8 @@ LockAcquire(LOCKMETHODID lockmethodid, LOCKTAG *locktag,
551551
ProcQueueInit(&(lock->waitProcs));
552552
lock->nRequested = 0;
553553
lock->nGranted = 0;
554-
MemSet((char *) lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
555-
MemSet((char *) lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
554+
MemSet(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
555+
MemSet(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
556556
LOCK_PRINT("LockAcquire: new", lock, lockmode);
557557
}
558558
else

src/backend/utils/cache/relcache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.222 2005/05/06 17:24:54 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.223 2005/05/11 01:26:02 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -297,7 +297,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
297297
/*
298298
* clear all fields of reldesc
299299
*/
300-
MemSet((char *) relation, 0, sizeof(RelationData));
300+
MemSet(relation, 0, sizeof(RelationData));
301301
relation->rd_targblock = InvalidBlockNumber;
302302

303303
/* make sure relation is marked as having no open file yet */
@@ -315,7 +315,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
315315
*/
316316
relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
317317

318-
memcpy((char *) relationForm, (char *) relp, CLASS_TUPLE_SIZE);
318+
memcpy(relationForm, relp, CLASS_TUPLE_SIZE);
319319

320320
/* initialize relation tuple form */
321321
relation->rd_rel = relationForm;

src/backend/utils/cache/syscache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.98 2005/04/14 20:03:26 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.99 2005/05/11 01:26:02 neilc Exp $
1212
*
1313
* NOTES
1414
* These routines allow the parser/planner/executor to perform
@@ -455,7 +455,7 @@ InitCatalogCache(void)
455455

456456
Assert(!CacheInitialized);
457457

458-
MemSet((char *) SysCache, 0, sizeof(SysCache));
458+
MemSet(SysCache, 0, sizeof(SysCache));
459459

460460
for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
461461
{

src/backend/utils/fmgr/dfmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.79 2004/12/31 22:01:31 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.80 2005/05/11 01:26:02 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -126,7 +126,7 @@ load_external_function(char *filename, char *funcname,
126126
(errcode(ERRCODE_OUT_OF_MEMORY),
127127
errmsg("out of memory")));
128128

129-
MemSet((char *) file_scanner, 0, sizeof(DynamicFileList));
129+
MemSet(file_scanner, 0, sizeof(DynamicFileList));
130130
strcpy(file_scanner->filename, fullname);
131131
file_scanner->device = stat_buf.st_dev;
132132
#ifndef WIN32

src/include/c.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.182 2005/04/28 21:47:17 tgl Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.183 2005/05/11 01:26:02 neilc Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -630,7 +630,7 @@ typedef NameData *Name;
630630
#define MemSet(start, val, len) \
631631
do \
632632
{ \
633-
int32 * _start = (int32 *) (start); \
633+
int32 *_start = (int32 *) (start); \
634634
int _val = (val); \
635635
Size _len = (len); \
636636
\
@@ -639,12 +639,12 @@ typedef NameData *Name;
639639
_val == 0 && \
640640
_len <= MEMSET_LOOP_LIMIT) \
641641
{ \
642-
int32 * _stop = (int32 *) ((char *) _start + _len); \
642+
int32 *_stop = (int32 *) ((char *) _start + _len); \
643643
while (_start < _stop) \
644644
*_start++ = 0; \
645645
} \
646646
else \
647-
memset((char *) _start, _val, _len); \
647+
memset(_start, _val, _len); \
648648
} while (0)
649649

650650
#define MEMSET_LOOP_LIMIT 1024
@@ -658,20 +658,20 @@ typedef NameData *Name;
658658
#define MemSetAligned(start, val, len) \
659659
do \
660660
{ \
661-
int32 * _start = (int32 *) (start); \
661+
int32 *_start = (int32 *) (start); \
662662
int _val = (val); \
663663
Size _len = (len); \
664664
\
665665
if ((_len & INT_ALIGN_MASK) == 0 && \
666666
_val == 0 && \
667667
_len <= MEMSET_LOOP_LIMIT) \
668668
{ \
669-
int32 * _stop = (int32 *) ((char *) _start + _len); \
669+
int32 *_stop = (int32 *) ((char *) _start + _len); \
670670
while (_start < _stop) \
671671
*_start++ = 0; \
672672
} \
673673
else \
674-
memset((char *) _start, _val, _len); \
674+
memset(_start, _val, _len); \
675675
} while (0)
676676

677677

src/interfaces/libpq/fe-protocol2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.16 2004/12/31 22:03:50 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.17 2005/05/11 01:26:02 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -592,7 +592,7 @@ getRowDescriptions(PGconn *conn)
592592
{
593593
result->attDescs = (PGresAttDesc *)
594594
pqResultAlloc(result, nfields * sizeof(PGresAttDesc), TRUE);
595-
MemSet((char *) result->attDescs, 0, nfields * sizeof(PGresAttDesc));
595+
MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
596596
}
597597

598598
/* get type info */
@@ -667,7 +667,7 @@ getAnotherTuple(PGconn *conn, bool binary)
667667
pqResultAlloc(result, nfields * sizeof(PGresAttValue), TRUE);
668668
if (conn->curTuple == NULL)
669669
goto outOfMemory;
670-
MemSet((char *) conn->curTuple, 0, nfields * sizeof(PGresAttValue));
670+
MemSet(conn->curTuple, 0, nfields * sizeof(PGresAttValue));
671671

672672
/*
673673
* If it's binary, fix the column format indicators. We assume
@@ -1409,7 +1409,7 @@ pqBuildStartupPacket2(PGconn *conn, int *packetlen,
14091409
if (!startpacket)
14101410
return NULL;
14111411

1412-
MemSet((char *) startpacket, 0, sizeof(StartupPacket));
1412+
MemSet(startpacket, 0, sizeof(StartupPacket));
14131413

14141414
startpacket->protoVersion = htonl(conn->pversion);
14151415

0 commit comments

Comments
 (0)