stm32f1x: add more asserts
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 8 Nov 2011 20:45:47 +0000 (21:45 +0100)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Wed, 16 Nov 2011 23:29:53 +0000 (23:29 +0000)
this at least checks the post conditions after convoluted code.

Change-Id: Idfa8cbedce5288d8bae5743687949f141dfb07b2
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/187
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/stm32f1x.c

index 6c419e92223aea72dba1250e62f0fb6e4f8f86d1..0678ce36dc8641214df0696c32cd32c00b1a1f32 100644 (file)
@@ -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);