This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit d4d513a709b77bb4c22122bef0a6e3236e6af10d
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Fri Mar 3 12:48:54 2023 +0100

    flashmap: Add #define for number of areas
---
 newt/flashmap/flashmap.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go
index 5e0dd0c8..517ad720 100644
--- a/newt/flashmap/flashmap.go
+++ b/newt/flashmap/flashmap.go
@@ -228,8 +228,7 @@ func Read(ymlFlashMap map[string]interface{}, pkgName 
string) (FlashMap, error)
 }
 
 func flashMapVarDecl(fm FlashMap) string {
-       return fmt.Sprintf("const struct flash_area %s[%d]", C_VAR_NAME,
-               len(fm.Areas))
+       return fmt.Sprintf("const struct flash_area %s[FLASH_AREA_COUNT]", 
C_VAR_NAME)
 }
 
 func writeFlashAreaHeader(w io.Writer, area flash.FlashArea) {
@@ -248,6 +247,8 @@ func writeFlashMapHeader(w io.Writer, fm FlashMap) {
        fmt.Fprintf(w, "\n")
        fmt.Fprintf(w, "#include \"flash_map/flash_map.h\"\n")
        fmt.Fprintf(w, "\n")
+       fmt.Fprintf(w, "#define FLASH_AREA_COUNT %d\n", len(fm.Areas))
+       fmt.Fprintf(w, "\n")
        fmt.Fprintf(w, "%s", C_VAR_COMMENT)
        fmt.Fprintf(w, "extern %s;\n", flashMapVarDecl(fm))
        fmt.Fprintf(w, "\n")

Reply via email to