iPXE
Defines | Functions | Variables
assert.h File Reference

Assertions. More...

Go to the source code of this file.

Defines

#define ASSERTED   ( ASSERTING && ( assertion_failures != 0 ) )
#define assert(condition)
 Assert a condition at run-time.
#define linker_assert(condition, error_symbol)
 Assert a condition at link-time.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int __attribute__ ((format(printf, 1, 2))) assert_printf(const char *fmt
 printf() for assertions
int asm ("printf")

Variables

unsigned int assertion_failures
 Number of assertion failures triggered.

Detailed Description

Assertions.

This file provides two assertion macros: assert() (for run-time assertions) and linker_assert() (for link-time assertions).

Definition in file assert.h.


Define Documentation

#define ASSERTED   ( ASSERTING && ( assertion_failures != 0 ) )

Definition at line 25 of file assert.h.

Referenced by free(), malloc(), realloc(), and zalloc().

#define assert (   condition)
Value:
do {                                                                 \
                if ( ASSERTING && ! (condition) ) {                          \
                        assertion_failures++;                                \
                        assert_printf ( "assert(%s) failed at %s line %d\n", \
                                        #condition, __FILE__, __LINE__ );    \
                }                                                            \
        } while ( 0 )

Assert a condition at run-time.

If the condition is not true, a debug message will be printed. Assertions only take effect in debug-enabled builds (see DBG()).

Todo:
Make an assertion failure abort the program

Definition at line 49 of file assert.h.

Referenced by _print_label(), a3c90x_internal_ReadEeprom(), acm_transmit(), aes_decrypt(), aes_encrypt(), alloc_iob_raw(), alloc_memblock(), ansicol_set(), ansicol_set_pair(), aoecmd_ata_cmd(), aoecmd_cfg_cmd(), aoecmd_free(), aoecmd_tx(), arbel_alloc_icm(), arbel_close(), arbel_cmd(), arbel_complete(), arbel_map_vpm(), arbel_post_send(), arbel_start_firmware(), asn1_okx(), atadev_read_capacity(), ath5k_handle_rx(), axge_in_complete(), bigint_mod_multiply_raw(), bios_ansi_seq(), bios_handle_ed(), blktrans_xferbuf_read(), blktrans_xferbuf_write(), block_translate(), bzimage_exec(), cachedhcp_init(), cbc_decrypt(), cbc_encrypt(), cbc_xor(), chap_init(), chap_respond(), chap_update(), check_blocks(), cipher_cost(), cms_test_exec(), cms_verify_signer_info(), com32_exec_loop(), comboot_exec_loop(), concat_args(), deflate_accumulate(), deflate_bin(), deflate_consume(), deflate_inflate(), deflate_init(), der_probe(), dhcp_create_request(), dhcpv6_rx(), dhcpv6_tx(), dns_xfer_deliver(), drbg_generate(), drbg_instantiate(), drbg_reseed(), drbg_uninstantiate(), ecb_decrypt(), ecb_encrypt(), ecm_probe(), edit_setting(), eepro_transmit(), efab_fill_rx_queue(), efab_receive(), efab_transmit(), efab_transmit_done(), efi_bofm_start(), efi_bofm_stop(), efi_driver_stop(), efi_file_install(), efi_handle_ed(), efi_image_exec(), efi_local_open_path(), efi_local_step(), efi_pxe_udp_deliver(), efi_snp_add_claim(), efi_snp_set_mode(), efi_urealloc(), efi_usb_close(), efi_usb_probe(), efi_usb_remove(), efi_usb_sync_transfer(), efifb_glyphs(), efx_hunt_alloc_special_buffer(), efx_hunt_receive(), efx_hunt_rxq_fill(), efx_hunt_transmit(), efx_hunt_transmit_done(), ehci_bus_close(), ehci_bus_open(), ehci_bus_poll(), ehci_dequeue(), ehci_device_address(), ehci_endpoint_capabilities(), ehci_endpoint_message(), ehci_endpoint_reset(), ehci_enqueue(), ehci_remove(), ehci_ring_fill(), ehci_ring_free(), ena_refill_rx(), eoib_transmit(), exanic_expired(), exanic_i2c_read_bit(), exanic_i2c_write_bit(), exanic_probe_port(), expand_tokens(), falcon_alloc_special_buffer(), falcon_mdio_read(), falcon_mdio_write(), falcon_spi_rw(), fbcon_handle_ed(), fbcon_init(), fbcon_scroll(), fc_els_free(), fc_els_step(), fc_peer_close(), fc_peer_decrement(), fc_peer_examine(), fc_peer_login(), fc_ulp_attach(), fc_ulp_close(), fc_ulp_login(), fc_xchg_free(), fcoe_expired(), fcpcmd_recv_rddata(), fcpcmd_send_cmnd(), fcpcmd_send_wrdata(), fcpdev_identify_device(), fcpdev_scsi_command(), fetch_setting_alloc(), fetchf_setting(), fetchf_setting_copy(), fetchn_setting(), find_smbios_entry(), find_smbios_structure(), flexboot_nodnic_complete(), flexboot_nodnic_post_send(), format_busdevfn_setting(), free_iob(), free_memblock(), free_usb(), free_usb_bus(), free_usb_hub(), gdbserial_recv(), gdbudp_ensure_netdev_open(), generic_settings_clear(), golan_complete(), golan_provide_pages(), guestinfo_fetch_type(), guestrpc_command(), hash_df(), hermon_close(), hermon_cmd(), hermon_complete(), hermon_map_icm(), hermon_map_vpm(), hermon_mod_stat_cfg(), hermon_post_send(), hermon_set_port_type(), hermon_start_firmware(), hide_umalloc(), history_append(), history_cleanup(), history_free(), hmac_drbg_generate(), hmac_drbg_instantiate(), hmac_drbg_reseed(), hmac_drbg_update(), hmac_drbg_update_key(), hmac_drbg_update_value(), http_block_read(), http_conn_close(), http_connect(), http_format_basic_auth(), http_format_digest_auth(), http_format_ntlm_auth(), http_init_transfer_chunked(), http_open_post_uri(), http_parse_headers(), http_rx_chunk_data(), http_transfer_complete(), http_tx_request(), hub_remove(), hunt_mcdi_copyin(), hv_post_message(), hv_wait_for_message(), hvm_ioremap(), ib_destroy_cq(), ib_destroy_qp(), ib_mcast_attach(), ib_mcast_detach(), ib_mcast_join(), ib_mcast_leave(), ib_mi_send(), ib_open(), ib_pull(), ibft_fill_target_chap(), ibft_fill_target_reverse_chap(), ibft_install(), icm_align(), icplus_read_eeprom(), icplus_refill_rx(), image_asn1(), image_exec(), image_replace(), init_i2c_bit_basher(), init_spi_bit_basher(), initrd_swap(), insert_delete(), int13_device_path_info(), int13_guess_geometry(), int22(), intel_read_eeprom(), intel_refill_rx(), intelvf_mbox_msg(), intelxl_refill_rx(), iob_pad(), iob_pull(), iob_split(), ioremap_pages(), iounmap_pages(), ipv6_add_miniroute(), iscsi_build_login_request_strings(), iscsi_fetch_settings(), iscsi_open_connection(), iscsi_rx_buffered_data(), iscsi_rx_data_in(), iscsi_scsi_done(), iscsi_socket_deliver(), iscsi_start_command(), iscsi_start_login(), iscsi_start_tx(), iscsi_tx_data_out(), iscsi_tx_step(), jump_scroll(), jump_scroll_key(), jump_scroll_move(), last_opened_ibdev(), last_opened_netdev(), linda_complete_recv(), linda_complete_send(), linda_ib_epb_mod_reg(), linda_ib_epb_ram_xfer(), linda_post_recv(), linda_post_send(), line_buffer(), longjmp_okx(), main_loop(), md4_digest(), md4_final(), md5_digest(), md5_final(), memcpy_test_speed(), menu_loop(), myson_refill_rx(), natsemi_refill_rx(), nbi_process_segments(), ncm_probe(), ndp_register_settings(), neighbour_free(), net80211_change_channel(), net80211_mgmt_dequeue(), net80211_prepare_assoc(), net80211_prepare_probe(), net80211_probe_start(), net80211_set_rate_idx(), netdev_fetch_bustype(), netdev_tx_flush(), netfront_create_ring(), netfront_open(), netfront_pull(), netfront_push(), netvsc_create_ring(), netvsc_destroy_ring(), netvsc_transmit(), nii_get_init_info(), nii_poll_tx(), numerate_int_setting(), nvs_read(), nvs_write(), ocsp_check(), ocsp_validate(), parse_fc_port(), parse_fc_port_id(), parse_gdb_transport(), parse_integer(), parse_netdev(), parse_netdev_configurator(), parse_setting(), parse_settings(), parse_string(), pci_vpd_resize(), peerblk_decrypt(), peerblk_expired(), peerblk_parse_block(), peerblk_parse_header(), peerblk_reset(), peerdisc_destroy(), peerdisc_open(), peerdist_discovery_reply_values(), peerdist_info(), peerdist_info_block(), peerdist_info_hash_ntoa(), peerdist_info_passphrase_okx(), peerdist_info_segment(), peerdist_info_segment_hash(), peerdist_info_v1(), peerdist_info_v1_block(), peerdist_info_v1_block_offset(), peerdist_info_v1_segment(), peerdist_info_v2(), peerdist_info_v2_block(), peerdist_info_v2_segment(), peermux_block_deliver(), pem_asn1(), pem_marker(), phantom_clp_cmd(), phantom_crb_access_128m(), phantom_crb_access_2m(), phantom_crb_access_32m(), phantom_dmesg(), phantom_fetch_setting(), phantom_poll(), phantom_probe(), phantom_refill_rx_ring(), phantom_store_setting(), phantom_transmit(), ping_rx(), pit8254_speaker_delay(), pixbuf_okx(), png_interlace(), png_pixels(), png_pixels_pass(), png_unfilter(), png_unfilter_pass(), pnm_type(), pool_add(), pool_expired(), profile_update(), pxe_fake_cached_info(), pxe_menu_boot(), pxe_netdev_close(), pxe_netdev_open(), pxe_udp_deliver(), pxenv_udp_read(), pxenv_undi_get_information(), qib7322_ahb_mod_reg(), qib7322_complete_recv(), qib7322_complete_send(), qib7322_post_recv(), qib7322_post_send(), qib7322_probe(), read_smbios_string(), read_smbios_structure(), read_user(), readline_history(), realloc(), realtek_refill_rx(), register_settings(), register_usb(), register_usb_bus(), reparse_options(), rfc_tcpip_chksum(), rndis_tx_defer(), rsa_encode_digest(), rtc_unhook_isr(), run_tests(), sandev_command(), sandev_command_read_capacity(), sandev_command_rw(), sandev_free(), sandev_reopen(), save_setting(), sdi_exec(), sha1_digest(), sha1_final(), sha256_digest(), sha256_final(), sha512_digest(), sha512_final(), show_menu(), shuffle(), skge_up(), skge_xmit_frame(), sky2_status_intr(), sky2_tx_complete(), slam_parse_multicast_address(), slam_pull_header(), slam_put_value(), smbios_version(), spi_bit_rw(), srp_open(), srpcmd_free(), storef_setting(), storen_setting(), tcp_close(), tcp_expired(), tcp_rx_opts(), tcp_rx_seq(), tcp_wait_expired(), tcp_xmit_sack(), tcpip_random_okx(), test_ok(), tg3_rx_complete(), threewire_read(), threewire_write(), timer_expired(), tls_cipherstream_deliver(), tls_generate_keys(), tls_newdata_process_data(), tls_newdata_process_header(), tls_restart(), tls_set_cipher(), tls_split_stream(), tls_validator_done(), txnic_complete_sqe(), txnic_lmac_probe(), txnic_lmac_probe_all(), txnic_lmac_remove(), txnic_lmac_remove_all(), txnic_refill_rq(), uhci_bus_close(), uhci_bus_open(), uhci_dequeue(), uhci_device_address(), uhci_endpoint_message(), uhci_endpoint_poll(), uhci_endpoint_stream(), uhci_enqueue(), uhci_remove(), uhci_restart(), uhci_ring_fill(), uhci_ring_free(), undinet_call(), undinet_hook_isr(), undinet_unhook_isr(), unregister_sandev(), unregister_usb(), unregister_usb_bus(), usb_attached(), usb_complete_err(), usb_control(), usb_deconfigure(), usb_describe(), usb_endpoint_close(), usb_endpoint_reset(), usb_flush(), usb_free_address(), usb_hotplug(), usb_message(), usb_prefill(), usb_probe_all(), usb_refill(), usb_remove_all(), usbio_close(), usbio_control_poll(), usbio_interfaces(), usbio_interrupt_callback(), usbio_interrupt_poll(), usbio_open(), usbkbd_consume(), usbkbd_fill(), validator_start_ocsp(), validator_xfer_close(), vmbus_open(), vmbus_poll(), vmbus_probe(), vmbus_remove_channels(), vmbus_send(), vmbus_send_cancellation(), vmbus_send_completion(), vmbus_send_control(), vmbus_send_data(), vmbus_xfer_page_iobufs(), vmxnet3_refill_rx(), vmxnet3_transmit(), vpm_ioread16(), vpm_ioread32(), vpm_ioread8(), vpm_iowrite16(), vpm_iowrite32(), vpm_iowrite8(), vxge_hw_device_terminate(), write_cmd(), x509_check_signature(), x509_test_exec(), xcm_free(), xengrant_alloc(), xengrant_free(), xenstore_request(), xhci_abort(), xhci_address_device_input(), xhci_bus_close(), xhci_command_free(), xhci_complete(), xhci_dcbaa_free(), xhci_dequeue(), xhci_device_open(), xhci_endpoint_message(), xhci_endpoint_open(), xhci_enqueue(), xhci_enqueue_multi(), xhci_init(), xhci_port_status(), xhci_ring_alloc(), xhci_ring_free(), xhci_ring_remaining(), xhci_scratchpad_alloc(), xhci_scratchpad_free(), xhci_transfer(), and xsigo_free().

#define linker_assert (   condition,
  error_symbol 
)
Value:
if ( ! (condition) ) {                          \
                extern void error_symbol ( void );      \
                error_symbol();                         \
        }

Assert a condition at link-time.

If the condition is not true, the link will fail with an unresolved symbol (error_symbol).

This macro is iPXE-specific. Do not use this macro in code intended to be portable.

Definition at line 68 of file assert.h.

Referenced by __attribute__(), aoecmd_ata_cmd(), arbel_mad(), asn1_built(), hermon_mad(), linda_init_recv(), linda_post_recv(), md4_digest(), md5_digest(), qib7322_init_recv(), qib7322_post_recv(), script_probe(), sha1_digest(), sha256_digest(), and sha512_digest().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int __attribute__ ( (format(printf, 1, 2))  ) const

printf() for assertions

This function exists so that the assert() macro can expand to printf() calls without dragging the printf() prototype into scope.

As far as the compiler is concerned, assert_printf() and printf() are completely unrelated calls; it's only at the assembly stage that references to the assert_printf symbol are collapsed into references to the printf symbol.

int asm ( "printf"  )

Variable Documentation

unsigned int assertion_failures

Number of assertion failures triggered.

Definition at line 35 of file assert.c.

Referenced by run_tests().