kasjer commented on a change in pull request #2073: sys/flash_map: Keep non-overlapping default areas URL: https://github.com/apache/mynewt-core/pull/2073#discussion_r339805247
########## File path: sys/flash_map/src/flash_map.c ########## @@ -406,6 +406,84 @@ flash_map_read_mfg(int max_areas, } } +/** + * Determines if the specified flash area overlaps any areas in the flash map. + * + * @param area1 The flash area to compare against the flash + * map. + * + * @return True if there is an overlap; false otherwise. + */ +static bool +flash_map_area_overlaps(const struct flash_area *area1) +{ + const struct flash_area *area2; + uint32_t end1; + uint32_t end2; + int i; + + for (i = 0; i < flash_map_entries; i++) { + area2 = &flash_map[i]; + + if (area1->fa_device_id == area2->fa_device_id) { + end1 = area1->fa_off + area1->fa_size; + end2 = area2->fa_off + area2->fa_size; + + if (end1 >= area2->fa_off && area1->fa_off < end2) { Review comment: shouldn't > be used in first conditions? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services