mirror of
https://git.openafs.org/openafs.git
synced 2025-01-20 16:00:12 +00:00
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 <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
parent
cfcb45d4ae
commit
25bc7849ca
@ -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;
|
||||
|
@ -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 );
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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 ) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user