From: Simon Wilkinson Date: Thu, 17 May 2012 11:31:39 +0000 (+0100) Subject: rx: Don't cast returns from allocator X-Git-Tag: upstream/1.8.0_pre1^2~2375 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=3613d41515438a5615c3ffcdde5616c5f4e1c6ae;p=packages%2Fo%2Fopenafs.git rx: Don't cast returns from allocator malloc() and osi_Alloc both return (void *). So, don't bother casting the return value before assigning it - its unnecessary noise. Change-Id: I71a66a8fa0d9f49f4833dd77bbb55422e6f20d6f Reviewed-on: http://gerrit.openafs.org/7466 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/rx/UKERNEL/rx_knet.c b/src/rx/UKERNEL/rx_knet.c index e6eb661e3..7e14cf3f8 100644 --- a/src/rx/UKERNEL/rx_knet.c +++ b/src/rx/UKERNEL/rx_knet.c @@ -178,7 +178,7 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) { struct usr_socket *usockp; - usockp = (struct usr_socket *)afs_osi_Alloc(sizeof(struct usr_socket)); + usockp = afs_osi_Alloc(sizeof(struct usr_socket)); usr_assert(usockp != NULL); usockp->sock = -1; diff --git a/src/rx/bulk.example/bulk_io.c b/src/rx/bulk.example/bulk_io.c index 3d860e21c..0a13d1f0d 100644 --- a/src/rx/bulk.example/bulk_io.c +++ b/src/rx/bulk.example/bulk_io.c @@ -29,7 +29,7 @@ bulk_SendFile(int fd, struct rx_call *call, long error = 0; blockSize = status->st_blksize; length = status->st_size; - buffer = (char *)malloc(status->st_blksize); + buffer = malloc(status->st_blksize); if (!buffer) { printf("malloc failed\n"); return BULK_ERROR; @@ -70,7 +70,7 @@ bulk_ReceiveFile(int fd, struct rx_call *call, if (!xdr_long(&xdr, &length)) return BULK_ERROR; blockSize = status->st_blksize; - buffer = (char *)malloc(status->st_blksize); + buffer = malloc(status->st_blksize); if (!buffer) { fprintf(stderr, "malloc failed\n"); return BULK_ERROR; diff --git a/src/rx/bulktest/bulk_client.c b/src/rx/bulktest/bulk_client.c index de7cc73f9..5ede9021c 100644 --- a/src/rx/bulktest/bulk_client.c +++ b/src/rx/bulktest/bulk_client.c @@ -117,8 +117,7 @@ async_BulkTest(host, conn, store, count, verbose, file) char tempfile[256]; char *name; PROCESS pid; - struct async_work *work = - (struct async_work *)malloc(sizeof(struct async_work)); + struct async_work *work = malloc(sizeof(struct async_work)); work->host = host; work->conn = conn; work->store = store; diff --git a/src/rx/bulktest/bulk_io.c b/src/rx/bulktest/bulk_io.c index d97249dd8..a296af7f4 100644 --- a/src/rx/bulktest/bulk_io.c +++ b/src/rx/bulktest/bulk_io.c @@ -31,7 +31,7 @@ bulk_SendFile(fd, call, status) long error = 0; blockSize = status->st_blksize; length = status->st_size; - buffer = (char *)malloc(status->st_blksize); + buffer = malloc(status->st_blksize); if (!buffer) { printf("malloc failed\n"); return BULK_ERROR; @@ -74,7 +74,7 @@ bulk_ReceiveFile(fd, call, status) if (!xdr_long(&xdr, &length)) return BULK_ERROR; blockSize = status->st_blksize; - buffer = (char *)malloc(status->st_blksize); + buffer = malloc(status->st_blksize); if (!buffer) { printf("malloc failed\n"); return BULK_ERROR; diff --git a/src/rx/rx.c b/src/rx/rx.c index f24fe2f1a..dd1c3ac4c 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -556,11 +556,10 @@ rx_InitHost(u_int host, u_int port) rx_connDeadTime = 12; rx_tranquil = 0; /* reset flag */ rxi_ResetStatistics(); - htable = (char *) - osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *)); + htable = osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *)); PIN(htable, rx_hashTableSize * sizeof(struct rx_connection *)); /* XXXXX */ memset(htable, 0, rx_hashTableSize * sizeof(struct rx_connection *)); - ptable = (char *)osi_Alloc(rx_hashTableSize * sizeof(struct rx_peer *)); + ptable = osi_Alloc(rx_hashTableSize * sizeof(struct rx_peer *)); PIN(ptable, rx_hashTableSize * sizeof(struct rx_peer *)); /* XXXXX */ memset(ptable, 0, rx_hashTableSize * sizeof(struct rx_peer *)); @@ -7935,7 +7934,7 @@ rx_SetSpecific(struct rx_connection *conn, int key, void *ptr) int i; MUTEX_ENTER(&conn->conn_data_lock); if (!conn->specific) { - conn->specific = (void **)malloc((key + 1) * sizeof(void *)); + conn->specific = malloc((key + 1) * sizeof(void *)); for (i = 0; i < key; i++) conn->specific[i] = NULL; conn->nSpecific = key + 1; @@ -7961,7 +7960,7 @@ rx_SetServiceSpecific(struct rx_service *svc, int key, void *ptr) int i; MUTEX_ENTER(&svc->svc_data_lock); if (!svc->specific) { - svc->specific = (void **)malloc((key + 1) * sizeof(void *)); + svc->specific = malloc((key + 1) * sizeof(void *)); for (i = 0; i < key; i++) svc->specific[i] = NULL; svc->nSpecific = key + 1; diff --git a/src/rx/rx_conncache.c b/src/rx/rx_conncache.c index 4828f2a7f..0fe15050e 100644 --- a/src/rx/rx_conncache.c +++ b/src/rx/rx_conncache.c @@ -132,7 +132,7 @@ rxi_AddCachedConnection(rx_connParts_p parts, struct rx_connection **conn) { cache_entry_p new_entry; - if ((new_entry = (cache_entry_p) malloc(sizeof(cache_entry_t)))) { + if ((new_entry = malloc(sizeof(cache_entry_t)))) { new_entry->conn = *conn; new_entry->parts = *parts; new_entry->inUse = 1; diff --git a/src/rx/rx_multi.c b/src/rx/rx_multi.c index cefa0a28a..20cd2a3e9 100644 --- a/src/rx/rx_multi.c +++ b/src/rx/rx_multi.c @@ -37,9 +37,9 @@ multi_Init(struct rx_connection **conns, int nConns) * a process stack will not be accessible to other processes */ - calls = (struct rx_call **)osi_Alloc(sizeof(struct rx_call *) * nConns); - ready = (short *)osi_Alloc(sizeof(short *) * nConns); - mh = (struct multi_handle *)osi_Alloc(sizeof(struct multi_handle)); + calls = osi_Alloc(sizeof(struct rx_call *) * nConns); + ready = osi_Alloc(sizeof(short *) * nConns); + mh = osi_Alloc(sizeof(struct multi_handle)); if (!calls || !ready || !mh) osi_Panic("multi_Rx: no mem\n"); memset(mh, 0, sizeof(struct multi_handle)); diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index 646b9633b..e7a82780c 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -530,7 +530,7 @@ rxi_MorePackets(int apackets) SPLVAR; getme = apackets * sizeof(struct rx_packet); - p = (struct rx_packet *)osi_Alloc(getme); + p = osi_Alloc(getme); osi_Assert(p); PIN(p, getme); /* XXXXX */ @@ -584,7 +584,7 @@ rxi_MorePackets(int apackets) SPLVAR; getme = apackets * sizeof(struct rx_packet); - p = (struct rx_packet *)osi_Alloc(getme); + p = osi_Alloc(getme); osi_Assert(p); PIN(p, getme); /* XXXXX */ @@ -627,7 +627,7 @@ rxi_MorePacketsTSFPQ(int apackets, int flush_global, int num_keep_local) SPLVAR; getme = apackets * sizeof(struct rx_packet); - p = (struct rx_packet *)osi_Alloc(getme); + p = osi_Alloc(getme); PIN(p, getme); /* XXXXX */ memset(p, 0, getme); @@ -689,7 +689,7 @@ rxi_MorePacketsNoLock(int apackets) * ((rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE) / RX_CBUFFERSIZE); do { getme = apackets * sizeof(struct rx_packet); - p = (struct rx_packet *)osi_Alloc(getme); + p = osi_Alloc(getme); if (p == NULL) { apackets -= apackets / 4; osi_Assert(apackets > 0); diff --git a/src/rx/test/generator.c b/src/rx/test/generator.c index 3a659fc07..8f3d929f1 100644 --- a/src/rx/test/generator.c +++ b/src/rx/test/generator.c @@ -176,7 +176,7 @@ GetName(char *serverName, int sign_no) /* itl file name 8.3 format */ char *bufP; - bufP = (char *)malloc(32 * sizeof(char)); + bufP = malloc(32 * sizeof(char)); MEM_CHK(bufP, "GetName: bufP out of mem\n"); sprintf(bufP, "%s%d", serverName, sign_no); @@ -530,7 +530,7 @@ WriteServC(rpcArgs * argsP, FILE * srv_h, char *serverName, int sign_no) argsP->argDescr[i].outValue[0]); } else if (!strcmp(typ, "varString")) { if (!strcmp(argsP->argDescr[i].direction, "OUT")) { - fprintf(srv_h, "\n\t*a%d = (char *) malloc(STR_MAX);", i); + fprintf(srv_h, "\n\t*a%d = malloc(STR_MAX);", i); } fprintf(srv_h, "\n\tstrcpy((char *)*a%d, %s);", i, argsP->argDescr[i].outValue[0]); @@ -768,7 +768,7 @@ WriteCltTrailer(char *serverName, int first, int last, FILE * itl_h) "malloc(numThreads*(sizeof(pthread_t)));\n"); } else { fprintf(itl_h, - "\ttid = (PROCESS *) malloc(numThreads*(sizeof(PROCESS *)));\n"); + "\ttid = malloc(numThreads*(sizeof(PROCESS *)));\n"); } fprintf(itl_h, "\tassert(tid);\n" "\tfor(j=0;jtype); fprintf(itl_h, "\t%sa%d.drpc_out_%s_t_val = " - "(%s *) malloc(FIX_ARRAY_SIZE * sizeof(%s));\n", s, i, - arg->type, (arg->type + 3), (arg->type + 3)); + "malloc(FIX_ARRAY_SIZE * sizeof(%s));\n", s, i, + arg->type, (arg->type + 3)); } for (j = 0; j < IDL_FIX_ARRAY_SIZE; j++) { if (structFlag) { diff --git a/src/rx/test/tableGen.c b/src/rx/test/tableGen.c index e74221db5..078de99c7 100644 --- a/src/rx/test/tableGen.c +++ b/src/rx/test/tableGen.c @@ -246,7 +246,7 @@ ProcessCmdLine(argc, argv, apFileNamePP, outputFileP) if (n == 0) FATAL("ProcessCmdLine: must give dir with -d\n"); dir_size = n; - dir = (char **)malloc(sizeof(char *) * n); + dir = malloc(sizeof(char *) * n); MEM_CHK(dir, "ProcessCmdLine: out of mem dir\n"); for (i = 0; i < n; i++) *(dir + i) = *++argv; @@ -272,7 +272,7 @@ ProcessCmdLine(argc, argv, apFileNamePP, outputFileP) if (n == 0) FATAL("ProcessCmdLine: must give typ with -t\n"); typ_size = n; - typ = (char **)malloc(sizeof(char *) * n); + typ = malloc(sizeof(char *) * n); MEM_CHK(typ, "ProcessCmdLine: out of mem typ\n"); for (i = 0; i < n; i++) *(typ + i) = *++argv; diff --git a/src/rx/test/testclient.c b/src/rx/test/testclient.c index 90c315e83..accd085ea 100644 --- a/src/rx/test/testclient.c +++ b/src/rx/test/testclient.c @@ -25,7 +25,7 @@ #include #ifndef osi_Alloc -#define osi_Alloc(n) (char *) malloc(n) +#define osi_Alloc(n) malloc(n) #endif int timeReadvs = 0; @@ -218,7 +218,7 @@ main(int argc, char **argv) if (sendFile) SendFile(sendFile, conn); else { - buffer = (char *)osi_Alloc(bufferSize); + buffer = osi_Alloc(bufferSize); while (nCalls--) { struct clock startTime; struct timeval t; @@ -323,7 +323,7 @@ SendFile(char *file, struct rx_connection *conn) blockSize = status.st_blksize; #endif #endif - buf = (char *)osi_Alloc(blockSize); + buf = osi_Alloc(blockSize); bytesLeft = status.st_size; clock_GetTime(&startTime); call = rx_NewCall(conn); diff --git a/src/rx/test/testqueue.c b/src/rx/test/testqueue.c index 1159c962a..b6c4669e7 100644 --- a/src/rx/test/testqueue.c +++ b/src/rx/test/testqueue.c @@ -46,10 +46,10 @@ createQueue(int n) int i; struct rx_queue *q; struct myq *qe; - q = (struct rx_queue *)malloc(sizeof(struct rx_queue)); + q = malloc(sizeof(struct rx_queue)); queue_Init(q); for (i = 0; i < 3; i++) { - qe = (struct myq *)malloc(sizeof(struct myq)); + qe = malloc(sizeof(struct myq)); qe->value = n * 1000 + i; queue_Append(q, qe); } diff --git a/src/rx/test/testserver.c b/src/rx/test/testserver.c index 3eae762ed..a84d206e1 100644 --- a/src/rx/test/testserver.c +++ b/src/rx/test/testserver.c @@ -274,7 +274,7 @@ FileRequest(struct rx_call *call) blockSize = status.st_blksize; #endif #endif /* AFS_NT40_ENV */ - buffer = (char *)malloc(blockSize); + buffer = malloc(blockSize); rx_SetLocalStatus(call, 79); /* Emulation of file server's old "RCallBackReceivedStore" */ diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index 125ab84de..3ee20ff44 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -144,12 +144,12 @@ rxkad_NewServerSecurityObject(rxkad_level level, void *get_key_rock, return 0; size = sizeof(struct rx_securityClass); - tsc = (struct rx_securityClass *)osi_Alloc(size); + tsc = osi_Alloc(size); memset(tsc, 0, size); tsc->refCount = 1; /* caller has one reference */ tsc->ops = &rxkad_server_ops; size = sizeof(struct rxkad_sprivate); - tsp = (struct rxkad_sprivate *)osi_Alloc(size); + tsp = osi_Alloc(size); memset(tsp, 0, size); tsc->privateData = (char *)tsp; @@ -415,7 +415,7 @@ rxkad_CheckResponse(struct rx_securityClass *aobj, return RXKADNOAUTH; } else { /* save the info for later retreival */ int size = sizeof(struct rxkad_serverinfo); - rock = (struct rxkad_serverinfo *)osi_Alloc(size); + rock = osi_Alloc(size); memset(rock, 0, size); rock->kvno = kvno; memcpy(&rock->client, &client, sizeof(rock->client)); diff --git a/src/rxkad/test/stress.c b/src/rxkad/test/stress.c index 1c7270ea6..0020fccaf 100644 --- a/src/rxkad/test/stress.c +++ b/src/rxkad/test/stress.c @@ -114,8 +114,8 @@ CommandProc(struct cmd_syndesc *as, void *arock) struct serverParms *sParms; struct clientParms *cParms; - sParms = (struct serverParms *)osi_Alloc(sizeof(*sParms)); - cParms = (struct clientParms *)osi_Alloc(sizeof(*cParms)); + sParms = osi_Alloc(sizeof(*sParms)); + cParms = osi_Alloc(sizeof(*cParms)); memset(sParms, 0, sizeof(*sParms)); memset(cParms, 0, sizeof(*cParms)); sParms->whoami = cParms->whoami = whoami; diff --git a/src/rxkad/test/stress_c.c b/src/rxkad/test/stress_c.c index 9b6d551cd..e9d83b321 100644 --- a/src/rxkad/test/stress_c.c +++ b/src/rxkad/test/stress_c.c @@ -282,7 +282,7 @@ CallSimultaneously(u_int threads, opaque rock, long (*proc)(int, opaque)) PROCESS pid; #endif assert(i < MAX_CTHREADS); - w = (struct worker *)osi_Alloc(sizeof(struct worker)); + w = osi_Alloc(sizeof(struct worker)); memset(w, 0, sizeof(*w)); w->next = workers; workers = w;