From: Simon Wilkinson Date: Thu, 21 Feb 2013 20:36:19 +0000 (+0000) Subject: libadmin: Fix a lot of dead assignments in vsprocs X-Git-Tag: openafs-stable-1_8_0pre1~1450 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=ee0d57bb488e9fd74b46547273904a9821e20c57 libadmin: Fix a lot of dead assignments in vsprocs Tidy up a lot of places where we initialise a variable, then immediately assign a proper value to it, or store a return value that we don't actually care about. Caught by clang-analyzer Change-Id: Icf0ec713dac6f2c4f0a60e8ead52a8d3e19381f0 Reviewed-on: http://gerrit.openafs.org/9205 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- diff --git a/src/libadmin/vos/vsprocs.c b/src/libadmin/vos/vsprocs.c index 5f37b01..30c47a3 100644 --- a/src/libadmin/vos/vsprocs.c +++ b/src/libadmin/vos/vsprocs.c @@ -59,7 +59,6 @@ CheckAndDeleteVolume(struct rx_connection *aconn, afs_int32 apart, afs_int32 error, code, tid, rcode; error = 0; - code = 0; if (okvol == 0) { code = AFSVolTransCreate(aconn, delvol, apart, ITOffline, &tid); @@ -1167,15 +1166,13 @@ static int DelVol(struct rx_connection *conn, afs_uint32 vid, afs_int32 part, afs_int32 flags) { - afs_int32 acode, ccode, rcode, tid; - ccode = rcode = tid = 0; + afs_int32 acode, rcode, tid; + rcode = tid = 0; acode = AFSVolTransCreate(conn, vid, part, flags, &tid); if (!acode) { /* It really was there */ acode = AFSVolDeleteVolume(conn, tid); - ccode = AFSVolEndTrans(conn, tid, &rcode); - if (!ccode) - ccode = rcode; + AFSVolEndTrans(conn, tid, &rcode); } return acode; @@ -1297,7 +1294,7 @@ GetTrans(afs_cell_handle_p cellHandle, struct nvldbentry *vldbEntryPtr, afs_int32 * transPtr, afs_int32 * timePtr, afs_status_p st) { int rc = 0; - afs_status_t tst = 0, etst = 0; + afs_status_t tst = 0; afs_uint32 volid; struct volser_status tstatus; int rcode; @@ -1369,10 +1366,8 @@ GetTrans(afs_cell_handle_p cellHandle, struct nvldbentry *vldbEntryPtr, fail_GetTrans: if ((rc == 0) && (*transPtr)) { - etst = AFSVolEndTrans(*connPtr, *transPtr, &rcode); + AFSVolEndTrans(*connPtr, *transPtr, &rcode); *transPtr = 0; - if (!etst) - etst = rcode; } if (st != NULL) { @@ -2035,7 +2030,6 @@ DumpFunction(struct rx_call *call, const char *filename) afs_int32 error, code; error = 0; - fd = -1; fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666); if (fd < 0 || fstat(fd, &status) < 0) { @@ -2083,12 +2077,10 @@ UV_DumpVolume(afs_cell_handle_p cellHandle, afs_uint32 afromvol, islocked = 0; rxError = 0; - fromcall = (struct rx_call *)0; fromconn = (struct rx_connection *)0; fromtid = 0; fromcall = (struct rx_call *)0; - islocked = 0; if (!aVLDB_GetEntryByID(cellHandle, afromvol, -1, &entry, &tst)) { goto fail_UV_DumpVolume; } @@ -2169,7 +2161,6 @@ SendFile(int fd, struct rx_call *call, int blockSize; fd_set in; afs_int32 error = 0; - int done = 0; int nbytes; #ifdef AFS_NT40_ENV @@ -2195,7 +2186,7 @@ t structure!! */ return ADMNOMEM; } - while (!error && !done) { + while (!error) { FD_ZERO(&in); FD_SET(fd, &in); #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */ @@ -2206,10 +2197,10 @@ t structure!! */ error = ADMVOSRESTOREFILEREADFAIL; break; } - if (nbytes == 0) { - done = 1; + + if (nbytes == 0) break; - } + if (rx_Write(call, buffer, nbytes) != nbytes) { error = ADMVOSRESTOREFILEWRITEFAIL; break; @@ -2228,7 +2219,6 @@ WriteData(struct rx_call *call, const char *filename) afs_int32 error, code; error = 0; - fd = -1; fd = open(filename, 0); if (fd < 0 || fstat(fd, &status) < 0) { @@ -2287,10 +2277,8 @@ UV_RestoreVolume(afs_cell_handle_p cellHandle, afs_int32 toserver, memset(&cookie, 0, sizeof(cookie)); islocked = 0; - success = 0; reuseID = 1; tocall = (struct rx_call *)0; - toconn = (struct rx_connection *)0; tempconn = (struct rx_connection *)0; totid = 0; temptid = 0; @@ -2974,7 +2962,7 @@ ProcessEntries(afs_cell_handle_p cellHandle, struct qHead *myQueue, { struct aqueue elem; int success, temp; - afs_uint32 temp1, temp2; + afs_uint32 temp2; afs_int32 vcode; afs_uint32 maxVolid = 0; struct nvldbentry entry; @@ -3006,30 +2994,24 @@ ProcessEntries(afs_cell_handle_p cellHandle, struct qHead *myQueue, continue; } if (maxVolid <= elem.ids[RWVOL]) { - temp1 = maxVolid; temp2 = elem.ids[RWVOL] - maxVolid + 1; maxVolid = 0; - vcode = - ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, - &maxVolid); + ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, + &maxVolid); maxVolid += temp2; } if (maxVolid <= elem.ids[ROVOL]) { - temp1 = maxVolid; temp2 = elem.ids[ROVOL] - maxVolid + 1; maxVolid = 0; - vcode = - ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, - &maxVolid); + ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, + &maxVolid); maxVolid += temp2; } if (maxVolid <= elem.ids[BACKVOL]) { - temp1 = maxVolid; - temp2 = elem.ids[BACKVOL] - temp1 + 1; + temp2 = elem.ids[BACKVOL] - maxVolid + 1; maxVolid = 0; - vcode = - ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, - &maxVolid); + ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2, + &maxVolid); maxVolid += temp2; } aVLDB_GetEntryByID(cellHandle, elem.ids[RWVOL], RWVOL, &entry, &tst);