From: Øyvind Harboe Date: Tue, 8 Nov 2011 20:45:47 +0000 (+0100) Subject: stm32f1x: add more asserts X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=287ba1888b3dc95d805d054c5c9f2d1dd231a1b2;p=fw%2Fopenocd stm32f1x: add more asserts 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 --- 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);