Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 177acf78 authored by Alan Cox's avatar Alan Cox Committed by Michal Marek
Browse files

kconfig: Fix malloc handling in conf tools



(and get them out of the noise in the audit work)

Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 9a926d43
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

struct expr *expr_alloc_symbol(struct symbol *sym)
{
	struct expr *e = calloc(1, sizeof(*e));
	struct expr *e = xcalloc(1, sizeof(*e));
	e->type = E_SYMBOL;
	e->left.sym = sym;
	return e;
@@ -21,7 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym)

struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
{
	struct expr *e = calloc(1, sizeof(*e));
	struct expr *e = xcalloc(1, sizeof(*e));
	e->type = type;
	e->left.expr = ce;
	return e;
@@ -29,7 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)

struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
{
	struct expr *e = calloc(1, sizeof(*e));
	struct expr *e = xcalloc(1, sizeof(*e));
	e->type = type;
	e->left.expr = e1;
	e->right.expr = e2;
@@ -38,7 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e

struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
{
	struct expr *e = calloc(1, sizeof(*e));
	struct expr *e = xcalloc(1, sizeof(*e));
	e->type = type;
	e->left.sym = s1;
	e->right.sym = s2;
@@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org)
	if (!org)
		return NULL;

	e = malloc(sizeof(*org));
	e = xmalloc(sizeof(*org));
	memcpy(e, org, sizeof(*org));
	switch (org->type) {
	case E_SYMBOL:
+2 −0
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@ void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
void *xmalloc(size_t size);
void *xcalloc(size_t nmemb, size_t size);

struct gstr {
	size_t len;
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
{
	struct menu *menu;

	menu = malloc(sizeof(*menu));
	menu = xmalloc(sizeof(*menu));
	memset(menu, 0, sizeof(*menu));
	menu->sym = sym;
	menu->parent = current_menu;
@@ -531,7 +531,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
			location = menu;
	}
	if (head && location) {
		jump = malloc(sizeof(struct jump_key));
		jump = xmalloc(sizeof(struct jump_key));

		if (menu_is_visible(prop->menu)) {
			/*
+6 −6
Original line number Diff line number Diff line
@@ -656,11 +656,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
	size = strlen(newval) + 1;
	if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
		size += 2;
		sym->def[S_DEF_USER].val = val = malloc(size);
		sym->def[S_DEF_USER].val = val = xmalloc(size);
		*val++ = '0';
		*val++ = 'x';
	} else if (!oldval || strcmp(oldval, newval))
		sym->def[S_DEF_USER].val = val = malloc(size);
		sym->def[S_DEF_USER].val = val = xmalloc(size);
	else
		return true;

@@ -812,7 +812,7 @@ struct symbol *sym_lookup(const char *name, int flags)
		hash = 0;
	}

	symbol = malloc(sizeof(*symbol));
	symbol = xmalloc(sizeof(*symbol));
	memset(symbol, 0, sizeof(*symbol));
	symbol->name = new_name;
	symbol->type = S_UNKNOWN;
@@ -863,7 +863,7 @@ const char *sym_expand_string_value(const char *in)
	size_t reslen;

	reslen = strlen(in) + 1;
	res = malloc(reslen);
	res = xmalloc(reslen);
	res[0] = '\0';

	while ((src = strchr(in, '$'))) {
@@ -921,7 +921,7 @@ const char *sym_escape_string_value(const char *in)
		p++;
	}

	res = malloc(reslen);
	res = xmalloc(reslen);
	res[0] = '\0';

	strcat(res, "\"");
@@ -1228,7 +1228,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
	struct property *prop;
	struct property **propp;

	prop = malloc(sizeof(*prop));
	prop = xmalloc(sizeof(*prop));
	memset(prop, 0, sizeof(*prop));
	prop->type = type;
	prop->sym = sym;
+21 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ struct file *file_lookup(const char *name)
		}
	}

	file = malloc(sizeof(*file));
	file = xmalloc(sizeof(*file));
	memset(file, 0, sizeof(*file));
	file->name = file_name;
	file->next = file_list;
@@ -81,7 +81,7 @@ int file_write_dep(const char *name)
struct gstr str_new(void)
{
	struct gstr gs;
	gs.s = malloc(sizeof(char) * 64);
	gs.s = xmalloc(sizeof(char) * 64);
	gs.len = 64;
	gs.max_width = 0;
	strcpy(gs.s, "\0");
@@ -138,3 +138,22 @@ const char *str_get(struct gstr *gs)
	return gs->s;
}

void *xmalloc(size_t size)
{
	void *p = malloc(size);
	if (p)
		return p;
	fprintf(stderr, "Out of memory.\n");
	exit(1);
}

void *xcalloc(size_t nmemb, size_t size)
{
	void *p = calloc(nmemb, size);
	if (p)
		return p;
	fprintf(stderr, "Out of memory.\n");
	exit(1);
}

Loading