FreeCalypso > hg > freecalypso-sw
view loadtools/flutil.c @ 57:10996c267de4
loadtools old buglet: off by 1 error in the max-arguments logic in cmd parsing
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 24 Jun 2013 05:24:19 +0000 |
parents | d98137625c0d |
children | a10491da8c3a |
line wrap: on
line source
/* * Miscellaneous utility functions for flash support */ #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include "flash.h" extern struct flash_bank_info flash_bank_info[2]; compute_flash_totsize_nsecs(bank) { struct flash_bank_info *bi; struct flash_region_desc *reg; bi = flash_bank_info + bank; for (reg = bi->bank_desc->regions; reg->nsectors; reg++) { bi->nsectors += reg->nsectors; bi->total_size += reg->sector_size * reg->nsectors; } } /* the following function is used to verify that total_size is a power of 2 */ count_ones(word) uint32_t word; { int count; for (count = 0; word; word >>= 1) count += word & 1; return count; }