No need to cast malloc() return value.

This commit is contained in:
Todd C. Miller
2015-05-14 10:47:09 -06:00
parent c75eb5bf0d
commit cbcaaa299a
7 changed files with 10 additions and 11 deletions

View File

@@ -197,7 +197,7 @@ sudo_estrdup_v1(const char *src)
if (src != NULL) {
len = strlen(src);
dst = (char *) sudo_emalloc(len + 1);
dst = sudo_emalloc(len + 1);
(void) memcpy(dst, src, len);
dst[len] = '\0';
}
@@ -219,7 +219,7 @@ sudo_estrndup_v1(const char *src, size_t maxlen)
len++;
maxlen--;
}
dst = (char *) sudo_emalloc(len + 1);
dst = sudo_emalloc(len + 1);
(void) memcpy(dst, src, len);
dst[len] = '\0';
}

View File

@@ -370,7 +370,7 @@ xxxprintf(char **strp, size_t strsize, int alloc, const char *fmt0, va_list ap)
if (alloc && str >= estr) { \
char *t; \
strsize = (strsize << 1) + 1; \
if (!(t = (char *)realloc(*strp, strsize))) { \
if (!(t = realloc(*strp, strsize))) { \
free(str); \
*strp = NULL; \
ret = -1; \

View File

@@ -286,7 +286,7 @@ find_editor(int nfiles, char * const files[], char **argv_out[])
}
if (editor_path != editor)
free(editor);
nargv = (char **) malloc((nargc + 1 + nfiles + 1) * sizeof(char *));
nargv = malloc((nargc + 1 + nfiles + 1) * sizeof(char *));
if (nargv == NULL) {
sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n");
free(editor_path);

View File

@@ -110,7 +110,7 @@ sudo_rfc1938_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
/* Get space for new prompt with embedded challenge */
if (np_size < op_len + strlen(challenge) + 7) {
np_size = op_len + strlen(challenge) + 7;
new_prompt = (char *) sudo_erealloc(new_prompt, np_size);
new_prompt = sudo_erealloc(new_prompt, np_size);
}
if (def_long_otp_prompt)

View File

@@ -90,7 +90,7 @@ rbcreate(int (*compar)(const void *, const void*))
struct rbtree *tree;
debug_decl(rbcreate, SUDOERS_DEBUG_RBTREE)
tree = (struct rbtree *) sudo_emalloc(sizeof(*tree));
tree = sudo_emalloc(sizeof(*tree));
tree->compar = compar;
/*
@@ -185,7 +185,7 @@ rbinsert(struct rbtree *tree, void *data)
node = res < 0 ? node->left : node->right;
}
node = (struct rbnode *) sudo_emalloc(sizeof(*node));
node = sudo_emalloc(sizeof(*node));
node->data = data;
node->left = node->right = rbnil(tree);
node->parent = parent;

View File

@@ -236,7 +236,7 @@ main(int argc, char *argv[])
for (size = 0, from = argv; *from; from++)
size += strlen(*from) + 1;
user_args = (char *) sudo_emalloc(size);
user_args = sudo_emalloc(size);
for (to = user_args, from = argv; *from; from++) {
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args))

View File

@@ -116,7 +116,7 @@ fill_cmnd(const char *src, int len)
arg_len = arg_size = 0;
dst = sudoerslval.command.cmnd = (char *) malloc(len + 1);
dst = sudoerslval.command.cmnd = malloc(len + 1);
if (sudoerslval.command.cmnd == NULL) {
sudo_warn(NULL);
sudoerserror(NULL);
@@ -155,8 +155,7 @@ fill_args(const char *s, int len, int addspace)
;
p = sudoerslval.command.args ?
(char *) realloc(sudoerslval.command.args, arg_size) :
(char *) malloc(arg_size);
realloc(sudoerslval.command.args, arg_size) : malloc(arg_size);
if (p == NULL) {
sudo_efree(sudoerslval.command.args);
sudo_warn(NULL);