From: Simon Wilkinson Date: Thu, 17 May 2012 08:37:50 +0000 (+0100) Subject: JAVA: Don't cast returns from malloc() X-Git-Tag: openafs-stable-1_8_0pre1~2383 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=25bc7849caf855b08a69b1701db089b1da9b506b JAVA: Don't cast returns from malloc() malloc() returns a (void *) on all of our current platforms. So, don't bother casting the return value before assigning it - it's unecessary noise. Change-Id: I534d424da13e03d3c0f0de3dddf1dd19088d1659 Reviewed-on: http://gerrit.openafs.org/7458 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/JAVA/libjafs/ACL.c b/src/JAVA/libjafs/ACL.c index 204b743..b818754 100644 --- a/src/JAVA/libjafs/ACL.c +++ b/src/JAVA/libjafs/ACL.c @@ -73,7 +73,7 @@ char* getACL(char *path) char *buffer; int rval1=0; - buffer = (char*) malloc(ACL_LEN); + buffer = malloc(ACL_LEN); params.in = NULL; params.out = NULL; params.in_size = params.out_size = 0; diff --git a/src/JAVA/libjafs/Cell.c b/src/JAVA/libjafs/Cell.c index 8ef7990..f44863d 100644 --- a/src/JAVA/libjafs/Cell.c +++ b/src/JAVA/libjafs/Cell.c @@ -208,9 +208,8 @@ Java_org_openafs_jafs_Cell_getKasUsersNextString (JNIEnv *env, jclass cls, } if( strcmp( who.instance, "" ) ) { - char *fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) - + strlen( who.instance ) - + 2 ) ); + char *fullName = malloc( sizeof(char)*( strlen( who.principal ) + + strlen( who.instance ) + 2 ) ); if( !fullName ) { throwAFSException( env, JAFSADMNOMEM ); return; @@ -265,8 +264,8 @@ Java_org_openafs_jafs_Cell_getKasUsersNext (JNIEnv *env, jclass cls, // take care of the instance stuff(by concatenating with a period in between) if( strcmp( who.instance, "" ) ) { - fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) + - strlen( who.instance ) + 2 ) ); + fullName = malloc( sizeof(char)*( strlen( who.principal ) + + strlen( who.instance ) + 2 ) ); if( !fullName ) { throwAFSException( env, JAFSADMNOMEM ); return 0; @@ -369,7 +368,7 @@ Java_org_openafs_jafs_Cell_getPtsUserCount (JNIEnv *env, jclass cls, return -1; } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -419,7 +418,7 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUserCount (JNIEnv *env, jclass cls, return -1; } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { free( who ); @@ -499,7 +498,7 @@ Java_org_openafs_jafs_Cell_getPtsUsersNextString (JNIEnv *env, jclass cls, char *userName; jstring juser; - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -555,7 +554,7 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString (JNIEnv *env, return; } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { free( who ); @@ -626,7 +625,7 @@ Java_org_openafs_jafs_Cell_getPtsUsersNext (JNIEnv *env, jclass cls, char *userName; jstring juser; - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -696,7 +695,7 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext (JNIEnv *env, jclass cls, return 0; } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { free( who ); @@ -798,7 +797,7 @@ Java_org_openafs_jafs_Cell_getGroupCount (JNIEnv *env, jclass cls, return -1; } - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -866,7 +865,7 @@ Java_org_openafs_jafs_Cell_getGroupsBeginAt (JNIEnv *env, jclass cls, char *groupName; int i; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) { throwAFSException( env, ast ); @@ -907,7 +906,7 @@ Java_org_openafs_jafs_Cell_getGroupsNextString (JNIEnv *env, jclass cls, char *groupName; jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -952,7 +951,7 @@ Java_org_openafs_jafs_Cell_getGroupsNext (JNIEnv *env, jclass cls, char *groupName; jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN ); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN ); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM ); diff --git a/src/JAVA/libjafs/FileOutputStream.c b/src/JAVA/libjafs/FileOutputStream.c index 76aceda..3223e9f 100644 --- a/src/JAVA/libjafs/FileOutputStream.c +++ b/src/JAVA/libjafs/FileOutputStream.c @@ -123,7 +123,7 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write "descriptor\n"); throwAFSFileException(env, 0, "Failed to get file descriptor!"); } - bytes = (char*) malloc(length); + bytes = malloc(length); if(bytes == NULL) { fprintf(stderr, "FileOutputStream::write(): malloc failed of %d bytes\n", length); diff --git a/src/JAVA/libjafs/GetNativeString.c b/src/JAVA/libjafs/GetNativeString.c index 209ba90..048728e 100644 --- a/src/JAVA/libjafs/GetNativeString.c +++ b/src/JAVA/libjafs/GetNativeString.c @@ -27,7 +27,7 @@ char* GetNativeString(JNIEnv *env, jstring jstr){ exc = (*env)->ExceptionOccurred(env); if (!exc) { jint len = (*env)->GetArrayLength(env, bytes); - result = (char *)malloc(len + 1); + result = malloc(len + 1); if (result == 0) { /*JNU_ThrowByName(env, "java/lang/OutOfMemoryError", diff --git a/src/JAVA/libjafs/Group.c b/src/JAVA/libjafs/Group.c index bc89a03..67bb36f 100644 --- a/src/JAVA/libjafs/Group.c +++ b/src/JAVA/libjafs/Group.c @@ -472,7 +472,7 @@ Java_org_openafs_jafs_Group_getGroupMembersNextString (JNIEnv *env, jclass cls, jlong iterationId) { afs_status_t ast; - char *userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + char *userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); jstring juser; if( !userName ) { @@ -516,7 +516,7 @@ Java_org_openafs_jafs_Group_getGroupMembersNext char *userName; jstring juser; - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !userName ) { throwAFSException( env, JAFSADMNOMEM ); diff --git a/src/JAVA/libjafs/Key.c b/src/JAVA/libjafs/Key.c index 85211c0..9844972 100644 --- a/src/JAVA/libjafs/Key.c +++ b/src/JAVA/libjafs/Key.c @@ -58,8 +58,7 @@ void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry ) // set all the fields (*env)->SetIntField( env, key, key_versionField, keyEntry.keyVersionNumber ); - convertedKey = (char *) malloc( sizeof(char *)* - (sizeof(keyEntry.key.key)*4+1) ); + convertedKey = malloc( sizeof(char *) * (sizeof(keyEntry.key.key)*4+1) ); if( !convertedKey ) { throwAFSException( env, JAFSADMNOMEM ); return; diff --git a/src/JAVA/libjafs/Partition.c b/src/JAVA/libjafs/Partition.c index f16cab6..238251a 100644 --- a/src/JAVA/libjafs/Partition.c +++ b/src/JAVA/libjafs/Partition.c @@ -180,7 +180,7 @@ Java_org_openafs_jafs_Partition_translateIDToName (JNIEnv *env, jclass cls, jint id) { afs_status_t ast; - char *name = (char *) malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN); + char *name = malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN); jstring jname; if( !name ) { diff --git a/src/JAVA/libjafs/Process.c b/src/JAVA/libjafs/Process.c index 0c1329d..68640b5 100644 --- a/src/JAVA/libjafs/Process.c +++ b/src/JAVA/libjafs/Process.c @@ -115,7 +115,7 @@ void getProcessInfoChar( JNIEnv *env, void *serverHandle, } // set state variable - auxStatus = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + auxStatus = malloc( sizeof(char)*BOS_MAX_NAME_LEN ); if( !auxStatus ) { throwAFSException( env, JAFSADMNOMEM ); return; diff --git a/src/JAVA/libjafs/Server.c b/src/JAVA/libjafs/Server.c index 0e9eb2c..0058965 100644 --- a/src/JAVA/libjafs/Server.c +++ b/src/JAVA/libjafs/Server.c @@ -516,7 +516,7 @@ Java_org_openafs_jafs_Server_getBosAdminCount (JNIEnv *env, jclass cls, return -1; } - admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN); + admin = malloc( sizeof(char)*BOS_MAX_NAME_LEN); if( !admin ) { throwAFSException( env, JAFSADMNOMEM ); @@ -578,7 +578,7 @@ Java_org_openafs_jafs_Server_getBosAdminsNextString (JNIEnv *env, afs_status_t ast; jstring jadmin; - char *admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + char *admin = malloc( sizeof(char)*BOS_MAX_NAME_LEN ); if( !admin ) { throwAFSException( env, JAFSADMNOMEM ); @@ -622,7 +622,7 @@ Java_org_openafs_jafs_Server_getBosAdminsNext (JNIEnv *env, jclass cls, char *admin; jstring jadmin; - admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN); + admin = malloc( sizeof(char)*BOS_MAX_NAME_LEN); if( !admin ) { throwAFSException( env, JAFSADMNOMEM ); @@ -821,7 +821,7 @@ Java_org_openafs_jafs_Server_getProcessCount (JNIEnv *env, jclass cls, return -1; } - process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + process = malloc( sizeof(char)*BOS_MAX_NAME_LEN ); if( !process ) { throwAFSException( env, JAFSADMNOMEM ); @@ -883,7 +883,7 @@ Java_org_openafs_jafs_Server_getProcessesNextString (JNIEnv *env, afs_status_t ast; jstring jprocess; - char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + char *process = malloc( sizeof(char)*BOS_MAX_NAME_LEN ); if( !process ) { throwAFSException( env, JAFSADMNOMEM ); @@ -925,7 +925,7 @@ Java_org_openafs_jafs_Server_getProcessesNext (JNIEnv *env, jclass cls, jobject jprocessObject) { afs_status_t ast; - char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + char *process = malloc( sizeof(char)*BOS_MAX_NAME_LEN ); jstring jprocess; if( !process ) { @@ -1539,7 +1539,7 @@ Java_org_openafs_jafs_Server_getLog(JNIEnv *env, jclass cls, logFile = NULL; } - logData = (char *) malloc( sizeof(char)*currInLogSize ); + logData = malloc( sizeof(char)*currInLogSize ); if( !logData ) { throwAFSException( env, JAFSADMNOMEM ); return; @@ -1564,7 +1564,7 @@ Java_org_openafs_jafs_Server_getLog(JNIEnv *env, jclass cls, // increase log size (plus one for terminator) currInLogSize = currOutLogSize + 1; // allocate buffer - logData = (char *) malloc( sizeof(char)*currInLogSize ); + logData = malloc( sizeof(char)*currInLogSize ); if( !logData ) { throwAFSException( env, JAFSADMNOMEM ); return; diff --git a/src/JAVA/libjafs/User.c b/src/JAVA/libjafs/User.c index 5e2abf8..70526fa 100644 --- a/src/JAVA/libjafs/User.c +++ b/src/JAVA/libjafs/User.c @@ -559,8 +559,7 @@ void getUserInfoChar kasEntry.lastModPrincipal.principal); (*env)->SetObjectField(env, user, user_lastModNameField, jlastModName); - convertedKey = (char *) malloc( sizeof(char *)* - (sizeof(kasEntry.key.key)*4+1) ); + convertedKey = malloc( sizeof(char *) * (sizeof(kasEntry.key.key)*4+1) ); if( !convertedKey ) { throwAFSException( env, JAFSADMNOMEM ); return; @@ -1171,7 +1170,7 @@ Java_org_openafs_jafs_User_getUserGroupsNextString (JNIEnv *env, jclass cls, jlong iterationId) { afs_status_t ast; - char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + char *groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); jstring jgroup; if( !groupName ) { @@ -1215,7 +1214,7 @@ Java_org_openafs_jafs_User_getUserGroupsNext char *groupName; jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -1290,7 +1289,7 @@ Java_org_openafs_jafs_User_getGroupsOwnedCount cellHandle, jname ); - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM ); @@ -1370,7 +1369,7 @@ Java_org_openafs_jafs_User_getGroupsOwnedNextString (JNIEnv *env, jclass cls, jlong iterationId) { afs_status_t ast; - char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + char *groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); jstring jgroup; if( !groupName ) { @@ -1415,7 +1414,7 @@ Java_org_openafs_jafs_User_getGroupsOwnedNext char *groupName; jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = malloc( sizeof(char)*PTS_MAX_NAME_LEN); if( !groupName ) { throwAFSException( env, JAFSADMNOMEM );