parent 3aa147f8d20bc5124dca1f4746da678a55247b82 (tevent-0-9-8-709-g3aa147f) commit 15e68f1627e3935351643d322d53d8c0925e0db8 Author: Jan Engelhardt Date: Fri Sep 25 10:11:13 2009 +0200 mount.cifs: remove redundant casts Signed-off-by: Jan Engelhardt --- client/mount.cifs.c | 38 +++++++++++++++++++------------------- client/umount.cifs.c | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/client/mount.cifs.c b/client/mount.cifs.c index 1c04e13..16ae4b4 100644 --- a/client/mount.cifs.c +++ b/client/mount.cifs.c @@ -323,7 +323,7 @@ static int open_cred_file(char * file_name) fs = fopen(file_name,"r"); if(fs == NULL) return errno; - line_buf = (char *)malloc(4096); + line_buf = malloc(4096); if(line_buf == NULL) { fclose(fs); return ENOMEM; @@ -356,7 +356,7 @@ static int open_cred_file(char * file_name) exit(EX_USAGE); } else { got_user = 1; - user_name = (char *)calloc(1 + length,1); + user_name = calloc(1 + length,1); /* BB adding free of user_name string before exit, not really necessary but would be cleaner */ strlcpy(user_name,temp_val, length+1); @@ -380,7 +380,7 @@ static int open_cred_file(char * file_name) exit(EX_USAGE); } else { if(mountpassword == NULL) { - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); } else memset(mountpassword,0,MOUNT_PASSWD_SIZE); if(mountpassword) { @@ -408,7 +408,7 @@ static int open_cred_file(char * file_name) exit(EX_USAGE); } else { if(domain_name == NULL) { - domain_name = (char *)calloc(DOMAIN_SIZE+1,1); + domain_name = calloc(DOMAIN_SIZE+1,1); } else memset(domain_name,0,DOMAIN_SIZE); if(domain_name) { @@ -432,7 +432,7 @@ static int get_password_from_file(int file_descript, char * filename) char c; if(mountpassword == NULL) - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); else memset(mountpassword, 0, MOUNT_PASSWD_SIZE); @@ -560,7 +560,7 @@ static int parse_options(char ** optionsp, unsigned long * filesys_flags) if(percent_char) { *percent_char = ','; if(mountpassword == NULL) - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); if(mountpassword) { if(got_password) fprintf(stderr, "\nmount.cifs warning - password specified twice\n"); @@ -769,7 +769,7 @@ static int parse_options(char ** optionsp, unsigned long * filesys_flags) } else if (strncmp(data, "exec", 4) == 0) { *filesys_flags &= ~MS_NOEXEC; } else if (strncmp(data, "guest", 5) == 0) { - user_name = (char *)calloc(1, 1); + user_name = calloc(1, 1); got_user = 1; got_password = 1; } else if (strncmp(data, "ro", 2) == 0) { @@ -806,7 +806,7 @@ static int parse_options(char ** optionsp, unsigned long * filesys_flags) if (value) word_len += 1 + strlen(value); - out = (char *)realloc(out, out_len + word_len + 2); + out = realloc(out, out_len + word_len + 2); if (out == NULL) { perror("malloc"); exit(EX_SYSERR); @@ -831,7 +831,7 @@ nocopy: if (got_uid) { word_len = strlen(user); - out = (char *)realloc(out, out_len + word_len + 6); + out = realloc(out, out_len + word_len + 6); if (out == NULL) { perror("malloc"); exit(EX_SYSERR); @@ -847,7 +847,7 @@ nocopy: if (got_gid) { word_len = strlen(group); - out = (char *)realloc(out, out_len + 1 + word_len + 6); + out = realloc(out, out_len + 1 + word_len + 6); if (out == NULL) { perror("malloc"); exit(EX_SYSERR); @@ -895,7 +895,7 @@ static void check_for_comma(char ** ppasswrd) return; } - new_pass_buf = (char *)malloc(len+number_of_commas+1); + new_pass_buf = malloc(len+number_of_commas+1); if(new_pass_buf == NULL) return; @@ -959,7 +959,7 @@ static char * check_for_domain(char **ppuser) len = strlen(domainnm); /* reset domainm to new buffer, and copy domain name into it */ - domainnm = (char *)malloc(len+1); + domainnm = malloc(len+1); if(domainnm == NULL) return NULL; @@ -1031,7 +1031,7 @@ parse_server(char ** punc_name) /* check for nfs syntax ie server:share */ share = strchr(unc_name,':'); if(share) { - *punc_name = (char *)malloc(length+3); + *punc_name = malloc(length+3); if(*punc_name == NULL) { /* put the original string back if no memory left */ @@ -1336,7 +1336,7 @@ int main(int argc, char ** argv) break; case 'p': if(mountpassword == NULL) - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); if(mountpassword) { got_password = 1; strlcpy(mountpassword,optarg,MOUNT_PASSWD_SIZE+1); @@ -1378,7 +1378,7 @@ int main(int argc, char ** argv) if (getenv("PASSWD")) { if(mountpassword == NULL) - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); if(mountpassword) { strlcpy(mountpassword,getenv("PASSWD"),MOUNT_PASSWD_SIZE+1); got_password = 1; @@ -1422,7 +1422,7 @@ int main(int argc, char ** argv) } /* BB save off path and pop after mount returns? */ - resolved_path = (char *)malloc(PATH_MAX+1); + resolved_path = malloc(PATH_MAX+1); if(resolved_path) { /* Note that if we can not canonicalize the name, we get another chance to see if it is valid when we chdir to it */ @@ -1444,7 +1444,7 @@ int main(int argc, char ** argv) if(got_password == 0) { char *tmp_pass = getpass("Password: "); /* BB obsolete sys call but no good replacement yet. */ - mountpassword = (char *)calloc(MOUNT_PASSWD_SIZE+1,1); + mountpassword = calloc(MOUNT_PASSWD_SIZE+1,1); if (!tmp_pass || !mountpassword) { fprintf(stderr, "Password not entered, exiting\n"); exit(EX_USAGE); @@ -1474,7 +1474,7 @@ int main(int argc, char ** argv) mount_retry: SAFE_FREE(options); options_size = optlen + 10 + DOMAIN_SIZE; - options = (char *)malloc(options_size /* space for commas in password */ + 8 /* space for domain= , domain name itself was counted as part of the length username string above */); + options = malloc(options_size /* space for commas in password */ + 8 /* space for domain= , domain name itself was counted as part of the length username string above */); if(options == NULL) { fprintf(stderr, "Could not allocate memory for mount options\n"); @@ -1614,7 +1614,7 @@ mount_retry: mountent.mnt_fsname = dev_name; mountent.mnt_dir = mountpoint; mountent.mnt_type = CONST_DISCARD(char *,"cifs"); - mountent.mnt_opts = (char *)malloc(220); + mountent.mnt_opts = malloc(220); if(mountent.mnt_opts) { char * mount_user = getusername(); memset(mountent.mnt_opts,0,200); diff --git a/client/umount.cifs.c b/client/umount.cifs.c index 35563c1..01f8200 100644 --- a/client/umount.cifs.c +++ b/client/umount.cifs.c @@ -252,7 +252,7 @@ canonicalize(char *path) return NULL; } - canonical = (char *)malloc (PATH_MAX + 1); + canonical = malloc (PATH_MAX + 1); if (!canonical) { fprintf(stderr, "Error! Not enough memory!\n"); -- # Created with git-export-patch