mirror of
https://github.com/ipxe/ipxe
synced 2025-12-20 12:00:19 +03:00
Assertions are now handled via the POSIX-like <assert.h>.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "string.h"
|
||||
#include "io.h"
|
||||
#include "errno.h"
|
||||
#include <assert.h>
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
@@ -208,7 +209,7 @@ int fill_buffer ( struct buffer *buffer, const void *data,
|
||||
/* Write back 'before' block, if any */
|
||||
if ( before.start ) {
|
||||
before.tail = 0;
|
||||
ASSERT ( ( before.end - before.start ) >=
|
||||
assert ( ( before.end - before.start ) >=
|
||||
sizeof ( struct buffer_free_block ) );
|
||||
store_free_block ( &before );
|
||||
} else {
|
||||
@@ -217,7 +218,7 @@ int fill_buffer ( struct buffer *buffer, const void *data,
|
||||
|
||||
/* Write back 'after' block, if any */
|
||||
if ( after.start < buffer->end ) {
|
||||
ASSERT ( after.tail ||
|
||||
assert ( after.tail ||
|
||||
( ( after.end - after.start ) >=
|
||||
sizeof ( struct buffer_free_block ) ) );
|
||||
store_free_block ( &after );
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "etherboot.h"
|
||||
#include "init.h"
|
||||
#include "memsizes.h"
|
||||
#include <assert.h>
|
||||
#include "heap.h"
|
||||
|
||||
struct heap_block {
|
||||
@@ -76,7 +77,7 @@ static void init_heap ( void ) {
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT ( size != 0 );
|
||||
assert ( size != 0 );
|
||||
DBG ( "HEAP using region [%x,%x)\n", heap_start, heap_end );
|
||||
heap_ptr = heap_end;
|
||||
}
|
||||
@@ -95,7 +96,7 @@ void * emalloc ( size_t size, unsigned int align ) {
|
||||
struct heap_block *block;
|
||||
physaddr_t addr;
|
||||
|
||||
ASSERT ( ( align & ( align - 1 ) ) == 0 );
|
||||
assert ( ( align & ( align - 1 ) ) == 0 );
|
||||
|
||||
addr = block_alloc_addr ( heap_ptr, size, align );
|
||||
if ( addr < heap_start ) {
|
||||
@@ -133,7 +134,7 @@ static inline physaddr_t block_free_addr ( size_t size ) {
|
||||
void efree ( void *ptr ) {
|
||||
struct heap_block *block;
|
||||
|
||||
ASSERT ( ptr == phys_to_virt ( heap_ptr + sizeof ( size_t ) ) );
|
||||
assert ( ptr == phys_to_virt ( heap_ptr + sizeof ( size_t ) ) );
|
||||
|
||||
block = ( struct heap_block * )
|
||||
( ptr - offsetof ( struct heap_block, data ) );
|
||||
@@ -142,7 +143,7 @@ void efree ( void *ptr ) {
|
||||
DBG ( "HEAP freed %x [%x,%x)\n", virt_to_phys ( ptr ),
|
||||
virt_to_phys ( block ), heap_ptr );
|
||||
|
||||
ASSERT ( heap_ptr <= heap_end );
|
||||
assert ( heap_ptr <= heap_end );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -199,7 +200,7 @@ void * erealloc ( void *ptr, size_t size ) {
|
||||
* already checked that there was sufficient space.
|
||||
*/
|
||||
ptr = emalloc ( size, old_align );
|
||||
ASSERT ( ptr != NULL );
|
||||
assert ( ptr != NULL );
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user