From d7b00d5f19e7dfd7d8ee3d600d0184e4364fa7be Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Fri, 28 Aug 2009 17:03:44 -0400 Subject: [PATCH] Use intptr_t and uintptr_t for integer/pointer conversions Use intptr_t and uintptr_t casts to appease the compiler when values are converted between 32-bit integers and pointers. This generates many warnings (currently ~170 on linux amd64) when pointers are 64-bit. These types are normally defined in stdint.h, and get defined by autoconf if that's not the case. In a few places, NULL is simply replaced with 0 where compared with an integer. Reviewed-on: http://gerrit.openafs.org/474 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- acinclude.m4 | 2 ++ src/afs/UKERNEL/afs_usrops.c | 2 +- src/afs/UKERNEL/osi_vfsops.c | 4 ++-- src/afs/afs_lock.c | 6 +++--- src/afsd/vsys.c | 2 +- src/afsmonitor/afsmonitor.c | 2 +- src/bozo/bnode.c | 4 ++-- src/bozo/bosoprocs.c | 2 +- src/bucoord/dump.c | 6 +++--- src/budb/dbs_dump.c | 6 +++--- src/butc/dump.c | 2 +- src/butc/lwps.c | 4 ++-- src/butc/recoverDb.c | 2 +- src/butc/tcprocs.c | 4 ++-- src/butc/tcudbprocs.c | 6 +++--- src/butm/file_tm.c | 4 ++-- src/dir/salvage.c | 12 ++++++------ src/gtx/frame.c | 5 +++-- src/gtx/gtxtest.c | 5 +++-- src/lwp/lwp.c | 5 +++-- src/ptserver/ptprocs.c | 4 ++-- src/ptserver/ptutils.c | 12 ++++++------ src/rx/rx.c | 2 +- src/rx/rx_pthread.c | 8 ++++---- src/rxkad/rxkad_server.c | 2 +- src/scout/scout.c | 2 +- src/ubik/ubikclient.c | 4 ++-- src/usd/usd_file.c | 12 ++++++------ src/util/serverLog.c | 10 +++++----- src/viced/viced.c | 4 ++-- src/vlserver/vlserver.c | 4 ++-- src/vol/fssync-debug.c | 2 +- src/vol/fssync-server.c | 2 +- src/vol/vnode.c | 24 ++++++++++++------------ src/volser/volmain.c | 2 +- src/volser/vos.c | 8 ++++---- 36 files changed, 96 insertions(+), 91 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 345317afa..0b797814e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1600,6 +1600,8 @@ fi AC_TYPE_SOCKLEN_T AC_TYPE_SIGNAL +AC_TYPE_INTPTR_T +AC_TYPE_UINTPTR_T AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPES(sig_t, , , [#include diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 9ee502117..2fa541263 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -4178,7 +4178,7 @@ uafs_getcellstatus(char *cell, afs_int32 * status) return -1; } - *status = (afs_int32) iob.out; + *status = (intptr_t)iob.out; return 0; } diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index 16d7d507f..abaa42aef 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -47,7 +47,7 @@ afs_mount(struct vfs *afsp, char *path, void *data) afs_globalVFS = afsp; afsp->vfs_bsize = 8192; afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid.val[1] = (afs_int32) AFS_VFSFSID; + afsp->vfs_fsid.val[1] = (intptr_t)AFS_VFSFSID; return 0; } @@ -115,7 +115,7 @@ afs_statfs(register struct vfs *afsp, struct statfs *abp) abp->f_type = 0; abp->f_bsize = afsp->vfs_bsize; abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID; + abp->f_fsid.val[1] = (intptr_t)AFS_VFSFSID; return 0; } diff --git a/src/afs/afs_lock.c b/src/afs/afs_lock.c index a29357f75..65d738ef3 100644 --- a/src/afs/afs_lock.c +++ b/src/afs/afs_lock.c @@ -279,7 +279,7 @@ afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc) /* To shut up SGI compiler on remark(1413) warnings. */ alock->proc = (char *)(long)MyPidxx; #else /* AFS_64BITPOINTER_ENV */ - alock->proc = (char *)MyPidxx; + alock->proc = (char *)(intptr_t)MyPidxx; #endif /* AFS_64BITPOINTER_ENV */ #endif alock->count = 1; @@ -291,7 +291,7 @@ afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc) /* To shut up SGI compiler on remark(1413) warnings. */ } else if (alock->proc == (char *)(long)MyPidxx) { #else /* AFS_64BITPOINTER_ENV */ - } else if (alock->proc == (char *)MyPidxx) { + } else if (alock->proc == (char *)(intptr_t)MyPidxx) { #endif /* AFS_64BITPOINTER_ENV */ #endif /* lock is held, but by us, so we win anyway */ @@ -350,7 +350,7 @@ afs_CheckBozonLockBlocking(struct afs_bozoLock *alock) /* To shut up SGI compiler on remark(1413) warnings. */ if (alock->proc != (char *)(long)MyPidxx) #else /* AFS_64BITPOINTER_ENV */ - if (alock->proc != (char *)MyPidxx) + if (alock->proc != (char *)(intptr_t)MyPidxx) #endif /* AFS_64BITPOINTER_ENV */ #endif return 1; diff --git a/src/afsd/vsys.c b/src/afsd/vsys.c index b618396b8..0dd4a895c 100644 --- a/src/afsd/vsys.c +++ b/src/afsd/vsys.c @@ -48,7 +48,7 @@ main(int argc, char **argv) parms[counter++] = atoi(argv[i]); numberFlag = 1; } else { - parms[counter++] = (afs_int32) argv[i]; + parms[counter++] = (intptr_t)argv[i]; numberFlag = 1; } } diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 7c1e1e5de..cda39a7f5 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -3768,7 +3768,7 @@ afsmon_execute(void) } /* start the gtx input server */ - code = (int) gtx_InputServer(afsmon_win); + code = (intptr_t)gtx_InputServer(afsmon_win); if (code) { fprintf(stderr, "[ %s ] Failed to start input server \n", rn); afsmon_Exit(140); diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index ddcc8662a..f770e1d6c 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -819,9 +819,9 @@ void bnode_Int(int asignal) { if (asignal == SIGQUIT) { - IOMGR_SoftSig(bozo_ShutdownAndExit, (void *) asignal); + IOMGR_SoftSig(bozo_ShutdownAndExit, (void *)(intptr_t)asignal); } else { - IOMGR_SoftSig(bnode_SoftInt, (void *) asignal); + IOMGR_SoftSig(bnode_SoftInt, (void *)(intptr_t)asignal); } } diff --git a/src/bozo/bosoprocs.c b/src/bozo/bosoprocs.c index 47b2e64ab..2ff668e50 100644 --- a/src/bozo/bosoprocs.c +++ b/src/bozo/bosoprocs.c @@ -1562,7 +1562,7 @@ SBOZO_SetRestrictedMode(struct rx_call *acall, afs_int32 arestmode) void * bozo_ShutdownAndExit(void *param) { - int asignal = (int) param; + int asignal = (intptr_t)param; int code; bozo_Log diff --git a/src/bucoord/dump.c b/src/bucoord/dump.c index 4a373f154..855a63e18 100644 --- a/src/bucoord/dump.c +++ b/src/bucoord/dump.c @@ -197,7 +197,7 @@ freeDumpTaskVolumeList(struct bc_volumeDump *vdptr) void * bc_DmpRstStart(void *param) { - afs_int32 aindex = (afs_int32) param; + afs_int32 aindex = (intptr_t)param; register struct bc_dumpTask *tdump; register afs_int32 code; @@ -220,7 +220,7 @@ bc_DmpRstStart(void *param) free(tdump->portOffset); tdump->flags &= ~BC_DI_INUSE; - return (void *)code; + return (void *)(intptr_t)code; } /* bc_StartDmpRst @@ -289,7 +289,7 @@ bc_StartDmpRst(struct bc_config *aconfig, char *adname, char *avname, code = LWP_CreateProcess(bc_DmpRstStart, 20480, LWP_NORMAL_PRIORITY, - (void *)i, "helper", junk); + (void *)(intptr_t)i, "helper", junk); if (code) { bc_HandleMisc(code); afs_com_err(whoami, code, "; Can't start thread"); diff --git a/src/budb/dbs_dump.c b/src/budb/dbs_dump.c index fb1634680..5ac93a872 100644 --- a/src/budb/dbs_dump.c +++ b/src/budb/dbs_dump.c @@ -67,7 +67,7 @@ badEntry(afs_uint32 dbAddr) void * setupDbDump(void *param) { - int writeFid = (int)param; + int writeFid = (intptr_t)param; afs_int32 code = 0; code = InitRPC(&dumpSyncPtr->ut, LOCKREAD, 1); @@ -87,7 +87,7 @@ setupDbDump(void *param) error_exit: if (dumpSyncPtr->ut) ubik_EndTrans(dumpSyncPtr->ut); - return (void *)(code); + return (void *)(intptr_t)(code); } @@ -173,7 +173,7 @@ DumpDB(struct rx_call *call, #else code = LWP_CreateProcess(setupDbDump, 16384, 1, - (void *)dumpSyncPtr->pipeFid[1], + (void *)(intptr_t)dumpSyncPtr->pipeFid[1], "Database Dumper", &dumperPid); if (code) goto error_exit; diff --git a/src/butc/dump.c b/src/butc/dump.c index bee3de63a..60975bce6 100644 --- a/src/butc/dump.c +++ b/src/butc/dump.c @@ -1381,7 +1381,7 @@ Dumper(void *param) FreeNode(taskId); /* free the dump node */ LeaveDeviceQueue(deviceLatch); - return (void *)(code); + return (void *)(intptr_t)(code); } #define BELLTIME 60 /* 60 seconds before a bell rings */ diff --git a/src/butc/lwps.c b/src/butc/lwps.c index 3639f74d7..c3fd547ec 100644 --- a/src/butc/lwps.c +++ b/src/butc/lwps.c @@ -1927,7 +1927,7 @@ Restorer(void *param) { FreeNode(taskId); LeaveDeviceQueue(deviceLatch); - return (void *)(code); + return (void *)(intptr_t)(code); } /* this is just scaffolding, creates new tape label with name */ @@ -2276,7 +2276,7 @@ Labeller(void *param) free(labelIfPtr); LeaveDeviceQueue(deviceLatch); - return (void *)(code); + return (void *)(intptr_t)(code); } /* PrintTapeLabel diff --git a/src/butc/recoverDb.c b/src/butc/recoverDb.c index ac9768cd3..67df0b257 100644 --- a/src/butc/recoverDb.c +++ b/src/butc/recoverDb.c @@ -765,7 +765,7 @@ ScanDumps(void *param) free(ptr); setStatus(taskId, TASK_DONE); LeaveDeviceQueue(deviceLatch); - return (void *)(code); + return (void *)(intptr_t)(code); } diff --git a/src/butc/tcprocs.c b/src/butc/tcprocs.c index e0b51de0c..de7d44d2b 100644 --- a/src/butc/tcprocs.c +++ b/src/butc/tcprocs.c @@ -446,11 +446,11 @@ STC_RestoreDb(struct rx_call *rxCall, afs_uint32 *taskId) ERROR_EXIT(code); AFS_SIGSET_CLEAR(); - code = pthread_create(&pid, &tattr, restoreDbFromTape, (void *)*taskId); + code = pthread_create(&pid, &tattr, restoreDbFromTape, (void *)(intptr_t)*taskId); AFS_SIGSET_RESTORE(); #else code = - LWP_CreateProcess(restoreDbFromTape, 32768, 1, (void *)*taskId, + LWP_CreateProcess(restoreDbFromTape, 32768, 1, (void *)(intptr_t)*taskId, "Db restore", &pid); #endif diff --git a/src/butc/tcudbprocs.c b/src/butc/tcudbprocs.c index 16494a624..3b285ae26 100644 --- a/src/butc/tcudbprocs.c +++ b/src/butc/tcudbprocs.c @@ -754,7 +754,7 @@ saveDbToTape(void *param) free(saveDbIfPtr); LeaveDeviceQueue(deviceLatch); - return (void *)(code); + return (void *)(intptr_t)(code); } @@ -1021,7 +1021,7 @@ restoreDbEntries(struct butm_tapeInfo *tapeInfoPtr, void * restoreDbFromTape(void *param) { - afs_uint32 taskId = (afs_uint32) param; + afs_uint32 taskId = (intptr_t) param; afs_int32 code = 0; afs_int32 i; struct butm_tapeInfo tapeInfo; @@ -1107,7 +1107,7 @@ restoreDbFromTape(void *param) LeaveDeviceQueue(deviceLatch); setStatus(taskId, TASK_DONE); - return (void *)(code); + return (void *)(intptr_t)(code); } /* KeepAlive diff --git a/src/butm/file_tm.c b/src/butm/file_tm.c index c1d0c2db6..7a84d1749 100644 --- a/src/butm/file_tm.c +++ b/src/butm/file_tm.c @@ -197,7 +197,7 @@ ForkIoctl(usd_handle_t fd, int op, int count) /* note: as painful as it is, we have to reach under the covers of * the usd package to implement this functionality. */ - unixfd = (int)(fd->handle); + unixfd = (intptr_t)(fd->handle); for (i = 3; i < _POSIX_OPEN_MAX; i++) { if (i != unixfd && i != pipefd[1]) { @@ -448,7 +448,7 @@ ForkClose(usd_handle_t fd) /* note: as painful as it is, we have to reach under the covers of * the usd package to implement this functionality. */ - unixfd = (int)(fd->handle); + unixfd = (intptr_t)(fd->handle); for (i = 3; i < _POSIX_OPEN_MAX; i++) { if (i != unixfd && i != ctlpipe[0] && i != pipefd[1]) { diff --git a/src/dir/salvage.c b/src/dir/salvage.c index b20e73b7b..2b3924583 100644 --- a/src/dir/salvage.c +++ b/src/dir/salvage.c @@ -290,7 +290,7 @@ DirOK(void *file) /* A null name is no good */ if (ep->name[0] == '\000') { printf("Dir entry %x in chain %d has bogus (null) name.\n", - (int)ep, i); + (intptr_t)ep, i); DRelease(ep, 0); DRelease(dhp, 0); return 0; @@ -298,7 +298,7 @@ DirOK(void *file) /* The entry flag better be FFIRST */ if (ep->flag != FFIRST) { - printf("Dir entry %x in chain %d has bogus flag field.\n", (int)ep, + printf("Dir entry %x in chain %d has bogus flag field.\n", (intptr_t)ep, i); DRelease(ep, 0); DRelease(dhp, 0); @@ -308,7 +308,7 @@ DirOK(void *file) /* Check the size of the name */ j = strlen(ep->name); if (j >= MAXENAME) { /* MAXENAME counts the null */ - printf("Dir entry %x in chain %d has too-long name.\n", (int)ep, + printf("Dir entry %x in chain %d has too-long name.\n", (intptr_t)ep, i); DRelease(ep, 0); DRelease(dhp, 0); @@ -327,7 +327,7 @@ DirOK(void *file) if ((j = DirHash(ep->name)) != i) { printf ("Dir entry %x should be in hash bucket %d but IS in %d.\n", - (int)ep, j, i); + (intptr_t)ep, j, i); DRelease(ep, 0); DRelease(dhp, 0); return 0; @@ -340,7 +340,7 @@ DirOK(void *file) } else { printf ("Dir entry %x, index 13 has name '%s' should be '.'\n", - (int)ep, ep->name); + (intptr_t)ep, ep->name); DRelease(ep, 0); DRelease(dhp, 0); return 0; @@ -354,7 +354,7 @@ DirOK(void *file) } else { printf ("Dir entry %x, index 14 has name '%s' should be '..'\n", - (int)ep, ep->name); + (intptr_t)ep, ep->name); DRelease(ep, 0); DRelease(dhp, 0); return 0; diff --git a/src/gtx/frame.c b/src/gtx/frame.c index abed6418d..9a2f797a3 100644 --- a/src/gtx/frame.c +++ b/src/gtx/frame.c @@ -18,6 +18,7 @@ #include #include +#include #include "gtxobjects.h" #include "gtxwindows.h" @@ -93,7 +94,7 @@ gtxframe_SelfInsertCmd(void *aparam, void *rockparam) { struct gwin *awindow = (struct gwin *) aparam; - int arock = (int) rockparam; + int arock = (intptr_t)rockparam; register struct gtx_frame *tframe; register int pos; @@ -139,7 +140,7 @@ SaveMap(struct gtx_frame *aframe) tstring[0] = i; tstring[1] = 0; keymap_BindToString(recursiveMap, tstring, gtxframe_SelfInsertCmd, - NULL, (void *)i); + NULL, (void *)(intptr_t)i); } } aframe->savemap = aframe->keymap; diff --git a/src/gtx/gtxtest.c b/src/gtx/gtxtest.c index f9be9a7fa..96c5a162f 100644 --- a/src/gtx/gtxtest.c +++ b/src/gtx/gtxtest.c @@ -12,6 +12,7 @@ #include +#include #include "gtxwindows.h" #include "gtxobjects.h" @@ -30,7 +31,7 @@ static int ChangeMenuCmd(void *param1, void *param2) { struct gwin * awin = (struct gwin *) param1; - afs_int32 arock = (afs_int32) param2; + afs_int32 arock = (intptr_t)param2; register struct gtx_frame *tf; register afs_int32 code; @@ -57,7 +58,7 @@ static int ChangeListCmd(void *param1, void *param2) { struct gwin *awin = (struct gwin *) param1; - afs_int32 arock = (afs_int32) param2; + afs_int32 arock = (intptr_t)param2; register struct gtx_frame *tf; register afs_int32 code; diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index 0a257bd4c..035996726 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -20,6 +20,7 @@ #include #include +#include #include /* allocate externs here */ @@ -932,8 +933,8 @@ Dispatcher(void) printf("stackcheck = %u: stack = %u \n", lwp_cpptr->stackcheck, *(int *)lwp_cpptr->stack); printf("topstack = 0x%x: stackptr = 0x%x: stacksize = 0x%x\n", - (unsigned int)lwp_cpptr->context.topstack, - (unsigned int)lwp_cpptr->stack, + (uintptr_t)lwp_cpptr->context.topstack, + (uintptr_t)lwp_cpptr->stack, lwp_cpptr->stacksize); switch (lwp_overflowAction) { diff --git a/src/ptserver/ptprocs.c b/src/ptserver/ptprocs.c index 6a09fab1b..3693862eb 100644 --- a/src/ptserver/ptprocs.c +++ b/src/ptserver/ptprocs.c @@ -790,7 +790,7 @@ Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid) /* Delete each continuation block as a separate transaction so that no one * transaction become to large to complete. */ nptr = tentry.next; - while (nptr != (afs_int32) NULL) { + while (nptr != 0) { struct contentry centry; int i; @@ -918,7 +918,7 @@ Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid) * transaction, we start a new transaction every 50 entries. */ count = 0; nptr = tentry.owned; - while (nptr != (afs_int32) NULL) { + while (nptr != 0) { struct prentry nentry; code = pr_ReadEntry(tt, 0, nptr, &nentry); diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c index 1e35fc943..87d24a7ba 100644 --- a/src/ptserver/ptutils.c +++ b/src/ptserver/ptutils.c @@ -915,7 +915,7 @@ DeleteEntry(struct ubik_trans *at, struct prentry *tentry, afs_int32 loc) } #endif /* SUPERGROUPS */ nptr = tentry->next; - while (nptr != (afs_int32) NULL) { + while (nptr != 0) { code = pr_ReadCoEntry(at, 0, nptr, ¢ry); if (code != 0) return PRDBFAIL; @@ -1036,7 +1036,7 @@ AddToEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_int3 } last = 0; nptr = entry->next; - while (nptr != (afs_int32) NULL) { + while (nptr != 0) { code = pr_ReadCoEntry(tt, 0, nptr, &nentry); if (code != 0) return code; @@ -1359,7 +1359,7 @@ GetList2(struct ubik_trans *at, struct prentry *tentry, struct prentry *tentry2, } nptr = tentry->next; - while (nptr != (afs_uint32) NULL) { + while (nptr != 0) { /* look through cont entries */ code = pr_ReadCoEntry(at, 0, nptr, ¢ry); if (code != 0) @@ -1401,7 +1401,7 @@ GetList2(struct ubik_trans *at, struct prentry *tentry, struct prentry *tentry2, if (!code) { nptr = tentry2->next; - while (nptr != (afs_uint32) NULL) { + while (nptr != 0) { /* look through cont entries */ code = pr_ReadCoEntry(at, 0, nptr, ¢ry); if (code != 0) @@ -1747,7 +1747,7 @@ Initdb(void) } if ((ntohl(cheader.version) == PRDBVERSION) && ntohl(cheader.headerSize) == sizeof(cheader) - && ntohl(cheader.eofPtr) != (afs_uint32) NULL + && ntohl(cheader.eofPtr) != 0 && FindByID(tt, ANONYMOUSID) != 0) { /* database exists, so we don't have to build it */ code = ubik_EndTrans(tt); @@ -1797,7 +1797,7 @@ Initdb(void) */ if ((ntohl(cheader.version) == PRDBVERSION) && ntohl(cheader.headerSize) == sizeof(cheader) - && ntohl(cheader.eofPtr) != (afs_uint32) NULL + && ntohl(cheader.eofPtr) != 0 && FindByID(tt, ANONYMOUSID) != 0) { /* database exists, so we don't have to build it */ code = ubik_EndTrans(tt); diff --git a/src/rx/rx.c b/src/rx/rx.c index 68474cdb6..a01f3eb9d 100755 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -537,7 +537,7 @@ rx_InitHost(u_int host, u_int port) #else socklen_t addrlen = sizeof(addr); #endif - if (getsockname((int)rx_socket, (struct sockaddr *)&addr, &addrlen)) { + if (getsockname((intptr_t)rx_socket, (struct sockaddr *)&addr, &addrlen)) { rx_Finalize(); return -1; } diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index c3996ef7a..96fd36be5 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -248,7 +248,7 @@ static void * rx_ListenerProc(void *argp) { int threadID; - osi_socket sock = (osi_socket)argp; + osi_socket sock = (osi_socket)(intptr_t)argp; struct rx_call *newcall; while (1) { @@ -258,7 +258,7 @@ rx_ListenerProc(void *argp) /* assert(threadID != -1); */ /* assert(newcall != NULL); */ sock = OSI_NULLSOCKET; - assert(pthread_setspecific(rx_thread_id_key, (void *)threadID) == 0); + assert(pthread_setspecific(rx_thread_id_key, (void *)(intptr_t)threadID) == 0); rxi_ServerProc(threadID, newcall, &sock); /* assert(sock != OSI_NULLSOCKET); */ } @@ -302,7 +302,7 @@ rx_ServerProc(void * dummy) while (1) { sock = OSI_NULLSOCKET; - assert(pthread_setspecific(rx_thread_id_key, (void *)threadID) == 0); + assert(pthread_setspecific(rx_thread_id_key, (void *)(intptr_t)threadID) == 0); rxi_ServerProc(threadID, newcall, &sock); /* assert(sock != OSI_NULLSOCKET); */ newcall = NULL; @@ -385,7 +385,7 @@ rxi_Listen(osi_socket sock) } AFS_SIGSET_CLEAR(); - if (pthread_create(&thread, &tattr, rx_ListenerProc, (void *)sock) != 0) { + if (pthread_create(&thread, &tattr, rx_ListenerProc, (void *)(intptr_t)sock) != 0) { dpf(("Unable to create socket listener thread\n")); exit(1); } diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index ec5148a7a..1e2b5cefb 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -470,7 +470,7 @@ afs_int32 rxkad_SetConfiguration(struct rx_securityClass *aobj, if (currentValue) { *((afs_uint32 *)currentValue) = private->flags; } else { - private->flags = (afs_uint32) avalue; + private->flags = (intptr_t)avalue; } break; default: diff --git a/src/scout/scout.c b/src/scout/scout.c index 701904b30..6623de00e 100644 --- a/src/scout/scout.c +++ b/src/scout/scout.c @@ -1937,7 +1937,7 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg) &gxlistener_ID); /*Returned LWP process ID */ #endif /* 0 */ - code = (int) gtx_InputServer(scout_gwin); + code = (int)(intptr_t)gtx_InputServer(scout_gwin); if (code) { fprintf(stderr, "[%s] Error exit from gtx_InputServer(), error is %d\n", rn, diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c index 060da0129..df48738de 100644 --- a/src/ubik/ubikclient.c +++ b/src/ubik/ubikclient.c @@ -153,7 +153,7 @@ afs_random(void) if (!called_afs_random_once) pthread_once(&random_once, afs_random_once); - state = (afs_uint32) pthread_getspecific(random_number_key); + state = (uintptr_t) pthread_getspecific(random_number_key); #else static afs_uint32 state = 0; #endif @@ -168,7 +168,7 @@ afs_random(void) ranstage(state); #ifdef AFS_PTHREAD_ENV - pthread_setspecific(random_number_key, (const void *)state); + pthread_setspecific(random_number_key, (const void *)(uintptr_t)state); #endif return (state); diff --git a/src/usd/usd_file.c b/src/usd/usd_file.c index af3cc8e7e..0694c81f8 100644 --- a/src/usd/usd_file.c +++ b/src/usd/usd_file.c @@ -77,7 +77,7 @@ static int usd_FileRead(usd_handle_t usd, char *buf, afs_uint32 nbytes, afs_uint32 * xferdP) { - int fd = (int)(usd->handle); + int fd = (intptr_t)(usd->handle); int got; got = read(fd, buf, nbytes); @@ -95,7 +95,7 @@ static int usd_FileWrite(usd_handle_t usd, char *buf, afs_uint32 nbytes, afs_uint32 * xferdP) { - int fd = (int)(usd->handle); + int fd = (intptr_t)(usd->handle); int sent; sent = write(fd, buf, nbytes); @@ -115,7 +115,7 @@ static int usd_FileSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence, afs_hyper_t * curOffP) { - int fd = (int)(usd->handle); + int fd = (intptr_t)(usd->handle); osi_lloff_t lloff; if (!osi_hFitsInOff(reqOff, lloff)) @@ -134,7 +134,7 @@ usd_FileSeek(usd_handle_t usd, afs_hyper_t reqOff, int whence, static int usd_FileIoctl(usd_handle_t usd, int req, void *arg) { - int fd = (int)(usd->handle); + int fd = (intptr_t)(usd->handle); #ifdef O_LARGEFILE struct stat64 info; #else /* O_LARGEFILE */ @@ -290,7 +290,7 @@ usd_FileIoctl(usd_handle_t usd, int req, void *arg) static int usd_FileClose(usd_handle_t usd) { - int fd = (int)(usd->handle); + int fd = (intptr_t)(usd->handle); int code = 0; int ccode; @@ -351,7 +351,7 @@ usd_FileOpen(const char *path, int flags, int mode, usd_handle_t * usdP) usd = (usd_handle_t) malloc(sizeof(*usd)); memset(usd, 0, sizeof(*usd)); - usd->handle = (void *)fd; + usd->handle = (void *)(intptr_t)fd; usd->read = usd_FileRead; usd->write = usd_FileWrite; usd->seek = usd_FileSeek; diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 546bbcbe3..736528ac8 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -167,7 +167,7 @@ FSLog(const char *format, ...) static void* DebugOn(void *param) { - int loglevel = (int)param; + int loglevel = (intptr_t)param; if (loglevel == 0) { ViceLog(0, ("Reset Debug levels to 0\n")); } else { @@ -200,9 +200,9 @@ SetDebug_Signal(int signo) } printLocks = 2; #if defined(AFS_PTHREAD_ENV) - DebugOn((void *) LogLevel); + DebugOn((void *)(intptr_t)LogLevel); #else /* AFS_PTHREAD_ENV */ - IOMGR_SoftSig(DebugOn, (void *) LogLevel); + IOMGR_SoftSig(DebugOn, (void *)(intptr_t)LogLevel); #endif /* AFS_PTHREAD_ENV */ (void)signal(signo, SetDebug_Signal); /* on some platforms, this @@ -218,9 +218,9 @@ ResetDebug_Signal(int signo) if (printLocks > 0) --printLocks; #if defined(AFS_PTHREAD_ENV) - DebugOn((void *) LogLevel); + DebugOn((void *)(intptr_t)LogLevel); #else /* AFS_PTHREAD_ENV */ - IOMGR_SoftSig(DebugOn, (void *) LogLevel); + IOMGR_SoftSig(DebugOn, (void *)(intptr_t)LogLevel); #endif /* AFS_PTHREAD_ENV */ (void)signal(signo, ResetDebug_Signal); /* on some platforms, diff --git a/src/viced/viced.c b/src/viced/viced.c index 78f895d1a..22c1b7f52 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -352,7 +352,7 @@ ResetCheckDescriptors(void) int threadNum(void) { - return (int)pthread_getspecific(rx_thread_id_key); + return (intptr_t)pthread_getspecific(rx_thread_id_key); } #endif @@ -430,7 +430,7 @@ setThreadId(char *s) /* set our 'thread-id' so that the host hold table works */ MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */ ++rxi_pthread_hinum; - pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum); + pthread_setspecific(rx_thread_id_key, (void *)(intptr_t)rxi_pthread_hinum); MUTEX_EXIT(&rx_stats_mutex); ViceLog(0, ("Set thread id %d for '%s'\n", diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c index 4a6c2c2e0..743354b1e 100644 --- a/src/vlserver/vlserver.c +++ b/src/vlserver/vlserver.c @@ -88,7 +88,7 @@ CheckSignal(void *unused) if ((errorcode = Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))) - return (void *)errorcode; + return (void *)(intptr_t)errorcode; VLog(0, ("Dump name hash table out\n")); for (i = 0; i < HASHSIZE; i++) { HashNDump(trans, i); @@ -97,7 +97,7 @@ CheckSignal(void *unused) for (i = 0; i < HASHSIZE; i++) { HashIdDump(trans, i); } - return ((void *)ubik_EndTrans(trans)); + return ((void *)(intptr_t)ubik_EndTrans(trans)); } /*CheckSignal */ diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c index 8e58dadb2..126e5c7c7 100644 --- a/src/vol/fssync-debug.c +++ b/src/vol/fssync-debug.c @@ -1046,7 +1046,7 @@ VnQuery(struct cmd_syndesc * as, void * rock) } #endif /* !AFS_DEMAND_ATTACH_FS */ - printf("\twriter = %u\n", (unsigned int) v.writer); + printf("\twriter = %u\n", (uintptr_t)v.writer); printf("\tvcp = %p\n", v.vcp); printf("\thandle = %p\n", v.handle); diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index 86bd5fde0..472b61b00 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -237,7 +237,7 @@ FSYNC_sync(void * args) MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */ tid = ++rxi_pthread_hinum; MUTEX_EXIT(&rx_stats_mutex); - pthread_setspecific(rx_thread_id_key, (void *)tid); + pthread_setspecific(rx_thread_id_key, (void *)(intptr_t)tid); Log("Set thread id %d for FSYNC_sync\n", tid); #endif /* AFS_PTHREAD_ENV */ diff --git a/src/vol/vnode.c b/src/vol/vnode.c index d051bbc1b..e20057133 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -481,7 +481,7 @@ VGetFreeVnode_r(struct VnodeClassInfo * vcp) if (Vn_refcount(vnp) != 0 || CheckLock(&vnp->lock)) Abort("VGetFreeVnode_r: locked vnode in lruq"); #endif - VNLog(1, 2, Vn_id(vnp), (afs_int32) vnp, 0, 0); + VNLog(1, 2, Vn_id(vnp), (intptr_t)vnp, 0, 0); /* * it's going to be overwritten soon enough. @@ -662,7 +662,7 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type) if (vnp) { /* slot already exists. May even not be in lruq (consider store file locking a file being deleted) * so we may have to wait for it below */ - VNLog(3, 2, vnodeNumber, (afs_int32) vnp, 0, 0); + VNLog(3, 2, vnodeNumber, (intptr_t)vnp, 0, 0); VnCreateReservation_r(vnp); if (Vn_refcount(vnp) == 1) { @@ -819,13 +819,13 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type) } sane: - VNLog(4, 2, vnodeNumber, (afs_int32) vnp, 0, 0); + VNLog(4, 2, vnodeNumber, (intptr_t)vnp, 0, 0); #ifndef AFS_DEMAND_ATTACH_FS AddToVnHash(vnp); #endif } - VNLog(5, 1, (afs_int32) vnp, 0, 0, 0); + VNLog(5, 1, (intptr_t)vnp, 0, 0, 0); memset(&vnp->disk, 0, sizeof(vnp->disk)); vnp->changed_newTime = 0; /* set this bit when vnode is updated */ vnp->changed_oldTime = 0; /* set this on CopyOnWrite. */ @@ -1167,7 +1167,7 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype) if (vnp) { /* vnode is in cache */ - VNLog(101, 2, vnodeNumber, (afs_int32) vnp, 0, 0); + VNLog(101, 2, vnodeNumber, (intptr_t)vnp, 0, 0); VnCreateReservation_r(vnp); #ifdef AFS_DEMAND_ATTACH_FS @@ -1254,7 +1254,7 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype) /* Check that the vnode hasn't been removed while we were obtaining * the lock */ - VNLog(102, 2, vnodeNumber, (afs_int32) vnp, 0, 0); + VNLog(102, 2, vnodeNumber, (intptr_t) vnp, 0, 0); if ((vnp->disk.type == vNull) || (Vn_cacheCheck(vnp) == 0)) { VnUnlock(vnp, locktype); VnCancelReservation_r(vnp); @@ -1316,7 +1316,7 @@ VPutVnode_r(Error * ec, register Vnode * vnp) class = vnodeIdToClass(Vn_id(vnp)); vcp = &VnodeClassInfo[class]; assert(vnp->disk.vnodeMagic == vcp->magic); - VNLog(200, 2, Vn_id(vnp), (afs_int32) vnp, 0, 0); + VNLog(200, 2, Vn_id(vnp), (intptr_t) vnp, 0, 0); #ifdef AFS_DEMAND_ATTACH_FS writeLocked = (Vn_state(vnp) == VN_STATE_EXCLUSIVE); @@ -1332,7 +1332,7 @@ VPutVnode_r(Error * ec, register Vnode * vnp) PROCESS thisProcess; LWP_CurrentProcess(&thisProcess); #endif /* AFS_PTHREAD_ENV */ - VNLog(201, 2, (afs_int32) vnp, + VNLog(201, 2, (intptr_t) vnp, ((vnp->changed_newTime) << 1) | ((vnp-> changed_oldTime) << 1) | vnp-> delete, 0, 0); @@ -1350,7 +1350,7 @@ VPutVnode_r(Error * ec, register Vnode * vnp) /* No longer any directory entries for this vnode. Free the Vnode */ memset(&vnp->disk, 0, sizeof(vnp->disk)); /* delete flag turned off further down */ - VNLog(202, 2, Vn_id(vnp), (afs_int32) vnp, 0, 0); + VNLog(202, 2, Vn_id(vnp), (intptr_t) vnp, 0, 0); } else if (vnp->changed_newTime) { vnp->disk.serverModifyTime = now; } @@ -1456,7 +1456,7 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp) class = vnodeIdToClass(Vn_id(vnp)); vcp = &VnodeClassInfo[class]; assert(vnp->disk.vnodeMagic == vcp->magic); - VNLog(300, 2, Vn_id(vnp), (afs_int32) vnp, 0, 0); + VNLog(300, 2, Vn_id(vnp), (intptr_t) vnp, 0, 0); #ifdef AFS_DEMAND_ATTACH_FS writeLocked = (Vn_state(vnp) == VN_STATE_EXCLUSIVE); @@ -1468,7 +1468,7 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp) } - VNLog(301, 2, (afs_int32) vnp, + VNLog(301, 2, (intptr_t) vnp, ((vnp->changed_newTime) << 1) | ((vnp-> changed_oldTime) << 1) | vnp-> delete, 0, 0); @@ -1481,7 +1481,7 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp) #endif /* AFS_PTHREAD_ENV */ if (thisProcess != vnp->writer) Abort("VPutVnode: Vnode at 0x%x locked by another process!\n", - (int)vnp); + (intptr_t)vnp); if (vnp->delete) { return 0; diff --git a/src/volser/volmain.c b/src/volser/volmain.c index fa683c4eb..897b54dca 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -102,7 +102,7 @@ afs_uint32 SHostAddrs[ADDRSPERSITE]; int threadNum(void) { - return (int)pthread_getspecific(rx_thread_id_key); + return (intptr_t)pthread_getspecific(rx_thread_id_key); } #endif diff --git a/src/volser/vos.c b/src/volser/vos.c index 78caa8c68..f002c5448 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -283,12 +283,12 @@ SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize) #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */ fd_set in; FD_ZERO(&in); - FD_SET((int)(ufd->handle), &in); + FD_SET((intptr_t)(ufd->handle), &in); /* don't timeout if read blocks */ #if defined(AFS_PTHREAD_ENV) select(((int)(ufd->handle)) + 1, &in, 0, 0, 0); #else - IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0); + IOMGR_Select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0); #endif #endif error = USD_READ(ufd, buffer, blksize, &nbytes); @@ -396,12 +396,12 @@ ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize) #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */ fd_set out; FD_ZERO(&out); - FD_SET((int)(ufd->handle), &out); + FD_SET((intptr_t)(ufd->handle), &out); /* don't timeout if write blocks */ #if defined(AFS_PTHREAD_ENV) select(((int)(ufd->handle)) + 1, &out, 0, 0, 0); #else - IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0); + IOMGR_Select(((intptr_t)(ufd->handle)) + 1, 0, &out, 0, 0); #endif #endif error = -- 2.39.5