Skip to contentSkip to conversation

mm: memcontrol: uninitialized "ret" variables

PATCH In review Dan Carpenter 2 participants 2 messages Jan 22, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: memcontrol: uninitialized "ret" variables

We recently re-arranged the code in these functions and now static checkers complain that "ret" is uninitialized. Oddly enough GCC is fine with this code.

Fixes d1ebc463cf89 ('mm: page_counter: pull "-1" handling out of page_counter_memparse()')
mm/memcontrol.c +3 -2
index 323a01f..7af7834 100644
@@ -3422,7 +3422,7 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
 {
 	struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
 	unsigned long nr_pages;
-	int ret;
+	int ret = 0;
 
 	buf = strstrip(buf);
 	if (!strcmp(buf, "-1")) {
@@ -3799,7 +3799,8 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,
 	struct mem_cgroup_threshold_ary *new;
 	unsigned long threshold;
 	unsigned long usage;
-	int i, size, ret;
+	int i, size;
+	int ret = 0;
 
 	if (!strcmp(args, "-1")) {
 		threshold = PAGE_COUNTER_MAX;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#1 lore raw

Hi Dan,

Quoted 6 lines · Dan Carpenter

We recently re-arranged the code in these functions and now static checkers complain that "ret" is uninitialized. Oddly enough GCC is fine with this code.

Fixes d1ebc463cf89 ('mm: page_counter: pull "-1" handling out of page_counter_memparse()')

This code was again re-arranged in -mm, and that

ret = page_counter_memparse()

is now happening unconditionally, so I think it should be fine. The latest mmots snapshot (mmots-2015-01-21-16-38) has it.

Thanks!