From 287ba1888b3dc95d805d054c5c9f2d1dd231a1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Tue, 8 Nov 2011 21:45:47 +0100 Subject: [PATCH] stm32f1x: add more asserts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this at least checks the post conditions after convoluted code. Change-Id: Idfa8cbedce5288d8bae5743687949f141dfb07b2 Signed-off-by: Øyvind Harboe Reviewed-on: http://openocd.zylin.com/187 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- src/flash/nor/stm32f1x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c index 6c419e922..0678ce36d 100644 --- a/src/flash/nor/stm32f1x.c +++ b/src/flash/nor/stm32f1x.c @@ -1107,9 +1107,15 @@ static int stm32x_probe(struct flash_bank *bank) LOG_INFO("flash size = %dkbytes", num_pages); + /* did we assign # of pages? */ + assert(num_pages != 0xffff); + /* calculate numbers of pages */ num_pages /= (page_size / 1024); + /* check that calculation result makes sense */ + assert(num_pages > 0); + if (bank->sectors) { free(bank->sectors);