diff --git a/src/util/argv.c b/src/util/argv.c index 54d4e8b814..b578d6777f 100644 --- a/src/util/argv.c +++ b/src/util/argv.c @@ -20,7 +20,7 @@ int ompi_argv_append(int *argc, char ***argv, const char *arg) /* Create new argv. */ if (NULL == *argv) { - *argv = malloc(2 * sizeof(char *)); + *argv = (char**) malloc(2 * sizeof(char *)); if (NULL == *argv) return OMPI_ERROR; *argc = 0; @@ -31,14 +31,14 @@ int ompi_argv_append(int *argc, char ***argv, const char *arg) /* Extend existing argv. */ else { - *argv = realloc(*argv, (*argc + 2) * sizeof(char *)); + *argv = (char**) realloc(*argv, (*argc + 2) * sizeof(char *)); if (NULL == *argv) return OMPI_ERROR; } /* Set the newest element to point to a copy of the arg string */ - (*argv)[*argc] = malloc(strlen(arg) + 1); + (*argv)[*argc] = (char*) malloc(strlen(arg) + 1); if (NULL == (*argv)[*argc]) return OMPI_ERROR; @@ -105,7 +105,7 @@ char **ompi_argv_split(const char *src_string, int delimiter) /* long argument, malloc buffer, copy and add */ else if (arglen > (ARGSIZE - 1)) { - argtemp = malloc(arglen + 1); + argtemp = (char*) malloc(arglen + 1); if (NULL == argtemp) return NULL; @@ -178,7 +178,7 @@ char *ompi_argv_join(char **argv, int delimiter) /* Allocate the string. */ - if (NULL == (str = malloc(str_len))) + if (NULL == (str = (char*) malloc(str_len))) return NULL; /* Loop filling in the string. */ @@ -326,8 +326,8 @@ int ompi_argv_insert(char ***target, int start, char **source) /* Alloc out new space */ - *target = realloc(*target, - sizeof(char *) * (target_count + source_count + 1)); + *target = (char**) realloc(*target, + sizeof(char *) * (target_count + source_count + 1)); /* Move suffix items down to the end */ diff --git a/src/util/bufpack.c b/src/util/bufpack.c index 19cc5bc864..195b1692d3 100644 --- a/src/util/bufpack.c +++ b/src/util/bufpack.c @@ -352,7 +352,8 @@ return (OMPI_SUCCESS); */ int ompi_pack(ompi_buffer_t buffer, void * src, size_t n, ompi_pack_type_t type) { - int i, rc; + int rc; + size_t i; void *dest; ompi_buffer_internal_t* bptr; size_t op_size=0; @@ -439,7 +440,7 @@ return (OMPI_SUCCESS); } break; case OMPI_STRING: - strncpy(dest, src, n); + strncpy((char*) dest, (char*) src, n); *((char *) dest + n - 1) = '\0'; break; case OMPI_NAME: @@ -478,9 +479,10 @@ return (OMPI_SUCCESS); * @retval OMPI_SUCCESS * @retval OMPI_ERROR */ - int ompi_unpack(ompi_buffer_t buffer, void * dest, size_t n, ompi_pack_type_t type) +int +ompi_unpack(ompi_buffer_t buffer, void * dest, size_t n, ompi_pack_type_t type) { - int i; + size_t i; void *src; ompi_buffer_internal_t* bptr; size_t op_size=0; @@ -555,7 +557,7 @@ return (OMPI_SUCCESS); } break; case OMPI_STRING: - strncpy(dest, src, n); + strncpy((char*) dest, (char*) src, n); *((char *) dest + n - 1) = '\0'; break; case OMPI_NAME: diff --git a/src/util/cmd_line.c b/src/util/cmd_line.c index a464793dd7..78e0e2b9a3 100644 --- a/src/util/cmd_line.c +++ b/src/util/cmd_line.c @@ -423,7 +423,7 @@ char *ompi_cmd_line_get_usage_msg(ompi_cmd_line_t *cmd) if (NULL != line) { free(line); } - line = malloc(len * 2); + line = (char*) malloc(len * 2); if (NULL == line) { ompi_mutex_unlock(&cmd->lcl_mutex); return NULL; diff --git a/src/util/if.c b/src/util/if.c index d7a63aba8e..1cc8a6d689 100644 --- a/src/util/if.c +++ b/src/util/if.c @@ -135,7 +135,7 @@ static int ompi_ifinit(void) } memcpy(&intf.if_mask, &ifr->ifr_addr, sizeof(intf.if_mask)); - intf_ptr = malloc(sizeof(ompi_if_t)); + intf_ptr = (ompi_if_t*) malloc(sizeof(ompi_if_t)); if(intf_ptr == 0) { ompi_output(0, "ompi_ifinit: unable to allocated %d bytes\n", sizeof(ompi_if_t)); return OMPI_ERR_OUT_OF_RESOURCE; diff --git a/src/util/numtostr.c b/src/util/numtostr.c index 1107b854e6..0bb43978ae 100644 --- a/src/util/numtostr.c +++ b/src/util/numtostr.c @@ -17,7 +17,7 @@ ompi_ltostr(long num) char *buf = NULL; int ret = 0; - buf = malloc(sizeof(char) * buflen); + buf = (char*) malloc(sizeof(char) * buflen); if (NULL == buf) return NULL; ret = snprintf(buf, buflen, "%ld", num); @@ -38,7 +38,7 @@ ompi_dtostr(double num) char *buf = NULL; int ret = 0; - buf = malloc(sizeof(char) * buflen); + buf = (char*) malloc(sizeof(char) * buflen); if (NULL == buf) return NULL; ret = snprintf(buf, buflen, "%f", num); diff --git a/src/util/output.c b/src/util/output.c index 4628c1671c..9817bad702 100644 --- a/src/util/output.c +++ b/src/util/output.c @@ -401,7 +401,7 @@ static int open_file(int i) dir = ompi_process_info.proc_session_dir; if (NULL != dir) { - filename = malloc(MAXPATHLEN); + filename = (char*) malloc(MAXPATHLEN); if (NULL == filename) { return OMPI_ERR_OUT_OF_RESOURCE; } @@ -519,7 +519,7 @@ static void output(int output_id, char *format, va_list arglist) if (NULL != temp_str) { free(temp_str); } - temp_str = malloc(total_len * 2); + temp_str = (char*) malloc(total_len * 2); temp_str_len = total_len * 2; } if (NULL != ldi->ldi_prefix) { diff --git a/src/util/path.c b/src/util/path.c index 90c141e465..4641be469d 100644 --- a/src/util/path.c +++ b/src/util/path.c @@ -82,7 +82,7 @@ ompi_path_findv(char *fname, char **pathv, int mode, char **envv) if (!delimit) { fullpath = path_access(fname, env, mode); } else { - pfix = malloc(strlen(env) + strlen(delimit) + 1); + pfix = (char*) malloc(strlen(env) + strlen(delimit) + 1); if (NULL == pfix){ return(0); } @@ -224,7 +224,7 @@ path_access(char *fname, char *path, int mode) /* * Allocate space for the full pathname. */ - fullpath = malloc(strlen(path) + strlen(fname) + 2); + fullpath = (char*) malloc(strlen(path) + strlen(fname) + 2); if (NULL == fullpath){ return(0); } diff --git a/src/util/printf.c b/src/util/printf.c index cc0d94790f..de8adec6d3 100644 --- a/src/util/printf.c +++ b/src/util/printf.c @@ -27,7 +27,7 @@ static int guess_strlen(const char *fmt, va_list ap) char *sarg; double darg; float farg; - int i; + size_t i; int iarg; int len; long larg; @@ -192,7 +192,7 @@ int ompi_vasprintf(char **ptr, const char *fmt, va_list ap) length = vsprintf(*ptr, fmt, ap); /* realloc */ - *ptr = realloc(*ptr, (size_t) length + 1); + *ptr = (char*) realloc(*ptr, (size_t) length + 1); if (NULL == *ptr) { errno = ENOMEM; return -1; diff --git a/src/util/show_help.c b/src/util/show_help.c index a4223d0746..7a319cf456 100644 --- a/src/util/show_help.c +++ b/src/util/show_help.c @@ -240,7 +240,7 @@ static int output(bool want_error_header, ompi_pointer_array_t *lines, len = want_error_header ? 2 * strlen(star_line) : 0; for (i = 0; i < ompi_pointer_array_get_size(lines); ++i) { - tmp = ompi_pointer_array_get_item(lines, i); + tmp = (char*) ompi_pointer_array_get_item(lines, i); if (NULL == tmp) { break; } @@ -249,7 +249,7 @@ static int output(bool want_error_header, ompi_pointer_array_t *lines, /* Malloc it out */ - concat = malloc(len + 1); + concat = (char*) malloc(len + 1); if (NULL == concat) { fprintf(stderr, star_line); fprintf(stderr, "Sorry! You were supposed to get help about:\n %s\nfrom the file:\n %s\n", topic, base); @@ -265,7 +265,7 @@ static int output(bool want_error_header, ompi_pointer_array_t *lines, strcat(concat, star_line); } for (i = 0; i < ompi_pointer_array_get_size(lines); ++i) { - tmp = ompi_pointer_array_get_item(lines, i); + tmp = (char*) ompi_pointer_array_get_item(lines, i); if (NULL == tmp) { break; } @@ -301,7 +301,7 @@ static int destroy_message(ompi_pointer_array_t *lines) char *tmp; for (i = 0; i < ompi_pointer_array_get_size(lines); ++i) { - tmp = ompi_pointer_array_get_item(lines, i); + tmp = (char*) ompi_pointer_array_get_item(lines, i); if (NULL == tmp) { break; } diff --git a/src/util/show_help_lex.l b/src/util/show_help_lex.l index fd55d14513..4e5beb6200 100644 --- a/src/util/show_help_lex.l +++ b/src/util/show_help_lex.l @@ -16,7 +16,13 @@ int ompi_show_help_finish_parsing(void); /* * local functions */ -static int ompi_show_help_yywrap(void); +#ifdef __cplusplus + extern "C" { +#endif + static int ompi_show_help_yywrap(void); +#ifdef __cplusplus + } +#endif /* * global variables diff --git a/src/util/strncpy.c b/src/util/strncpy.c index 8b48b33ba2..c2289ee3b9 100644 --- a/src/util/strncpy.c +++ b/src/util/strncpy.c @@ -31,7 +31,7 @@ char * ompi_strncpy(char *dest, const char *src, size_t len) { - int i; + size_t i; int pad = 0; char *new_dest = dest;