From c7fcdf968d797488f9aae8ed8255a66a1ec2b74d Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Wed, 31 May 2017 09:07:25 -0600 Subject: [PATCH] mtd/smart: Fix use of uninitialized variable --- drivers/mtd/smart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index c5c6e80a3e..e483bc99d3 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -1368,7 +1368,8 @@ static int smart_add_sector_to_cache(FAR struct smart_struct_s *dev, index = 1; if (dev->cache_entries < CONFIG_MTD_SMART_SECTOR_CACHE_SIZE) { - index = dev->cache_entries++; + oldest = 0; + index = dev->cache_entries++; } else { @@ -1387,7 +1388,7 @@ static int smart_add_sector_to_cache(FAR struct smart_struct_s *dev, if (dev->sCache[x].birth < oldest) { oldest = dev->sCache[x].birth; - index = x; + index = x; } } }