target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
static bool nmbm_check_header(const void *data, uint32_t size)
{
	const struct nmbm_header *header = data;
	struct nmbm_header nhdr;
	uint32_t new_checksum;

	/*
	 * Make sure expected structure size is equal or smaller than
	 * buffer size.
	 */
	if (header->size > size)
		return false;

	memcpy(&nhdr, data, sizeof(nhdr));

	nhdr.checksum = 0;
	new_checksum = nmbm_crc32(0, &nhdr, sizeof(nhdr));
	if (header->size > sizeof(nhdr))
		new_checksum = nmbm_crc32(new_checksum,
			(const uint8_t *)data + sizeof(nhdr),
			header->size - sizeof(nhdr));

	if (header->checksum != new_checksum)
		return false;

	return true;
}
/*
 * nmbm_check_header - Check whether a NMBM structure is valid
 * @data: pointer to a NMBM structure with a NMBM header at beginning
 * @size: Size of the buffer pointed by @header
 *
 * The size of the NMBM structure may be larger than NMBM header,
 * e.g. block mapping table and block state table.
 */
Check whether a NMBM structure is valid
@data: pointer to a NMBM structure with a NMBM header at beginning
@size: Size of the buffer pointed by @header

The size of the NMBM structure may be larger than NMBM header,
e.g. block mapping table and block state table.
Check whether a NMBM structure is valid @data : pointer to a NMBM structure with a NMBM header at beginning @size : Size of the buffer pointed by @header The size of the NMBM structure may be larger than NMBM header e . g . block mapping table and block state table .
static bool nmbm_check_header(const void *data, uint32_t size)
{
	const struct nmbm_header *header = data;
	struct nmbm_header nhdr;
	uint32_t new_checksum;
	if (header->size > size)
		return false;
	memcpy(&nhdr, data, sizeof(nhdr));
	nhdr.checksum = 0;
	new_checksum = nmbm_crc32(0, &nhdr, sizeof(nhdr));
	if (header->size > sizeof(nhdr))
		new_checksum = nmbm_crc32(new_checksum,
			(const uint8_t *)data + sizeof(nhdr),
			header->size - sizeof(nhdr));
	if (header->checksum != new_checksum)
		return false;
	return true;
}
static bool nmbm_check_header ( const void * data , uint32_t size ) { const struct nmbm_header * header = data ; struct nmbm_header nhdr ; uint32_t new_checksum ; if ( header -> size > size ) return false ; memcpy ( & nhdr , data , sizeof ( nhdr ) ) ; nhdr . checksum = 0 ; new_checksum = nmbm_crc32 ( 0 , & nhdr , sizeof ( nhdr ) ) ; if ( header -> size > sizeof ( nhdr ) ) new_checksum = nmbm_crc32 ( new_checksum , ( const uint8_t * ) data + sizeof ( nhdr ) , header -> size - sizeof ( nhdr ) ) ; if ( header -> checksum != new_checksum ) return false ; return true ; }
nmbm_check_header - Check whether a NMBM structure is valid
 @data: pointer to a NMBM structure with a NMBM header at beginning
 @size: Size of the buffer pointed by @header
nmbm_check_header - Check whether a NMBM structure is valid @data : pointer to a NMBM structure with a NMBM header at beginning @size : Size of the buffer pointed by @header
/*
	 * Make sure expected structure size is equal or smaller than
	 * buffer size.
	 */