1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

Everywhere: Rename ASSERT => VERIFY

(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
This commit is contained in:
Andreas Kling 2021-02-23 20:42:32 +01:00
parent b33a6a443e
commit 5d180d1f99
725 changed files with 3448 additions and 3448 deletions

View file

@ -70,7 +70,7 @@ static void read_samples_from_stream(InputMemoryStream& stream, SampleReader rea
}
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -127,13 +127,13 @@ RefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream& stream, ResampleHelper
read_samples_from_stream(stream, read_norm_sample_24, fdata, resampler, num_channels);
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
// We should handle this in a better way above, but for now --
// just make sure we're good. Worst case we just write some 0s where they
// don't belong.
ASSERT(!stream.handle_any_error());
VERIFY(!stream.handle_any_error());
return Buffer::create_with_samples(move(fdata));
}

View file

@ -174,7 +174,7 @@ bool WavLoaderPlugin::parse_header()
u32 sz = read_u32();
ok = ok && sz < 1024 * 1024 * 1024; // arbitrary
CHECK_OK("File size");
ASSERT(sz < 1024 * 1024 * 1024);
VERIFY(sz < 1024 * 1024 * 1024);
u32 wave = read_u32();
ok = ok && wave == 0x45564157; // "WAVE"
@ -187,12 +187,12 @@ bool WavLoaderPlugin::parse_header()
u32 fmt_size = read_u32();
ok = ok && fmt_size == 16;
CHECK_OK("FMT size");
ASSERT(fmt_size == 16);
VERIFY(fmt_size == 16);
u16 audio_format = read_u16();
CHECK_OK("Audio format"); // incomplete read check
ok = ok && audio_format == 1; // WAVE_FORMAT_PCM
ASSERT(audio_format == 1);
VERIFY(audio_format == 1);
CHECK_OK("Audio format"); // value check
m_num_channels = read_u16();
@ -211,7 +211,7 @@ bool WavLoaderPlugin::parse_header()
m_bits_per_sample = read_u16();
CHECK_OK("Bits per sample"); // incomplete read check
ok = ok && (m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);
ASSERT(m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);
VERIFY(m_bits_per_sample == 8 || m_bits_per_sample == 16 || m_bits_per_sample == 24);
CHECK_OK("Bits per sample"); // value check
// Read chunks until we find DATA
@ -241,7 +241,7 @@ bool WavLoaderPlugin::parse_header()
ok = ok && found_data;
CHECK_OK("Found no data chunk");
ASSERT(found_data);
VERIFY(found_data);
ok = ok && data_sz < INT32_MAX;
CHECK_OK("Data was too large");

View file

@ -68,7 +68,7 @@ void WavWriter::write_samples(const u8* samples, size_t size)
void WavWriter::finalize()
{
ASSERT(!m_finalized);
VERIFY(!m_finalized);
m_finalized = true;
if (m_file) {
m_file->seek(0);

View file

@ -39,18 +39,18 @@ __attribute__((noreturn)) void __assertion_failed(const char* msg);
if (__builtin_expect(!(expr), 0)) \
__assertion_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)); \
} while (0)
# define ASSERT_NOT_REACHED() assert(false)
# define VERIFY_NOT_REACHED() assert(false)
#else
# define assert(expr) ((void)(0))
# define ASSERT_NOT_REACHED() CRASH()
# define VERIFY_NOT_REACHED() CRASH()
#endif
#define CRASH() \
do { \
asm volatile("ud2"); \
} while (0)
#define ASSERT assert
#define VERIFY assert
#define RELEASE_ASSERT assert
#define TODO ASSERT_NOT_REACHED
#define TODO VERIFY_NOT_REACHED
__END_DECLS

View file

@ -110,7 +110,7 @@ void __cxa_finalize(void* dso_handle)
[[noreturn]] void __cxa_pure_virtual()
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
} // extern "C"

View file

@ -194,7 +194,7 @@ int readdir_r(DIR* dirp, struct dirent* entry, struct dirent** result)
int dirfd(DIR* dirp)
{
ASSERT(dirp);
VERIFY(dirp);
return dirp->fd;
}
}

View file

@ -104,7 +104,7 @@ void* dlopen(const char* filename, int flags)
void* dlsym(void* handle, const char* symbol_name)
{
// FIXME: When called with a NULL handle we're supposed to search every dso in the process... that'll get expensive
ASSERT(handle);
VERIFY(handle);
auto* dso = reinterpret_cast<ELF::DynamicLoader*>(handle);
void* symbol = dso->symbol_for_name(symbol_name);
if (!symbol) {

View file

@ -142,7 +142,7 @@ int OptionParser::getopt()
if (should_reorder_argv)
shift_argv();
else
ASSERT(optind == static_cast<int>(m_arg_index));
VERIFY(optind == static_cast<int>(m_arg_index));
optind += m_consumed_args;
return res;
@ -152,7 +152,7 @@ bool OptionParser::lookup_short_option(char option, int& needs_value) const
{
Vector<StringView> parts = m_short_options.split_view(option, true);
ASSERT(parts.size() <= 2);
VERIFY(parts.size() <= 2);
if (parts.size() < 2) {
// Haven't found the option in the spec.
return false;
@ -175,7 +175,7 @@ bool OptionParser::lookup_short_option(char option, int& needs_value) const
int OptionParser::handle_short_option()
{
StringView arg = m_argv[m_arg_index];
ASSERT(arg.starts_with('-'));
VERIFY(arg.starts_with('-'));
if (s_index_into_multioption_argument == 0) {
// Just starting to parse this argument, skip the "-".
@ -245,7 +245,7 @@ const option* OptionParser::lookup_long_option(char* raw) const
optarg = nullptr;
return &option;
}
ASSERT(arg.length() > name.length());
VERIFY(arg.length() > name.length());
if (arg[name.length()] == '=') {
optarg = raw + name.length() + 1;
return &option;
@ -257,7 +257,7 @@ const option* OptionParser::lookup_long_option(char* raw) const
int OptionParser::handle_long_option()
{
ASSERT(StringView(m_argv[m_arg_index]).starts_with("--"));
VERIFY(StringView(m_argv[m_arg_index]).starts_with("--"));
// We cannot set optopt to anything sensible for long options, so set it to 0.
optopt = 0;
@ -298,7 +298,7 @@ int OptionParser::handle_long_option()
}
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
// Now that we've figured the value out, see about reporting this option to
@ -314,7 +314,7 @@ void OptionParser::shift_argv()
{
// We've just parsed an option (which perhaps has a value).
// Put the option (along with it value, if any) in front of other arguments.
ASSERT(optind <= static_cast<int>(m_arg_index));
VERIFY(optind <= static_cast<int>(m_arg_index));
if (optind == static_cast<int>(m_arg_index) || m_consumed_args == 0) {
// Nothing to do!

View file

@ -75,8 +75,8 @@ char* basename(char* path)
return path;
if (len == 1) {
ASSERT(last_slash == path);
ASSERT(path[0] == '/');
VERIFY(last_slash == path);
VERIFY(path[0] == '/');
return slash;
}

View file

@ -156,7 +156,7 @@ extern "C" {
static void* os_alloc(size_t size, const char* name)
{
auto* ptr = serenity_mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, ChunkedBlock::block_size, name);
ASSERT(ptr != MAP_FAILED);
VERIFY(ptr != MAP_FAILED);
return ptr;
}
@ -192,11 +192,11 @@ static void* malloc_impl(size_t size)
bool this_block_was_purged = rc == 1;
if (rc < 0) {
perror("madvise");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (mprotect(block, real_size, PROT_READ | PROT_WRITE) < 0) {
perror("mprotect");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (this_block_was_purged) {
g_malloc_stats.number_of_big_allocator_purge_hits++;
@ -229,12 +229,12 @@ static void* malloc_impl(size_t size)
bool this_block_was_purged = rc == 1;
if (rc < 0) {
perror("madvise");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
rc = mprotect(block, ChunkedBlock::block_size, PROT_READ | PROT_WRITE);
if (rc < 0) {
perror("mprotect");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (this_block_was_purged) {
g_malloc_stats.number_of_empty_block_purge_hits++;
@ -255,7 +255,7 @@ static void* malloc_impl(size_t size)
--block->m_free_chunks;
void* ptr = block->m_freelist;
ASSERT(ptr);
VERIFY(ptr);
block->m_freelist = block->m_freelist->next;
if (block->is_full()) {
g_malloc_stats.number_of_blocks_full++;
@ -296,11 +296,11 @@ static void free_impl(void* ptr)
size_t this_block_size = block->m_size;
if (mprotect(block, this_block_size, PROT_NONE) < 0) {
perror("mprotect");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (madvise(block, this_block_size, MADV_SET_VOLATILE) != 0) {
perror("madvise");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return;
}
@ -390,7 +390,7 @@ size_t malloc_size(void* ptr)
if (header->m_magic == MAGIC_BIGALLOC_HEADER)
size -= sizeof(CommonHeader);
else
ASSERT(header->m_magic == MAGIC_PAGE_HEADER);
VERIFY(header->m_magic == MAGIC_PAGE_HEADER);
return size;
}

View file

@ -142,13 +142,13 @@ hostent* gethostbyname(const char* name)
perror("write");
return nullptr;
}
ASSERT((size_t)nsent == sizeof(request_header));
VERIFY((size_t)nsent == sizeof(request_header));
nsent = write(fd, name, name_length);
if (nsent < 0) {
perror("write");
return nullptr;
}
ASSERT((size_t)nsent == name_length);
VERIFY((size_t)nsent == name_length);
struct [[gnu::packed]] {
u32 message_size;
@ -163,7 +163,7 @@ hostent* gethostbyname(const char* name)
perror("recv");
return nullptr;
}
ASSERT((size_t)nrecv == sizeof(response_header));
VERIFY((size_t)nrecv == sizeof(response_header));
if (response_header.endpoint_magic != lookup_server_endpoint_magic || response_header.message_id != 2) {
dbgln("Received an unexpected message");
return nullptr;
@ -172,7 +172,7 @@ hostent* gethostbyname(const char* name)
// TODO: return a specific error.
return nullptr;
}
ASSERT(response_header.addresses_count > 0);
VERIFY(response_header.addresses_count > 0);
i32 response_length;
nrecv = read(fd, &response_length, sizeof(response_length));
@ -180,15 +180,15 @@ hostent* gethostbyname(const char* name)
perror("recv");
return nullptr;
}
ASSERT((size_t)nrecv == sizeof(response_length));
ASSERT(response_length == sizeof(__gethostbyname_address));
VERIFY((size_t)nrecv == sizeof(response_length));
VERIFY(response_length == sizeof(__gethostbyname_address));
nrecv = read(fd, &__gethostbyname_address, response_length);
if (nrecv < 0) {
perror("recv");
return nullptr;
}
ASSERT(nrecv == response_length);
VERIFY(nrecv == response_length);
gethostbyname_name_buffer = name;
__gethostbyname_buffer.h_name = const_cast<char*>(gethostbyname_name_buffer.characters());
@ -243,13 +243,13 @@ hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type)
perror("write");
return nullptr;
}
ASSERT((size_t)nsent == sizeof(request_header));
VERIFY((size_t)nsent == sizeof(request_header));
nsent = write(fd, &in_addr, sizeof(in_addr));
if (nsent < 0) {
perror("write");
return nullptr;
}
ASSERT((size_t)nsent == sizeof(in_addr));
VERIFY((size_t)nsent == sizeof(in_addr));
struct [[gnu::packed]] {
u32 message_size;
@ -264,7 +264,7 @@ hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type)
perror("recv");
return nullptr;
}
ASSERT((size_t)nrecv == sizeof(response_header));
VERIFY((size_t)nrecv == sizeof(response_header));
if (response_header.endpoint_magic != lookup_server_endpoint_magic || response_header.message_id != 4) {
dbgln("Received an unexpected message");
return nullptr;
@ -281,7 +281,7 @@ hostent* gethostbyaddr(const void* addr, socklen_t addr_size, int type)
perror("recv");
return nullptr;
}
ASSERT(nrecv == response_header.name_length);
VERIFY(nrecv == response_header.name_length);
gethostbyaddr_name_buffer = move(string_impl);
__gethostbyaddr_buffer.h_name = buffer;
@ -661,12 +661,12 @@ int getaddrinfo(const char* __restrict node, const char* __restrict service, con
(void)service;
(void)hints;
(void)res;
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void freeaddrinfo(struct addrinfo* res)
{
(void)res;
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
const char* gai_strerror(int errcode)
{

View file

@ -178,7 +178,7 @@ static void construct_pwd(struct passwd* pwd, char* buf, struct passwd** result)
ok = ok || s_dir.copy_characters_to_buffer(buf_dir, s_dir.length() + 1);
ok = ok || s_shell.copy_characters_to_buffer(buf_shell, s_shell.length() + 1);
ASSERT(ok);
VERIFY(ok);
*result = pwd;
pwd->pw_name = buf_name;

View file

@ -50,7 +50,7 @@ namespace AK {
template<>
inline void swap(const SizedObject& a, const SizedObject& b)
{
ASSERT(a.size() == b.size());
VERIFY(a.size() == b.size());
const size_t size = a.size();
const auto a_data = reinterpret_cast<char*>(a.data());
const auto b_data = reinterpret_cast<char*>(b.data());

View file

@ -104,7 +104,7 @@ struct read_element_concrete<int, ApT, kind> {
return false;
auto diff = endptr - nptr;
ASSERT(diff > 0);
VERIFY(diff > 0);
lexer.ignore((size_t)diff);
*ptr = value;
@ -155,7 +155,7 @@ struct read_element_concrete<unsigned, ApT, kind> {
return false;
auto diff = endptr - nptr;
ASSERT(diff > 0);
VERIFY(diff > 0);
lexer.ignore((size_t)diff);
*ptr = value;
@ -189,7 +189,7 @@ struct read_element_concrete<unsigned long long, ApT, kind> {
return false;
auto diff = endptr - nptr;
ASSERT(diff > 0);
VERIFY(diff > 0);
lexer.ignore((size_t)diff);
*ptr = value;
@ -220,7 +220,7 @@ struct read_element_concrete<float, ApT, kind> {
return false;
auto diff = endptr - nptr;
ASSERT(diff > 0);
VERIFY(diff > 0);
lexer.ignore((size_t)diff);
*ptr = value;
@ -235,7 +235,7 @@ struct read_element {
switch (length_modifier) {
default:
case None:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
case Default:
return read_element_concrete<T, T, kind> {}(input_lexer, ap);
case Char:
@ -510,7 +510,7 @@ extern "C" int vsscanf(const char* input, const char* format, va_list ap)
default:
// "undefined behaviour", let's be nice and crash.
dbgln("Invalid conversion specifier {} in scanf!", (int)conversion_specifier);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
case Decimal:
if (!read_element<int, ReadKind::Normal> {}(length_modifier, input_lexer, &ap))
format_lexer.consume_all();

View file

@ -29,37 +29,37 @@
int sem_close(sem_t*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_destroy(sem_t*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_getvalue(sem_t*, int*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_init(sem_t*, int, unsigned int)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
sem_t* sem_open(const char*, int, ...)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_post(sem_t*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_trywait(sem_t*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_unlink(const char*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int sem_wait(sem_t*)
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}

View file

@ -227,7 +227,7 @@ static_assert(sizeof(signal_names) == sizeof(const char*) * NSIG);
int getsignalbyname(const char* name)
{
ASSERT(name);
VERIFY(name);
for (size_t i = 0; i < NSIG; ++i) {
auto* signal_name = signal_names[i];
if (!strcmp(signal_name, name))

View file

@ -141,7 +141,7 @@ private:
FILE::~FILE()
{
bool already_closed = m_fd == -1;
ASSERT(already_closed);
VERIFY(already_closed);
}
FILE* FILE::create(int fd, int mode)
@ -222,7 +222,7 @@ bool FILE::read_into_buffer()
size_t available_size;
u8* data = m_buffer.begin_enqueue(available_size);
// If we want to read, the buffer must have some space!
ASSERT(available_size);
VERIFY(available_size);
ssize_t nread = do_read(data, available_size);
@ -238,7 +238,7 @@ bool FILE::write_from_buffer()
size_t size;
const u8* data = m_buffer.begin_dequeue(size);
// If we want to write, the buffer must have something in it!
ASSERT(size);
VERIFY(size);
ssize_t nwritten = do_write(data, size);
@ -378,7 +378,7 @@ bool FILE::gets(u8* data, size_t size)
*data = 0;
return total_read > 0;
}
ASSERT(nread == 1);
VERIFY(nread == 1);
*data = byte;
total_read++;
data++;
@ -508,17 +508,17 @@ const u8* FILE::Buffer::begin_dequeue(size_t& available_size) const
void FILE::Buffer::did_dequeue(size_t actual_size)
{
ASSERT(actual_size > 0);
VERIFY(actual_size > 0);
if (m_ungotten) {
ASSERT(actual_size == 1);
VERIFY(actual_size == 1);
m_ungotten = false;
return;
}
m_begin += actual_size;
ASSERT(m_begin <= m_capacity);
VERIFY(m_begin <= m_capacity);
if (m_begin == m_capacity) {
// Wrap around.
m_begin = 0;
@ -534,7 +534,7 @@ void FILE::Buffer::did_dequeue(size_t actual_size)
u8* FILE::Buffer::begin_enqueue(size_t& available_size) const
{
ASSERT(m_data != nullptr);
VERIFY(m_data != nullptr);
if (m_begin < m_end || m_empty)
available_size = m_capacity - m_end;
@ -546,12 +546,12 @@ u8* FILE::Buffer::begin_enqueue(size_t& available_size) const
void FILE::Buffer::did_enqueue(size_t actual_size)
{
ASSERT(m_data != nullptr);
ASSERT(actual_size > 0);
VERIFY(m_data != nullptr);
VERIFY(actual_size > 0);
m_end += actual_size;
ASSERT(m_end <= m_capacity);
VERIFY(m_end <= m_capacity);
if (m_end == m_capacity) {
// Wrap around.
m_end = 0;
@ -590,7 +590,7 @@ void __stdio_init()
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
{
ASSERT(stream);
VERIFY(stream);
if (mode != _IONBF && mode != _IOLBF && mode != _IOFBF) {
errno = EINVAL;
return -1;
@ -611,13 +611,13 @@ void setlinebuf(FILE* stream)
int fileno(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
return stream->fileno();
}
int feof(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
return stream->eof();
}
@ -632,14 +632,14 @@ int fflush(FILE* stream)
char* fgets(char* buffer, int size, FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
bool ok = stream->gets(reinterpret_cast<u8*>(buffer), size);
return ok ? buffer : nullptr;
}
int fgetc(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
char ch;
size_t nread = fread(&ch, sizeof(char), 1, stream);
if (nread == 1)
@ -715,19 +715,19 @@ ssize_t getline(char** lineptr, size_t* n, FILE* stream)
int ungetc(int c, FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
bool ok = stream->ungetc(c);
return ok ? c : EOF;
}
int fputc(int ch, FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
u8 byte = ch;
size_t nwritten = stream->write(&byte, 1);
if (nwritten == 0)
return EOF;
ASSERT(nwritten == 1);
VERIFY(nwritten == 1);
return byte;
}
@ -743,7 +743,7 @@ int putchar(int ch)
int fputs(const char* s, FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
size_t len = strlen(s);
size_t nwritten = stream->write(reinterpret_cast<const u8*>(s), len);
if (nwritten < len)
@ -761,20 +761,20 @@ int puts(const char* s)
void clearerr(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
stream->clear_err();
}
int ferror(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
return stream->error();
}
size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream)
{
ASSERT(stream);
ASSERT(!Checked<size_t>::multiplication_would_overflow(size, nmemb));
VERIFY(stream);
VERIFY(!Checked<size_t>::multiplication_would_overflow(size, nmemb));
size_t nread = stream->read(reinterpret_cast<u8*>(ptr), size * nmemb);
return nread / size;
@ -782,8 +782,8 @@ size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream)
size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream)
{
ASSERT(stream);
ASSERT(!Checked<size_t>::multiplication_would_overflow(size, nmemb));
VERIFY(stream);
VERIFY(!Checked<size_t>::multiplication_would_overflow(size, nmemb));
size_t nwritten = stream->write(reinterpret_cast<const u8*>(ptr), size * nmemb);
return nwritten / size;
@ -791,32 +791,32 @@ size_t fwrite(const void* ptr, size_t size, size_t nmemb, FILE* stream)
int fseek(FILE* stream, long offset, int whence)
{
ASSERT(stream);
VERIFY(stream);
return stream->seek(offset, whence);
}
int fseeko(FILE* stream, off_t offset, int whence)
{
ASSERT(stream);
VERIFY(stream);
return stream->seek(offset, whence);
}
long ftell(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
return stream->tell();
}
off_t ftello(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
return stream->tell();
}
int fgetpos(FILE* stream, fpos_t* pos)
{
ASSERT(stream);
ASSERT(pos);
VERIFY(stream);
VERIFY(pos);
off_t val = stream->tell();
if (val == -1L)
@ -828,17 +828,17 @@ int fgetpos(FILE* stream, fpos_t* pos)
int fsetpos(FILE* stream, const fpos_t* pos)
{
ASSERT(stream);
ASSERT(pos);
VERIFY(stream);
VERIFY(pos);
return stream->seek(*pos, SEEK_SET);
}
void rewind(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
int rc = stream->seek(0, SEEK_SET);
ASSERT(rc == 0);
VERIFY(rc == 0);
}
ALWAYS_INLINE void stdout_putch(char*&, char ch)
@ -991,7 +991,7 @@ FILE* fopen(const char* pathname, const char* mode)
FILE* freopen(const char* pathname, const char* mode, FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
if (!pathname) {
// FIXME: Someone should probably implement this path.
TODO();
@ -1022,7 +1022,7 @@ static inline bool is_default_stream(FILE* stream)
int fclose(FILE* stream)
{
ASSERT(stream);
VERIFY(stream);
bool ok = stream->close();
ScopedValueRollback errno_restorer(errno);
@ -1124,8 +1124,8 @@ FILE* popen(const char* command, const char* type)
int pclose(FILE* stream)
{
ASSERT(stream);
ASSERT(stream->popen_child() != 0);
VERIFY(stream);
VERIFY(stream->popen_child() != 0);
int wstatus = 0;
int rc = waitpid(stream->popen_child(), &wstatus, 0);

View file

@ -289,7 +289,7 @@ int unsetenv(const char* name)
for (; environ[environ_size]; ++environ_size) {
char* old_var = environ[environ_size];
char* old_eq = strchr(old_var, '=');
ASSERT(old_eq);
VERIFY(old_eq);
size_t old_var_len = old_eq - old_var;
if (new_var_len != old_var_len)
@ -343,7 +343,7 @@ int putenv(char* new_var)
for (; environ[environ_size]; ++environ_size) {
char* old_var = environ[environ_size];
char* old_eq = strchr(old_var, '=');
ASSERT(old_eq);
VERIFY(old_eq);
auto old_var_len = old_eq - old_var;
if (new_var_len != old_var_len)
@ -491,7 +491,7 @@ double strtod(const char* str, char** endptr)
is_a_digit = false;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -547,7 +547,7 @@ double strtod(const char* str, char** endptr)
is_a_digit = false;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -955,7 +955,7 @@ long long strtoll(const char* str, char** endptr, int base)
is_a_digit = false;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -1039,7 +1039,7 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
is_a_digit = false;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -86,7 +86,7 @@ pid_t waitpid(pid_t waitee, int* wstatus, int options)
*wstatus = 0;
return 0; // return 0 if running
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -66,7 +66,7 @@ static const char* get_syslog_ident(struct syslog_data* data)
else if (program_name_set)
return program_name_buffer;
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void openlog_r(const char* ident, int logopt, int facility, struct syslog_data* data)

View file

@ -137,7 +137,7 @@ int tgetnum(const char* id)
auto it = caps->find(id);
if (it != caps->end())
return atoi((*it).value);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
static Vector<char> s_tgoto_buffer;

View file

@ -84,7 +84,7 @@ static void time_to_tm(struct tm* tm, time_t t)
t += days_in_year(year - 1) * __seconds_per_day;
tm->tm_year = year - 1900;
ASSERT(t >= 0);
VERIFY(t >= 0);
int days = t / __seconds_per_day;
tm->tm_yday = days;
int remaining = t % __seconds_per_day;

View file

@ -592,7 +592,7 @@ long fpathconf([[maybe_unused]] int fd, [[maybe_unused]] int name)
return _POSIX_VDISABLE;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
long pathconf([[maybe_unused]] const char* path, int name)
@ -604,13 +604,13 @@ long pathconf([[maybe_unused]] const char* path, int name)
return PIPE_BUF;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void _exit(int status)
{
syscall(SC_exit, status);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void sync()

View file

@ -79,7 +79,7 @@ Color opposing_color(Color color)
Square::Square(const StringView& name)
{
ASSERT(name.length() == 2);
VERIFY(name.length() == 2);
char filec = name[0];
char rankc = name[1];
@ -88,13 +88,13 @@ Square::Square(const StringView& name)
} else if (filec >= 'A' && filec <= 'H') {
file = filec - 'A';
} else {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (rankc >= '1' && rankc <= '8') {
rank = rankc - '1';
} else {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -312,7 +312,7 @@ String Board::to_fen() const
}
// 2. Active color
ASSERT(m_turn != Color::None);
VERIFY(m_turn != Color::None);
builder.append(m_turn == Color::White ? " w " : " b ");
// 3. Castling availability
@ -349,15 +349,15 @@ String Board::to_fen() const
Piece Board::get_piece(const Square& square) const
{
ASSERT(square.rank < 8);
ASSERT(square.file < 8);
VERIFY(square.rank < 8);
VERIFY(square.file < 8);
return m_board[square.rank][square.file];
}
Piece Board::set_piece(const Square& square, const Piece& piece)
{
ASSERT(square.rank < 8);
ASSERT(square.file < 8);
VERIFY(square.rank < 8);
VERIFY(square.file < 8);
return m_board[square.rank][square.file] = piece;
}
@ -913,7 +913,7 @@ String Board::result_to_string(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:
ASSERT(turn != Chess::Color::None);
VERIFY(turn != Chess::Color::None);
return turn == Chess::Color::White ? "Black wins by Checkmate" : "White wins by Checkmate";
case Result::WhiteResign:
return "Black wins by Resignation";
@ -934,7 +934,7 @@ String Board::result_to_string(Result result, Color turn)
case Chess::Board::Result::NotFinished:
return "Game not finished";
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -942,7 +942,7 @@ String Board::result_to_points(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:
ASSERT(turn != Chess::Color::None);
VERIFY(turn != Chess::Color::None);
return turn == Chess::Color::White ? "0-1" : "1-0";
case Result::WhiteResign:
return "0-1";
@ -963,7 +963,7 @@ String Board::result_to_points(Result result, Color turn)
case Chess::Board::Result::NotFinished:
return "*";
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -32,8 +32,8 @@ namespace Chess::UCI {
UCICommand UCICommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "uci");
ASSERT(tokens.size() == 1);
VERIFY(tokens[0] == "uci");
VERIFY(tokens.size() == 1);
return UCICommand();
}
@ -45,14 +45,14 @@ String UCICommand::to_string() const
DebugCommand DebugCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "debug");
ASSERT(tokens.size() == 2);
VERIFY(tokens[0] == "debug");
VERIFY(tokens.size() == 2);
if (tokens[1] == "on")
return DebugCommand(Flag::On);
if (tokens[1] == "off")
return DebugCommand(Flag::On);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
String DebugCommand::to_string() const
@ -67,8 +67,8 @@ String DebugCommand::to_string() const
IsReadyCommand IsReadyCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "isready");
ASSERT(tokens.size() == 1);
VERIFY(tokens[0] == "isready");
VERIFY(tokens.size() == 1);
return IsReadyCommand();
}
@ -80,9 +80,9 @@ String IsReadyCommand::to_string() const
SetOptionCommand SetOptionCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "setoption");
ASSERT(tokens[1] == "name");
ASSERT(tokens.size() > 2);
VERIFY(tokens[0] == "setoption");
VERIFY(tokens[1] == "name");
VERIFY(tokens.size() > 2);
StringBuilder name;
StringBuilder value;
@ -110,7 +110,7 @@ SetOptionCommand SetOptionCommand::from_string(const StringView& command)
}
}
ASSERT(!name.is_empty());
VERIFY(!name.is_empty());
return SetOptionCommand(name.to_string().trim_whitespace(), value.to_string().trim_whitespace());
}
@ -131,9 +131,9 @@ String SetOptionCommand::to_string() const
PositionCommand PositionCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens.size() >= 3);
ASSERT(tokens[0] == "position");
ASSERT(tokens[2] == "moves");
VERIFY(tokens.size() >= 3);
VERIFY(tokens[0] == "position");
VERIFY(tokens[2] == "moves");
Optional<String> fen;
if (tokens[1] != "startpos")
@ -167,40 +167,40 @@ String PositionCommand::to_string() const
GoCommand GoCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "go");
VERIFY(tokens[0] == "go");
GoCommand go_command;
for (size_t i = 1; i < tokens.size(); ++i) {
if (tokens[i] == "searchmoves") {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
} else if (tokens[i] == "ponder") {
go_command.ponder = true;
} else if (tokens[i] == "wtime") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.wtime = tokens[i].to_int().value();
} else if (tokens[i] == "btime") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.btime = tokens[i].to_int().value();
} else if (tokens[i] == "winc") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.winc = tokens[i].to_int().value();
} else if (tokens[i] == "binc") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.binc = tokens[i].to_int().value();
} else if (tokens[i] == "movestogo") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.movestogo = tokens[i].to_int().value();
} else if (tokens[i] == "depth") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.depth = tokens[i].to_int().value();
} else if (tokens[i] == "nodes") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.nodes = tokens[i].to_int().value();
} else if (tokens[i] == "mate") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.mate = tokens[i].to_int().value();
} else if (tokens[i] == "movetime") {
ASSERT(i++ < tokens.size());
VERIFY(i++ < tokens.size());
go_command.movetime = tokens[i].to_int().value();
} else if (tokens[i] == "infinite") {
go_command.infinite = true;
@ -253,8 +253,8 @@ String GoCommand::to_string() const
StopCommand StopCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "stop");
ASSERT(tokens.size() == 1);
VERIFY(tokens[0] == "stop");
VERIFY(tokens.size() == 1);
return StopCommand();
}
@ -266,7 +266,7 @@ String StopCommand::to_string() const
IdCommand IdCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "id");
VERIFY(tokens[0] == "id");
StringBuilder value;
for (size_t i = 2; i < tokens.size(); ++i) {
if (i != 2)
@ -280,7 +280,7 @@ IdCommand IdCommand::from_string(const StringView& command)
} else if (tokens[1] == "author") {
return IdCommand(Type::Author, value.build());
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
String IdCommand::to_string() const
@ -300,8 +300,8 @@ String IdCommand::to_string() const
UCIOkCommand UCIOkCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "uciok");
ASSERT(tokens.size() == 1);
VERIFY(tokens[0] == "uciok");
VERIFY(tokens.size() == 1);
return UCIOkCommand();
}
@ -313,8 +313,8 @@ String UCIOkCommand::to_string() const
ReadyOkCommand ReadyOkCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "readyok");
ASSERT(tokens.size() == 1);
VERIFY(tokens[0] == "readyok");
VERIFY(tokens.size() == 1);
return ReadyOkCommand();
}
@ -326,8 +326,8 @@ String ReadyOkCommand::to_string() const
BestMoveCommand BestMoveCommand::from_string(const StringView& command)
{
auto tokens = command.split_view(' ');
ASSERT(tokens[0] == "bestmove");
ASSERT(tokens.size() == 2);
VERIFY(tokens[0] == "bestmove");
VERIFY(tokens.size() == 2);
return BestMoveCommand(Move(tokens[1]));
}
@ -343,13 +343,13 @@ String BestMoveCommand::to_string() const
InfoCommand InfoCommand::from_string([[maybe_unused]] const StringView& command)
{
// FIXME: Implement this.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
String InfoCommand::to_string() const
{
// FIXME: Implement this.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "info";
}

View file

@ -125,7 +125,7 @@ NonnullOwnPtr<Command> Endpoint::read_command()
}
dbgln("command line: {}", line);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
};

View file

@ -109,7 +109,7 @@ u32 CanonicalCode::read_symbol(InputBitStream& stream) const
for (;;) {
code_bits = code_bits << 1 | stream.read_bits(1);
ASSERT(code_bits < (1 << 16));
VERIFY(code_bits < (1 << 16));
// FIXME: This is very inefficient and could greatly be improved by implementing this
// algorithm: https://www.hanshq.net/zip.html#huffdec
@ -273,7 +273,7 @@ size_t DeflateDecompressor::read(Bytes bytes)
return nread + read(bytes.slice(nread));
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool DeflateDecompressor::read_or_error(Bytes bytes)
@ -338,7 +338,7 @@ u32 DeflateDecompressor::decode_length(u32 symbol)
if (symbol == 285)
return 258;
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
u32 DeflateDecompressor::decode_distance(u32 symbol)
@ -353,7 +353,7 @@ u32 DeflateDecompressor::decode_distance(u32 symbol)
return ((symbol % 2 + 2) << extra_bits) + 1 + m_input_stream.read_bits(extra_bits);
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void DeflateDecompressor::decode_codes(CanonicalCode& literal_code, Optional<CanonicalCode>& distance_code)
@ -401,7 +401,7 @@ void DeflateDecompressor::decode_codes(CanonicalCode& literal_code, Optional<Can
code_lengths.append(0);
continue;
} else {
ASSERT(symbol == 16);
VERIFY(symbol == 16);
if (code_lengths.is_empty()) {
set_fatal_error();

View file

@ -47,10 +47,10 @@ Zlib::Zlib(ReadonlyBytes data)
m_compression_level = (flags >> 6) & 0x3;
m_checksum = 0;
ASSERT(m_compression_method == 8);
ASSERT(m_compression_info == 7);
ASSERT(!m_has_dictionary);
ASSERT((compression_info * 256 + flags) % 31 == 0);
VERIFY(m_compression_method == 8);
VERIFY(m_compression_info == 7);
VERIFY(!m_has_dictionary);
VERIFY((compression_info * 256 + flags) % 31 == 0);
m_data_bytes = data.slice(2, data.size() - 2 - 4);
}

View file

@ -200,9 +200,9 @@ String Account::generate_passwd_file() const
void Account::load_shadow_file()
{
auto file_or_error = Core::File::open("/etc/shadow", Core::File::ReadOnly);
ASSERT(!file_or_error.is_error());
VERIFY(!file_or_error.is_error());
auto shadow_file = file_or_error.release_value();
ASSERT(shadow_file->is_open());
VERIFY(shadow_file->is_open());
Vector<ShadowEntry> entries;
@ -250,7 +250,7 @@ bool Account::sync()
auto new_shadow_file_content = generate_shadow_file();
if (new_passwd_file_content.is_null() || new_shadow_file_content.is_null()) {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
char new_passwd_name[] = "/etc/passwd.XXXXXX";
@ -260,34 +260,34 @@ bool Account::sync()
auto new_passwd_fd = mkstemp(new_passwd_name);
if (new_passwd_fd < 0) {
perror("mkstemp");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ScopeGuard new_passwd_fd_guard = [new_passwd_fd] { close(new_passwd_fd); };
auto new_shadow_fd = mkstemp(new_shadow_name);
if (new_shadow_fd < 0) {
perror("mkstemp");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ScopeGuard new_shadow_fd_guard = [new_shadow_fd] { close(new_shadow_fd); };
if (fchmod(new_passwd_fd, 0644) < 0) {
perror("fchmod");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
auto nwritten = write(new_passwd_fd, new_passwd_file_content.characters(), new_passwd_file_content.length());
if (nwritten < 0) {
perror("write");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ASSERT(static_cast<size_t>(nwritten) == new_passwd_file_content.length());
VERIFY(static_cast<size_t>(nwritten) == new_passwd_file_content.length());
nwritten = write(new_shadow_fd, new_shadow_file_content.characters(), new_shadow_file_content.length());
if (nwritten < 0) {
perror("write");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ASSERT(static_cast<size_t>(nwritten) == new_shadow_file_content.length());
VERIFY(static_cast<size_t>(nwritten) == new_shadow_file_content.length());
}
if (rename(new_passwd_name, "/etc/passwd") < 0) {

View file

@ -87,10 +87,10 @@ AnonymousBufferImpl::~AnonymousBufferImpl()
{
if (m_fd != -1) {
auto rc = close(m_fd);
ASSERT(rc == 0);
VERIFY(rc == 0);
}
auto rc = munmap(m_data, round_up_to_power_of_two(m_size, PAGE_SIZE));
ASSERT(rc == 0);
VERIFY(rc == 0);
}
AnonymousBuffer AnonymousBuffer::create_from_anon_fd(int fd, size_t size)

View file

@ -104,16 +104,16 @@ bool ArgsParser::parse(int argc, char** argv, bool exit_on_failure)
Option* found_option = nullptr;
if (c == 0) {
// It was a long option.
ASSERT(index_of_found_long_option >= 0);
VERIFY(index_of_found_long_option >= 0);
found_option = &m_options[index_of_found_long_option];
index_of_found_long_option = -1;
} else {
// It was a short option, look it up.
auto it = m_options.find_if([c](auto& opt) { return c == opt.short_name; });
ASSERT(!it.is_end());
VERIFY(!it.is_end());
found_option = &*it;
}
ASSERT(found_option);
VERIFY(found_option);
const char* arg = found_option->requires_argument ? optarg : nullptr;
if (!found_option->accept_value(arg)) {
@ -264,7 +264,7 @@ void ArgsParser::add_option(bool& value, const char* help_string, const char* lo
short_name,
nullptr,
[&value](const char* s) {
ASSERT(s == nullptr);
VERIFY(s == nullptr);
value = true;
return true;
}

View file

@ -56,11 +56,11 @@ String command(const String& program, const Vector<String>& arguments, Optional<
int stderr_pipe[2] = {};
if (pipe2(stdout_pipe, O_CLOEXEC)) {
perror("pipe2");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (pipe2(stderr_pipe, O_CLOEXEC)) {
perror("pipe2");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
auto close_pipes = ScopeGuard([stderr_pipe, stdout_pipe] {
@ -88,7 +88,7 @@ String command(const String& program, const Vector<String>& arguments, Optional<
pid_t pid;
if ((errno = posix_spawnp(&pid, program.characters(), &action, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
int wstatus;
waitpid(pid, &wstatus, 0);
@ -102,7 +102,7 @@ String command(const String& program, const Vector<String>& arguments, Optional<
auto result_file = Core::File::construct();
if (!result_file->open(pipe[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
perror("open");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return String::copy(result_file->read_all());
};

View file

@ -43,7 +43,7 @@ void ElapsedTimer::start()
int ElapsedTimer::elapsed() const
{
ASSERT(is_valid());
VERIFY(is_valid());
struct timeval now;
timespec now_spec;
clock_gettime(m_precise ? CLOCK_MONOTONIC : CLOCK_MONOTONIC_COARSE, &now_spec);

View file

@ -160,7 +160,7 @@ public:
shutdown();
return;
}
ASSERT(nread == sizeof(length));
VERIFY(nread == sizeof(length));
auto request = m_socket->read(length);
auto request_json = JsonValue::from_string(request);
@ -296,7 +296,7 @@ EventLoop::EventLoop()
fcntl(s_wake_pipe_fds[1], F_SETFD, FD_CLOEXEC);
#endif
ASSERT(rc == 0);
VERIFY(rc == 0);
s_event_loop_stack->append(this);
#ifdef __serenity__
@ -326,20 +326,20 @@ bool EventLoop::start_rpc_server()
};
return s_rpc_server->listen(String::formatted("/tmp/rpc/{}", getpid()));
#else
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
#endif
}
EventLoop& EventLoop::main()
{
ASSERT(s_main_event_loop);
VERIFY(s_main_event_loop);
return *s_main_event_loop;
}
EventLoop& EventLoop::current()
{
EventLoop* event_loop = s_event_loop_stack->last();
ASSERT(event_loop != nullptr);
VERIFY(event_loop != nullptr);
return *event_loop;
}
@ -391,7 +391,7 @@ int EventLoop::exec()
return m_exit_code;
pump();
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EventLoop::pump(WaitMode mode)
@ -415,7 +415,7 @@ void EventLoop::pump(WaitMode mode)
if (!receiver) {
switch (event.type()) {
case Event::Quit:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return;
default:
#if EVENTLOOP_DEBUG
@ -485,7 +485,7 @@ void SignalHandlers::dispatch()
for (auto& handler : m_handlers_pending) {
if (handler.value) {
auto result = m_handlers.set(handler.key, move(handler.value));
ASSERT(result == AK::HashSetResult::InsertedNewEntry);
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
} else {
m_handlers.remove(handler.key);
}
@ -506,7 +506,7 @@ int SignalHandlers::add(Function<void(int)>&& handler)
bool SignalHandlers::remove(int handler_id)
{
ASSERT(handler_id != 0);
VERIFY(handler_id != 0);
if (m_calling_handlers) {
auto it = m_handlers.find(handler_id);
if (it != m_handlers.end()) {
@ -544,7 +544,7 @@ void EventLoop::dispatch_signal(int signo)
void EventLoop::handle_signal(int signo)
{
ASSERT(signo != 0);
VERIFY(signo != 0);
// We MUST check if the current pid still matches, because there
// is a window between fork() and exec() where a signal delivered
// to our fork could be inadvertedly routed to the parent process!
@ -552,7 +552,7 @@ void EventLoop::handle_signal(int signo)
int nwritten = write(s_wake_pipe_fds[1], &signo, sizeof(signo));
if (nwritten < 0) {
perror("EventLoop::register_signal: write");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
} else {
// We're a fork who received a signal, reset s_pid
@ -562,7 +562,7 @@ void EventLoop::handle_signal(int signo)
int EventLoop::register_signal(int signo, Function<void(int)> handler)
{
ASSERT(signo != 0);
VERIFY(signo != 0);
auto& info = *signals_info();
auto handlers = info.signal_handlers.find(signo);
if (handlers == info.signal_handlers.end()) {
@ -577,7 +577,7 @@ int EventLoop::register_signal(int signo, Function<void(int)> handler)
void EventLoop::unregister_signal(int handler_id)
{
ASSERT(handler_id != 0);
VERIFY(handler_id != 0);
int remove_signo = 0;
auto& info = *signals_info();
for (auto& h : info.signal_handlers) {
@ -612,7 +612,7 @@ void EventLoop::notify_forked(ForkEvent event)
return;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EventLoop::wait_for_event(WaitMode mode)
@ -639,7 +639,7 @@ retry:
if (notifier->event_mask() & Notifier::Write)
add_fd_to_set(notifier->fd(), wfds);
if (notifier->event_mask() & Notifier::Exceptional)
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool queued_events_is_empty;
@ -681,16 +681,16 @@ try_select_again:
dbgln("Core::EventLoop::wait_for_event: {} ({}: {})", marked_fd_count, saved_errno, strerror(saved_errno));
#endif
// Blow up, similar to Core::safe_syscall.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (FD_ISSET(s_wake_pipe_fds[0], &rfds)) {
int wake_events[8];
auto nread = read(s_wake_pipe_fds[0], wake_events, sizeof(wake_events));
if (nread < 0) {
perror("read from wake pipe");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ASSERT(nread > 0);
VERIFY(nread > 0);
bool wake_requested = false;
int event_count = nread / sizeof(wake_events[0]);
for (int i = 0; i < event_count; i++) {
@ -729,7 +729,7 @@ try_select_again:
timer.reload(now);
} else {
// FIXME: Support removing expired timers that don't want to reload.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -778,7 +778,7 @@ Optional<struct timeval> EventLoop::get_next_timer_expiration()
int EventLoop::register_timer(Object& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
{
ASSERT(milliseconds >= 0);
VERIFY(milliseconds >= 0);
auto timer = make<EventLoopTimer>();
timer->owner = object;
timer->interval = milliseconds;
@ -822,7 +822,7 @@ void EventLoop::wake()
int nwritten = write(s_wake_pipe_fds[1], &wake_event, sizeof(wake_event));
if (nwritten < 0) {
perror("EventLoop::wake: write");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -81,7 +81,7 @@ bool File::open(IODevice::OpenMode mode)
bool File::open_impl(IODevice::OpenMode mode, mode_t permissions)
{
ASSERT(!m_filename.is_null());
VERIFY(!m_filename.is_null());
int flags = 0;
if ((mode & IODevice::ReadWrite) == IODevice::ReadWrite) {
flags |= O_RDWR | O_CREAT;
@ -144,7 +144,7 @@ String File::real_path_for(const String& filename)
bool File::ensure_parent_directories(const String& path)
{
ASSERT(path.starts_with("/"));
VERIFY(path.starts_with("/"));
int saved_errno = 0;
ScopeGuard restore_errno = [&saved_errno] { errno = saved_errno; };
@ -365,7 +365,7 @@ Result<void, File::CopyError> File::copy_file(const String& dst_path, const stru
if (nwritten < 0)
return CopyError { OSError(errno), false };
ASSERT(nwritten > 0);
VERIFY(nwritten > 0);
remaining_to_write -= nwritten;
bufptr += nwritten;
}

View file

@ -42,7 +42,7 @@ public:
static Result<InputFileStream, String> open(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::ReadOnly, mode_t permissions = 0644)
{
ASSERT((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
VERIFY((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
auto file_result = File::open(filename, mode, permissions);
@ -54,7 +54,7 @@ public:
static Result<Buffered<InputFileStream>, String> open_buffered(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::ReadOnly, mode_t permissions = 0644)
{
ASSERT((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
VERIFY((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
auto file_result = File::open(filename, mode, permissions);
@ -106,7 +106,7 @@ public:
static Result<OutputFileStream, String> open(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::WriteOnly, mode_t permissions = 0644)
{
ASSERT((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
VERIFY((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
auto file_result = File::open(filename, mode, permissions);
@ -118,7 +118,7 @@ public:
static Result<Buffered<OutputFileStream>, String> open_buffered(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::WriteOnly, mode_t permissions = 0644)
{
ASSERT((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
VERIFY((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
auto file_result = File::open(filename, mode, permissions);

View file

@ -72,7 +72,7 @@ BlockingFileWatcher::BlockingFileWatcher(const String& path)
: m_path(path)
{
m_watcher_fd = watch_file(path.characters(), path.length());
ASSERT(m_watcher_fd != -1);
VERIFY(m_watcher_fd != -1);
}
BlockingFileWatcher::~BlockingFileWatcher()

View file

@ -58,7 +58,7 @@ Result<String, OSError> get_password(const StringView& prompt)
if (line_length < 0)
return OSError(saved_errno);
ASSERT(line_length != 0);
VERIFY(line_length != 0);
// Remove trailing '\n' read by getline().
password[line_length - 1] = '\0';

View file

@ -46,7 +46,7 @@ static Optional<ByteBuffer> get_gzip_payload(const ByteBuffer& data)
size_t current = 0;
auto read_byte = [&]() {
if (current >= data.size()) {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return (u8)0;
}
return data[current++];
@ -108,7 +108,7 @@ static Optional<ByteBuffer> get_gzip_payload(const ByteBuffer& data)
Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
{
ASSERT(is_compressed(data));
VERIFY(is_compressed(data));
dbgln_if(GZIP_DEBUG, "Gzip::decompress: Decompressing gzip compressed data. size={}", data.size());
auto optional_payload = get_gzip_payload(data);
@ -150,7 +150,7 @@ Optional<ByteBuffer> Gzip::decompress(const ByteBuffer& data)
destination.grow(destination.size() * 2);
} else {
dbgln("Gzip::decompress: Error. puff() returned: {}", puff_ret);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -47,7 +47,7 @@ public:
IODeviceStreamReader& operator>>(T& value)
{
int nread = m_device.read((u8*)&value, sizeof(T));
ASSERT(nread == sizeof(T));
VERIFY(nread == sizeof(T));
if (nread != sizeof(T))
m_had_failure = true;
return *this;

View file

@ -112,12 +112,12 @@ bool LocalServer::listen(const String& address)
ioctl(m_fd, FIONBIO, &option);
fcntl(m_fd, F_SETFD, FD_CLOEXEC);
#endif
ASSERT(m_fd >= 0);
VERIFY(m_fd >= 0);
#ifndef __APPLE__
rc = fchmod(m_fd, 0600);
if (rc < 0) {
perror("fchmod");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
#endif
@ -147,7 +147,7 @@ bool LocalServer::listen(const String& address)
RefPtr<LocalSocket> LocalServer::accept()
{
ASSERT(m_listening);
VERIFY(m_listening);
sockaddr_un un;
socklen_t un_size = sizeof(un);
int accepted_fd = ::accept(m_fd, (sockaddr*)&un, &un_size);

View file

@ -55,7 +55,7 @@ void NetworkJob::did_finish(NonnullRefPtr<NetworkResponse>&& response)
m_response = move(response);
dbgln_if(CNETWORKJOB_DEBUG, "{} job did_finish", *this);
ASSERT(on_finish);
VERIFY(on_finish);
on_finish(true);
shutdown();
}
@ -68,7 +68,7 @@ void NetworkJob::did_fail(Error error)
m_error = error;
dbgln_if(CNETWORKJOB_DEBUG, "{}{{{:p}}} job did_fail! error: {} ({})", class_name(), this, (unsigned)error, to_string(error));
ASSERT(on_finish);
VERIFY(on_finish);
on_finish(false);
shutdown();
}

View file

@ -84,7 +84,7 @@ void Object::event(Core::Event& event)
case Core::Event::ChildRemoved:
return child_event(static_cast<ChildEvent&>(event));
case Core::Event::Invalid:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
case Core::Event::Custom:
return custom_event(static_cast<CustomEvent&>(event));
@ -96,7 +96,7 @@ void Object::event(Core::Event& event)
void Object::add_child(Object& object)
{
// FIXME: Should we support reparenting objects?
ASSERT(!object.parent() || object.parent() == this);
VERIFY(!object.parent() || object.parent() == this);
object.m_parent = this;
m_children.append(object);
Core::ChildEvent child_event(Core::Event::ChildAdded, object);
@ -106,7 +106,7 @@ void Object::add_child(Object& object)
void Object::insert_child_before(Object& new_child, Object& before_child)
{
// FIXME: Should we support reparenting objects?
ASSERT(!new_child.parent() || new_child.parent() == this);
VERIFY(!new_child.parent() || new_child.parent() == this);
new_child.m_parent = this;
m_children.insert_before_matching(new_child, [&](auto& existing_child) { return existing_child.ptr() == &before_child; });
Core::ChildEvent child_event(Core::Event::ChildAdded, new_child, &before_child);
@ -126,7 +126,7 @@ void Object::remove_child(Object& object)
return;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void Object::remove_all_children()
@ -151,7 +151,7 @@ void Object::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_vis
{
if (m_timer_id) {
dbgln("{} {:p} already has a timer!", class_name(), this);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_timer_id = Core::EventLoop::register_timer(*this, ms, true, fire_when_not_visible);
@ -162,7 +162,7 @@ void Object::stop_timer()
if (!m_timer_id)
return;
bool success = Core::EventLoop::unregister_timer(m_timer_id);
ASSERT(success);
VERIFY(success);
m_timer_id = 0;
}
@ -224,7 +224,7 @@ bool Object::is_ancestor_of(const Object& other) const
void Object::dispatch_event(Core::Event& e, Object* stay_within)
{
ASSERT(!stay_within || stay_within == this || stay_within->is_ancestor_of(*this));
VERIFY(!stay_within || stay_within == this || stay_within->is_ancestor_of(*this));
auto* target = this;
do {
target->event(e);

View file

@ -86,21 +86,21 @@ bool Socket::connect(const String& hostname, int port)
void Socket::set_blocking(bool blocking)
{
int flags = fcntl(fd(), F_GETFL, 0);
ASSERT(flags >= 0);
VERIFY(flags >= 0);
if (blocking)
flags = fcntl(fd(), F_SETFL, flags & ~O_NONBLOCK);
else
flags = fcntl(fd(), F_SETFL, flags | O_NONBLOCK);
ASSERT(flags == 0);
VERIFY(flags == 0);
}
bool Socket::connect(const SocketAddress& address, int port)
{
ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::IPv4);
VERIFY(!is_connected());
VERIFY(address.type() == SocketAddress::Type::IPv4);
dbgln_if(CSOCKET_DEBUG, "{} connecting to {}...", *this, address);
ASSERT(port > 0 && port <= 65535);
VERIFY(port > 0 && port <= 65535);
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
@ -117,8 +117,8 @@ bool Socket::connect(const SocketAddress& address, int port)
bool Socket::connect(const SocketAddress& address)
{
ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::Local);
VERIFY(!is_connected());
VERIFY(address.type() == SocketAddress::Type::Local);
dbgln_if(CSOCKET_DEBUG, "{} connecting to {}...", *this, address);
sockaddr_un saddr;
@ -183,7 +183,7 @@ bool Socket::send(ReadonlyBytes data)
set_error(errno);
return false;
}
ASSERT(static_cast<size_t>(nsent) == data.size());
VERIFY(static_cast<size_t>(nsent) == data.size());
return true;
}
@ -204,13 +204,13 @@ void Socket::did_update_fd(int fd)
ensure_read_notifier();
} else {
// I don't think it would be right if we updated the fd while not connected *but* while having a notifier..
ASSERT(!m_read_notifier);
VERIFY(!m_read_notifier);
}
}
void Socket::ensure_read_notifier()
{
ASSERT(m_connected);
VERIFY(m_connected);
m_read_notifier = Notifier::construct(fd(), Notifier::Event::Read, this);
m_read_notifier->on_ready_to_read = [this] {
if (!can_read())

View file

@ -78,7 +78,7 @@ protected:
virtual bool common_connect(const struct sockaddr*, socklen_t);
private:
virtual bool open(IODevice::OpenMode) override { ASSERT_NOT_REACHED(); }
virtual bool open(IODevice::OpenMode) override { VERIFY_NOT_REACHED(); }
void ensure_read_notifier();
Type m_type { Type::Invalid };

View file

@ -84,7 +84,7 @@ public:
Optional<sockaddr_un> to_sockaddr_un() const
{
ASSERT(type() == Type::Local);
VERIFY(type() == Type::Local);
sockaddr_un address;
address.sun_family = AF_LOCAL;
bool fits = m_local_address.copy_characters_to_buffer(address.sun_path, sizeof(address.sun_path));
@ -95,7 +95,7 @@ public:
sockaddr_in to_sockaddr_in() const
{
ASSERT(type() == Type::IPv4);
VERIFY(type() == Type::IPv4);
sockaddr_in address {};
address.sin_family = AF_INET;
address.sin_addr.s_addr = m_ipv4_address.to_in_addr_t();

View file

@ -49,7 +49,7 @@ inline int safe_syscall(Syscall syscall, Args&&... args)
if (errno == EINTR)
continue;
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return sysret;
}

View file

@ -49,7 +49,7 @@ TCPServer::TCPServer(Object* parent)
ioctl(m_fd, FIONBIO, &option);
fcntl(m_fd, F_SETFD, FD_CLOEXEC);
#endif
ASSERT(m_fd >= 0);
VERIFY(m_fd >= 0);
}
TCPServer::~TCPServer()
@ -85,7 +85,7 @@ bool TCPServer::listen(const IPv4Address& address, u16 port)
RefPtr<TCPSocket> TCPServer::accept()
{
ASSERT(m_listening);
VERIFY(m_listening);
sockaddr_in in;
socklen_t in_size = sizeof(in);
int accepted_fd = ::accept(m_fd, (sockaddr*)&in, &in_size);

View file

@ -50,7 +50,7 @@ UDPServer::UDPServer(Object* parent)
ioctl(m_fd, FIONBIO, &option);
fcntl(m_fd, F_SETFD, FD_CLOEXEC);
#endif
ASSERT(m_fd >= 0);
VERIFY(m_fd >= 0);
}
UDPServer::~UDPServer()

View file

@ -53,7 +53,7 @@ Reader::Reader(NonnullRefPtr<MappedFile> coredump_file)
++index;
return IterationDecision::Continue;
});
ASSERT(m_notes_segment_index != -1);
VERIFY(m_notes_segment_index != -1);
}
Reader::~Reader()
@ -68,7 +68,7 @@ Reader::NotesEntryIterator::NotesEntryIterator(const u8* notes_data)
ELF::Core::NotesEntryHeader::Type Reader::NotesEntryIterator::type() const
{
ASSERT(m_current->header.type == ELF::Core::NotesEntryHeader::Type::ProcessInfo
VERIFY(m_current->header.type == ELF::Core::NotesEntryHeader::Type::ProcessInfo
|| m_current->header.type == ELF::Core::NotesEntryHeader::Type::MemoryRegionInfo
|| m_current->header.type == ELF::Core::NotesEntryHeader::Type::ThreadInfo
|| m_current->header.type == ELF::Core::NotesEntryHeader::Type::Metadata
@ -83,7 +83,7 @@ const ELF::Core::NotesEntry* Reader::NotesEntryIterator::current() const
void Reader::NotesEntryIterator::next()
{
ASSERT(!at_end());
VERIFY(!at_end());
switch (type()) {
case ELF::Core::NotesEntryHeader::Type::ProcessInfo: {
const auto* current = reinterpret_cast<const ELF::Core::ProcessInfo*>(m_current);
@ -106,7 +106,7 @@ void Reader::NotesEntryIterator::next()
break;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -192,7 +192,7 @@ void BinaryExpression::dump(size_t indent) const
m_lhs->dump(indent + 1);
print_indent(indent + 1);
ASSERT(op_string);
VERIFY(op_string);
outln("{}", op_string);
m_rhs->dump(indent + 1);
}
@ -216,7 +216,7 @@ void AssignmentExpression::dump(size_t indent) const
m_lhs->dump(indent + 1);
print_indent(indent + 1);
ASSERT(op_string);
VERIFY(op_string);
outln("{}", op_string);
m_rhs->dump(indent + 1);
}
@ -301,7 +301,7 @@ void UnaryExpression::dump(size_t indent) const
op_string = "<invalid>";
}
ASSERT(op_string);
VERIFY(op_string);
print_indent(indent + 1);
outln("{}", op_string);
m_lhs->dump(indent + 1);

View file

@ -53,12 +53,12 @@ public:
ASTNode* parent() const { return m_parent; }
Position start() const
{
ASSERT(m_start.has_value());
VERIFY(m_start.has_value());
return m_start.value();
}
Position end() const
{
ASSERT(m_end.has_value());
VERIFY(m_end.has_value());
return m_end.value();
}
const FlyString& filename() const

View file

@ -46,7 +46,7 @@ char Lexer::peek(size_t offset) const
char Lexer::consume()
{
ASSERT(m_index < m_input.length());
VERIFY(m_index < m_input.length());
char ch = m_input[m_index++];
m_previous_position = m_position;
if (ch == '\n') {
@ -660,8 +660,8 @@ Vector<Token> Lexer::lex()
StringView prefix_string = m_input.substring_view(prefix_start, m_index - prefix_start);
while (peek()) {
if (consume() == '"') {
ASSERT(m_index >= prefix_string.length() + 2);
ASSERT(m_input[m_index - 1] == '"');
VERIFY(m_index >= prefix_string.length() + 2);
VERIFY(m_input[m_index - 1] == '"');
if (m_input[m_index - 1 - prefix_string.length() - 1] == ')') {
StringView suffix_string = m_input.substring_view(m_index - 1 - prefix_string.length(), prefix_string.length());
if (prefix_string == suffix_string)

View file

@ -124,7 +124,7 @@ struct Token {
FOR_EACH_TOKEN_TYPE
#undef __TOKEN
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
const char* to_string() const

View file

@ -657,7 +657,7 @@ void Parser::load_state()
Optional<Parser::DeclarationType> Parser::match_declaration_in_function_definition()
{
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool Parser::done()
@ -667,8 +667,8 @@ bool Parser::done()
StringView Parser::text_of_token(const Cpp::Token& token) const
{
ASSERT(token.m_start.line == token.m_end.line);
ASSERT(token.m_start.column <= token.m_end.column);
VERIFY(token.m_start.line == token.m_end.line);
VERIFY(token.m_start.column <= token.m_end.column);
return m_lines[token.m_start.line].substring_view(token.m_start.column, token.m_end.column - token.m_start.column + 1);
}
@ -680,7 +680,7 @@ StringView Parser::text_of_node(const ASTNode& node) const
StringView Parser::text_of_range(Position start, Position end) const
{
if (start.line == end.line) {
ASSERT(start.column <= end.column);
VERIFY(start.column <= end.column);
return m_lines[start.line].substring_view(start.column, end.column - start.column + 1);
}
@ -694,7 +694,7 @@ StringView Parser::text_of_range(Position start, Position end) const
});
auto start_index = index_of_position(start);
auto end_index = index_of_position(end);
ASSERT(end_index >= start_index);
VERIFY(end_index >= start_index);
return m_program.substring_view(start_index, end_index - start_index);
}
@ -741,13 +741,13 @@ Position Parser::position() const
RefPtr<ASTNode> Parser::eof_node() const
{
ASSERT(m_tokens.size());
VERIFY(m_tokens.size());
return node_at(m_tokens.last().m_end);
}
RefPtr<ASTNode> Parser::node_at(Position pos) const
{
ASSERT(!m_tokens.is_empty());
VERIFY(!m_tokens.is_empty());
RefPtr<ASTNode> match_node;
for (auto& node : m_nodes) {
if (node.start() > pos || node.end() < pos)
@ -827,7 +827,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(ASTNode& parent)
while (!eof()) {
auto token = peek();
if (token.type() != Token::Type::DoubleQuotedString && token.type() != Token::Type::EscapeSequence) {
ASSERT(start_token_index.has_value());
VERIFY(start_token_index.has_value());
end_token_index = m_state.token_index - 1;
break;
}
@ -841,8 +841,8 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(ASTNode& parent)
end_token_index = m_tokens.size() - 1;
}
ASSERT(start_token_index.has_value());
ASSERT(end_token_index.has_value());
VERIFY(start_token_index.has_value());
VERIFY(end_token_index.has_value());
Token start_token = m_tokens[start_token_index.value()];
Token end_token = m_tokens[end_token_index.value()];

View file

@ -75,7 +75,7 @@ void Preprocessor::handle_preprocessor_line(const StringView& line)
}
if (keyword == "else") {
ASSERT(m_current_depth > 0);
VERIFY(m_current_depth > 0);
if (m_depths_of_not_taken_branches.contains_slow(m_current_depth - 1)) {
m_depths_of_not_taken_branches.remove_all_matching([this](auto x) { return x == m_current_depth - 1; });
m_state = State::Normal;
@ -88,7 +88,7 @@ void Preprocessor::handle_preprocessor_line(const StringView& line)
}
if (keyword == "endif") {
ASSERT(m_current_depth > 0);
VERIFY(m_current_depth > 0);
--m_current_depth;
if (m_depths_of_not_taken_branches.contains_slow(m_current_depth)) {
m_depths_of_not_taken_branches.remove_all_matching([this](auto x) { return x == m_current_depth; });
@ -164,7 +164,7 @@ void Preprocessor::handle_preprocessor_line(const StringView& line)
return;
}
dbgln("Unsupported preprocessor keyword: {}", keyword);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
};

View file

@ -62,7 +62,7 @@ ByteBuffer decode_pem(ReadonlyBytes data)
lexer.consume_all();
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -40,7 +40,7 @@ size_t SignedBigInteger::export_data(Bytes data, bool remove_leading_zeros) cons
{
// FIXME: Support this:
// m <0XX> -> m <XX> (if remove_leading_zeros)
ASSERT(!remove_leading_zeros);
VERIFY(!remove_leading_zeros);
data[0] = m_sign;
auto bytes_view = data.slice(1, data.size() - 1);

View file

@ -106,7 +106,7 @@ String UnsignedBigInteger::to_base10() const
while (temp != UnsignedBigInteger { 0 }) {
divide_u16_without_allocation(temp, 10, quotient, remainder);
ASSERT(remainder.words()[0] < 10);
VERIFY(remainder.words()[0] < 10);
builder.append(static_cast<char>(remainder.words()[0] + '0'));
temp.set_to(quotient);
}
@ -389,7 +389,7 @@ void UnsignedBigInteger::subtract_without_allocation(
}
// This assertion should not fail, because we verified that *this>=other at the beginning of the function
ASSERT(borrow == 0);
VERIFY(borrow == 0);
}
/**
@ -672,7 +672,7 @@ FLATTEN void UnsignedBigInteger::divide_u16_without_allocation(
UnsignedBigInteger& quotient,
UnsignedBigInteger& remainder)
{
ASSERT(denominator < (1 << 16));
VERIFY(denominator < (1 << 16));
u32 remainder_word = 0;
auto numerator_length = numerator.trimmed_length();
quotient.set_to_0();
@ -717,8 +717,8 @@ ALWAYS_INLINE u32 UnsignedBigInteger::shift_left_get_one_word(
{
// "<= length()" (rather than length() - 1) is intentional,
// The result inedx of length() is used when calculating the carry word
ASSERT(result_word_index <= number.length());
ASSERT(num_bits <= UnsignedBigInteger::BITS_IN_WORD);
VERIFY(result_word_index <= number.length());
VERIFY(num_bits <= UnsignedBigInteger::BITS_IN_WORD);
u32 result = 0;
// we need to check for "num_bits != 0" since shifting right by 32 is apparently undefined behaviour!

View file

@ -65,9 +65,9 @@ void AESCipherKey::expand_encrypt_key(ReadonlyBytes user_key, size_t bits)
u32 temp;
size_t i { 0 };
ASSERT(!user_key.is_null());
ASSERT(is_valid_key_size(bits));
ASSERT(user_key.size() == bits / 8);
VERIFY(!user_key.is_null());
VERIFY(is_valid_key_size(bits));
VERIFY(user_key.size() == bits / 8);
round_key = round_keys();
@ -401,7 +401,7 @@ void AESCipherBlock::overwrite(ReadonlyBytes bytes)
auto data = bytes.data();
auto length = bytes.size();
ASSERT(length <= this->data_size());
VERIFY(length <= this->data_size());
this->bytes().overwrite(0, data, length);
if (length < this->data_size()) {
switch (padding_mode()) {
@ -419,7 +419,7 @@ void AESCipherBlock::overwrite(ReadonlyBytes bytes)
break;
default:
// FIXME: We should handle the rest of the common padding modes
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}

View file

@ -59,7 +59,7 @@ public:
{
}
static size_t block_size() { ASSERT_NOT_REACHED(); }
static size_t block_size() { VERIFY_NOT_REACHED(); }
virtual ReadonlyBytes bytes() const = 0;
@ -74,11 +74,11 @@ public:
template<typename T>
void put(size_t offset, T value)
{
ASSERT(offset + sizeof(T) <= bytes().size());
VERIFY(offset + sizeof(T) <= bytes().size());
auto* ptr = bytes().offset_pointer(offset);
auto index { 0 };
ASSERT(sizeof(T) <= 4);
VERIFY(sizeof(T) <= 4);
if constexpr (sizeof(T) > 3)
ptr[index++] = (u8)(value >> 24);

View file

@ -66,7 +66,7 @@ public:
// FIXME: We should have two of these encrypt/decrypt functions that
// we SFINAE out based on whether the Cipher mode needs an ivec
ASSERT(!ivec.is_empty());
VERIFY(!ivec.is_empty());
const auto* iv = ivec.data();
m_cipher_block.set_padding_mode(cipher.padding_mode());
@ -77,7 +77,7 @@ public:
m_cipher_block.overwrite(in.slice(offset, block_size));
m_cipher_block.apply_initialization_vector(iv);
cipher.encrypt_block(m_cipher_block, m_cipher_block);
ASSERT(offset + block_size <= out.size());
VERIFY(offset + block_size <= out.size());
__builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size);
iv = out.offset(offset);
length -= block_size;
@ -88,7 +88,7 @@ public:
m_cipher_block.overwrite(in.slice(offset, length));
m_cipher_block.apply_initialization_vector(iv);
cipher.encrypt_block(m_cipher_block, m_cipher_block);
ASSERT(offset + block_size <= out.size());
VERIFY(offset + block_size <= out.size());
__builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), block_size);
iv = out.offset(offset);
}
@ -105,14 +105,14 @@ public:
auto& cipher = this->cipher();
ASSERT(!ivec.is_empty());
VERIFY(!ivec.is_empty());
const auto* iv = ivec.data();
auto block_size = cipher.block_size();
// if the data is not aligned, it's not correct encrypted data
// FIXME (ponder): Should we simply decrypt as much as we can?
ASSERT(length % block_size == 0);
VERIFY(length % block_size == 0);
m_cipher_block.set_padding_mode(cipher.padding_mode());
size_t offset { 0 };
@ -123,7 +123,7 @@ public:
cipher.decrypt_block(m_cipher_block, m_cipher_block);
m_cipher_block.apply_initialization_vector(iv);
auto decrypted = m_cipher_block.bytes();
ASSERT(offset + decrypted.size() <= out.size());
VERIFY(offset + decrypted.size() <= out.size());
__builtin_memcpy(out.offset(offset), decrypted.data(), decrypted.size());
iv = slice;
length -= block_size;

View file

@ -160,7 +160,7 @@ protected:
{
size_t length;
if (in) {
ASSERT(in->size() <= out.size());
VERIFY(in->size() <= out.size());
length = in->size();
if (length == 0)
return;
@ -172,8 +172,8 @@ protected:
// FIXME: We should have two of these encrypt/decrypt functions that
// we SFINAE out based on whether the Cipher mode needs an ivec
ASSERT(!ivec.is_empty());
ASSERT(ivec.size() >= IV_length());
VERIFY(!ivec.is_empty());
VERIFY(ivec.size() >= IV_length());
m_cipher_block.set_padding_mode(cipher.padding_mode());
@ -192,7 +192,7 @@ protected:
}
auto write_size = min(block_size, length);
ASSERT(offset + write_size <= out.size());
VERIFY(offset + write_size <= out.size());
__builtin_memcpy(out.offset(offset), m_cipher_block.bytes().data(), write_size);
increment(iv);

View file

@ -73,7 +73,7 @@ public:
// FIXME: This overload throws away the auth stuff, think up a better way to return more than a single bytebuffer.
virtual void encrypt(ReadonlyBytes in, Bytes& out, ReadonlyBytes ivec = {}, Bytes* = nullptr) override
{
ASSERT(!ivec.is_empty());
VERIFY(!ivec.is_empty());
static ByteBuffer dummy;

View file

@ -98,7 +98,7 @@ protected:
}
default:
// FIXME: support other padding modes
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}

View file

@ -85,7 +85,7 @@ struct MultiHashDigestVariant {
return sha512.value().immutable_data();
default:
case HashKind::None:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}
@ -103,7 +103,7 @@ struct MultiHashDigestVariant {
return sha512.value().data_length();
default:
case HashKind::None:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}
@ -179,7 +179,7 @@ public:
inline void initialize(HashKind kind)
{
if (m_kind != HashKind::None) {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_kind = kind;
@ -248,7 +248,7 @@ public:
return { m_sha512->peek() };
default:
case HashKind::None:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}

View file

@ -88,7 +88,7 @@ void MD5::update(const u8* input, size_t length)
index = 0;
}
ASSERT(length < part_length || length - offset <= 64);
VERIFY(length < part_length || length - offset <= 64);
m_buffer.overwrite(index, &input[offset], length - offset);
}
MD5::DigestType MD5::digest()

View file

@ -240,7 +240,7 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
{
// Written using Wikipedia:
// https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test
ASSERT(!(n < 4));
VERIFY(!(n < 4));
auto predecessor = n.minus({ 1 });
auto d = predecessor;
size_t r = 0;
@ -259,8 +259,8 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
}
for (auto& a : tests) {
// Technically: ASSERT(2 <= a && a <= n - 2)
ASSERT(a < n);
// Technically: VERIFY(2 <= a && a <= n - 2)
VERIFY(a < n);
auto x = ModularPower(a, d, n);
if (x == 1 || x == predecessor)
continue;
@ -283,13 +283,13 @@ static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInte
UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBigInteger& max_excluded)
{
ASSERT(min < max_excluded);
VERIFY(min < max_excluded);
auto range = max_excluded.minus(min);
UnsignedBigInteger base;
auto size = range.trimmed_length() * sizeof(u32) + 2;
// "+2" is intentional (see below).
// Also, if we're about to crash anyway, at least produce a nice error:
ASSERT(size < 8 * MiB);
VERIFY(size < 8 * MiB);
u8 buf[size];
AK::fill_with_random(buf, size);
UnsignedBigInteger random { buf, size };
@ -340,7 +340,7 @@ bool is_probably_prime(const UnsignedBigInteger& p)
UnsignedBigInteger random_big_prime(size_t bits)
{
ASSERT(bits >= 33);
VERIFY(bits >= 33);
UnsignedBigInteger min = UnsignedBigInteger::from_base10("6074001000").shift_left(bits - 33);
UnsignedBigInteger max = UnsignedBigInteger { 1 }.shift_left(bits).minus(1);
for (;;) {

View file

@ -286,7 +286,7 @@ void RSA::import_private_key(ReadonlyBytes bytes, bool pem)
auto key = parse_rsa_key(bytes);
if (!key.private_key.length()) {
dbgln("We expected to see a private key, but we found none");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_private_key = key.private_key;
}
@ -302,7 +302,7 @@ void RSA::import_public_key(ReadonlyBytes bytes, bool pem)
auto key = parse_rsa_key(bytes);
if (!key.public_key.length()) {
dbgln("We expected to see a public key, but we found none");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_public_key = key.public_key;
}
@ -356,7 +356,7 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
u8 ps[ps_length];
// FIXME: Without this assertion, GCC refuses to compile due to a memcpy overflow(!?)
ASSERT(ps_length < 16384);
VERIFY(ps_length < 16384);
AK::fill_with_random(ps, ps_length);
// since arc4random can create zeros (shocking!)

View file

@ -207,7 +207,7 @@ static Optional<Dwarf::DIE> parse_variable_type_die(const Dwarf::DIE& variable_d
if (!type_die_offset.has_value())
return {};
ASSERT(type_die_offset.value().type == Dwarf::DIE::AttributeValue::Type::DieReference);
VERIFY(type_die_offset.value().type == Dwarf::DIE::AttributeValue::Type::DieReference);
auto type_die = variable_die.get_die_at_offset(type_die_offset.value().data.as_u32);
auto type_name = type_die.get_attribute(Dwarf::Attribute::Name);
@ -241,7 +241,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
auto value = Dwarf::Expression::evaluate(expression_bytes, regs);
if (value.type != Dwarf::Expression::Type::None) {
ASSERT(value.type == Dwarf::Expression::Type::UnsignedIntetger);
VERIFY(value.type == Dwarf::Expression::Type::UnsignedIntetger);
variable_info.location_type = DebugInfo::VariableInfo::LocationType::Address;
variable_info.location_data.address = value.data.as_u32;
}
@ -254,7 +254,7 @@ static void parse_variable_location(const Dwarf::DIE& variable_die, DebugInfo::V
OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE& variable_die, const PtraceRegisters& regs) const
{
ASSERT(variable_die.tag() == Dwarf::EntryTag::Variable
VERIFY(variable_die.tag() == Dwarf::EntryTag::Variable
|| variable_die.tag() == Dwarf::EntryTag::Member
|| variable_die.tag() == Dwarf::EntryTag::FormalParameter
|| variable_die.tag() == Dwarf::EntryTag::EnumerationType
@ -274,7 +274,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (variable_die.tag() == Dwarf::EntryTag::Enumerator) {
auto constant = variable_die.get_attribute(Dwarf::Attribute::ConstValue);
ASSERT(constant.has_value());
VERIFY(constant.has_value());
switch (constant.value().type) {
case Dwarf::DIE::AttributeValue::Type::UnsignedNumber:
variable_info->constant_data.as_u32 = constant.value().data.as_u32;
@ -286,7 +286,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
variable_info->constant_data.as_string = constant.value().data.as_string;
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
} else {
parse_variable_location(variable_die, *variable_info, regs);
@ -302,7 +302,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (member.is_null())
return;
auto member_variable = create_variable_info(member, regs);
ASSERT(member_variable);
VERIFY(member_variable);
if (type_die.value().tag() == Dwarf::EntryTag::EnumerationType) {
member_variable->parent = type_info.ptr();
@ -311,7 +311,7 @@ OwnPtr<DebugInfo::VariableInfo> DebugInfo::create_variable_info(const Dwarf::DIE
if (variable_info->location_type == DebugInfo::VariableInfo::LocationType::None) {
return;
}
ASSERT(variable_info->location_type == DebugInfo::VariableInfo::LocationType::Address);
VERIFY(variable_info->location_type == DebugInfo::VariableInfo::LocationType::Address);
if (member_variable->location_type == DebugInfo::VariableInfo::LocationType::Address)
member_variable->location_data.address += variable_info->location_data.address;

View file

@ -73,7 +73,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(const String& command, String
}
auto parts = command.split(' ');
ASSERT(!parts.is_empty());
VERIFY(!parts.is_empty());
const char** args = (const char**)calloc(parts.size() + 1, sizeof(const char*));
for (size_t i = 0; i < parts.size(); i++) {
args[i] = parts[i].characters();
@ -155,7 +155,7 @@ bool DebugSession::insert_breakpoint(void* address)
if (!original_bytes.has_value())
return false;
ASSERT((original_bytes.value() & 0xff) != BREAKPOINT_INSTRUCTION);
VERIFY((original_bytes.value() & 0xff) != BREAKPOINT_INSTRUCTION);
BreakPoint breakpoint { address, original_bytes.value(), BreakPointState::Disabled };
@ -169,7 +169,7 @@ bool DebugSession::insert_breakpoint(void* address)
bool DebugSession::disable_breakpoint(void* address)
{
auto breakpoint = m_breakpoints.get(address);
ASSERT(breakpoint.has_value());
VERIFY(breakpoint.has_value());
if (!poke(reinterpret_cast<u32*>(reinterpret_cast<char*>(breakpoint.value().address)), breakpoint.value().original_first_word))
return false;
@ -182,9 +182,9 @@ bool DebugSession::disable_breakpoint(void* address)
bool DebugSession::enable_breakpoint(void* address)
{
auto breakpoint = m_breakpoints.get(address);
ASSERT(breakpoint.has_value());
VERIFY(breakpoint.has_value());
ASSERT(breakpoint.value().state == BreakPointState::Disabled);
VERIFY(breakpoint.value().state == BreakPointState::Disabled);
if (!poke(reinterpret_cast<u32*>(breakpoint.value().address), (breakpoint.value().original_first_word & ~(uint32_t)0xff) | BREAKPOINT_INSTRUCTION))
return false;
@ -214,7 +214,7 @@ PtraceRegisters DebugSession::get_registers() const
PtraceRegisters regs;
if (ptrace(PT_GETREGS, m_debuggee_pid, &regs, 0) < 0) {
perror("PT_GETREGS");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return regs;
}
@ -223,7 +223,7 @@ void DebugSession::set_registers(const PtraceRegisters& regs)
{
if (ptrace(PT_SETREGS, m_debuggee_pid, reinterpret_cast<void*>(&const_cast<PtraceRegisters&>(regs)), 0) < 0) {
perror("PT_SETREGS");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -232,7 +232,7 @@ void DebugSession::continue_debuggee(ContinueType type)
int command = (type == ContinueType::FreeRun) ? PT_CONTINUE : PT_SYSCALL;
if (ptrace(command, m_debuggee_pid, 0, 0) < 0) {
perror("continue");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -242,7 +242,7 @@ int DebugSession::continue_debuggee_and_wait(ContinueType type)
int wstatus = 0;
if (waitpid(m_debuggee_pid, &wstatus, WSTOPPED | WEXITED) != m_debuggee_pid) {
perror("waitpid");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return wstatus;
}
@ -264,7 +264,7 @@ void* DebugSession::single_step()
if (waitpid(m_debuggee_pid, 0, WSTOPPED) != m_debuggee_pid) {
perror("waitpid");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
regs = get_registers();
@ -316,7 +316,7 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
return {};
auto lib = library_at(address);
ASSERT(lib);
VERIFY(lib);
return InsertBreakpointAtSourcePositionResult { lib->name, address_and_source_position.value().file, address_and_source_position.value().line, address };
}
@ -325,11 +325,11 @@ void DebugSession::update_loaded_libs()
{
auto file = Core::File::construct(String::format("/proc/%u/vm", m_debuggee_pid));
bool rc = file->open(Core::IODevice::ReadOnly);
ASSERT(rc);
VERIFY(rc);
auto file_contents = file->read_all();
auto json = JsonValue::from_string(file_contents);
ASSERT(json.has_value());
VERIFY(json.has_value());
auto vm_entries = json.value().as_array();
Regex<PosixExtended> re("(.+): \\.text");

View file

@ -298,7 +298,7 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
break;
}
if (decision == DebugDecision::Kill) {
ASSERT_NOT_REACHED(); // TODO: implement
VERIFY_NOT_REACHED(); // TODO: implement
}
if (state == State::SingleStep && !did_single_step) {

View file

@ -46,7 +46,7 @@ DIE::DIE(const CompilationUnit& unit, u32 offset)
m_tag = EntryTag::None;
} else {
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
ASSERT(abbreviation_info.has_value());
VERIFY(abbreviation_info.has_value());
m_tag = abbreviation_info.value().tag;
m_has_children = abbreviation_info.value().has_children;
@ -76,7 +76,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::StringPointer: {
u32 offset;
debug_info_stream >> offset;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::String;
auto strings_data = m_compilation_unit.dwarf_info().debug_strings_data();
@ -86,7 +86,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data1: {
u8 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -94,7 +94,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data2: {
u16 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -102,7 +102,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Addr: {
u32 address;
debug_info_stream >> address;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = address;
break;
@ -110,7 +110,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::SData: {
ssize_t data;
debug_info_stream.read_LEB128_signed(data);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::SignedNumber;
value.data.as_i32 = data;
break;
@ -118,7 +118,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::SecOffset: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::SecOffset;
value.data.as_u32 = data;
break;
@ -126,7 +126,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Data4: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::UnsignedNumber;
value.data.as_u32 = data;
break;
@ -134,7 +134,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::Ref4: {
u32 data;
debug_info_stream >> data;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::DieReference;
value.data.as_u32 = data + m_compilation_unit.offset();
break;
@ -147,7 +147,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
case AttributeDataForm::ExprLoc: {
size_t length;
debug_info_stream.read_LEB128_unsigned(length);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::DwarfExpression;
assign_raw_bytes_value(length);
break;
@ -156,7 +156,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
String str;
u32 str_offset = debug_info_stream.offset();
debug_info_stream >> str;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
value.type = AttributeValue::Type::String;
value.data.as_string = reinterpret_cast<const char*>(str_offset + m_compilation_unit.dwarf_info().debug_info_data().data());
break;
@ -165,7 +165,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u8 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -173,7 +173,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u16 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -181,7 +181,7 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
u32 length;
debug_info_stream >> length;
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
@ -189,13 +189,13 @@ DIE::AttributeValue DIE::get_attribute_value(AttributeDataForm form,
value.type = AttributeValue::Type::RawBytes;
size_t length;
debug_info_stream.read_LEB128_unsigned(length);
ASSERT(!debug_info_stream.has_any_error());
VERIFY(!debug_info_stream.has_any_error());
assign_raw_bytes_value(length);
break;
}
default:
dbgln("Unimplemented AttributeDataForm: {}", (u32)form);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return value;
}
@ -206,7 +206,7 @@ Optional<DIE::AttributeValue> DIE::get_attribute(const Attribute& attribute) con
stream.discard_or_error(m_data_offset);
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
ASSERT(abbreviation_info.has_value());
VERIFY(abbreviation_info.has_value());
for (const auto& attribute_spec : abbreviation_info.value().attribute_specifications) {
auto value = get_attribute_value(attribute_spec.form, stream);
@ -251,7 +251,7 @@ void DIE::for_each_child(Function<void(const DIE& child)> callback) const
DIE DIE::get_die_at_offset(u32 offset) const
{
ASSERT(offset >= m_compilation_unit.offset() && offset < m_compilation_unit.offset() + m_compilation_unit.size());
VERIFY(offset >= m_compilation_unit.offset() && offset < m_compilation_unit.offset() + m_compilation_unit.size());
return DIE(m_compilation_unit, offset);
}

View file

@ -59,8 +59,8 @@ void DwarfInfo::populate_compilation_units()
CompilationUnitHeader compilation_unit_header {};
stream >> Bytes { &compilation_unit_header, sizeof(compilation_unit_header) };
ASSERT(compilation_unit_header.address_size == sizeof(u32));
ASSERT(compilation_unit_header.version <= 4);
VERIFY(compilation_unit_header.address_size == sizeof(u32));
VERIFY(compilation_unit_header.version <= 4);
u32 length_after_header = compilation_unit_header.length - (sizeof(CompilationUnitHeader) - offsetof(CompilationUnitHeader, version));
m_compilation_units.empend(*this, unit_offset, compilation_unit_header);

View file

@ -55,10 +55,10 @@ Value evaluate(ReadonlyBytes bytes, const PtraceRegisters& regs)
default:
dbgln("DWARF expr addr: {}", (const void*)bytes.data());
dbgln("unsupported opcode: {}", (u8)opcode);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -45,8 +45,8 @@ void LineProgram::parse_unit_header()
{
m_stream >> Bytes { &m_unit_header, sizeof(m_unit_header) };
ASSERT(m_unit_header.version == DWARF_VERSION);
ASSERT(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE);
VERIFY(m_unit_header.version == DWARF_VERSION);
VERIFY(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE);
#if DWARF_DEBUG
dbgln("unit length: {}", m_unit_header.length);
@ -67,7 +67,7 @@ void LineProgram::parse_source_directories()
}
m_stream.handle_recoverable_error();
m_stream.discard_or_error(1);
ASSERT(!m_stream.has_any_error());
VERIFY(!m_stream.has_any_error());
}
void LineProgram::parse_source_files()
@ -87,7 +87,7 @@ void LineProgram::parse_source_files()
m_source_files.append({ file_name, directory_index });
}
m_stream.discard_or_error(1);
ASSERT(!m_stream.has_any_error());
VERIFY(!m_stream.has_any_error());
}
void LineProgram::append_to_line_info()
@ -131,7 +131,7 @@ void LineProgram::handle_extended_opcode()
break;
}
case ExtendedOpcodes::SetAddress: {
ASSERT(length == sizeof(size_t) + 1);
VERIFY(length == sizeof(size_t) + 1);
m_stream >> m_address;
#if DWARF_DEBUG
dbgln("SetAddress: {:p}", m_address);
@ -149,7 +149,7 @@ void LineProgram::handle_extended_opcode()
#if DWARF_DEBUG
dbgln("offset: {:p}", m_stream.offset());
#endif
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
void LineProgram::handle_standard_opcode(u8 opcode)
@ -191,7 +191,7 @@ void LineProgram::handle_standard_opcode(u8 opcode)
case StandardOpcodes::AdvanceLine: {
ssize_t line_delta;
m_stream.read_LEB128_signed(line_delta);
ASSERT(line_delta >= 0 || m_line >= (size_t)(-line_delta));
VERIFY(line_delta >= 0 || m_line >= (size_t)(-line_delta));
m_line += line_delta;
#if DWARF_DEBUG
dbgln("AdvanceLine: {}", m_line);
@ -223,7 +223,7 @@ void LineProgram::handle_standard_opcode(u8 opcode)
}
default:
dbgln("Unhandled LineProgram opcode {}", opcode);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
void LineProgram::handle_sepcial_opcode(u8 opcode)

View file

@ -82,14 +82,14 @@ bool AppFile::validate() const
String AppFile::name() const
{
auto name = m_config->read_entry("App", "Name").trim_whitespace();
ASSERT(!name.is_empty());
VERIFY(!name.is_empty());
return name;
}
String AppFile::executable() const
{
auto executable = m_config->read_entry("App", "Executable").trim_whitespace();
ASSERT(!executable.is_empty());
VERIFY(!executable.is_empty());
return executable;
}

View file

@ -38,7 +38,7 @@ auto Launcher::Details::from_details_str(const String& details_str) -> NonnullRe
{
auto details = adopt(*new Details);
auto json = JsonValue::from_string(details_str);
ASSERT(json.has_value());
VERIFY(json.has_value());
auto obj = json.value().as_object();
details->executable = obj.get("executable").to_string();
details->name = obj.get("name").to_string();
@ -124,7 +124,7 @@ bool Launcher::open(const URL& url, const String& handler_name)
bool Launcher::open(const URL& url, const Details& details)
{
ASSERT(details.launcher_type != LauncherType::Application); // Launcher should not be used to execute arbitrary applications
VERIFY(details.launcher_type != LauncherType::Application); // Launcher should not be used to execute arbitrary applications
return open(url, details.executable);
}

View file

@ -110,13 +110,13 @@ HunkLocation parse_hunk_location(const String& location_line)
};
while (char_index < location_line.length() && location_line[char_index++] != '-') {
}
ASSERT(char_index < location_line.length());
VERIFY(char_index < location_line.length());
size_t original_location_start_index = char_index;
while (char_index < location_line.length() && location_line[char_index++] != ' ') {
}
ASSERT(char_index < location_line.length() && location_line[char_index] == '+');
VERIFY(char_index < location_line.length() && location_line[char_index] == '+');
size_t original_location_end_index = char_index - 2;
size_t target_location_start_index = char_index + 1;
@ -124,7 +124,7 @@ HunkLocation parse_hunk_location(const String& location_line)
char_index += 1;
while (char_index < location_line.length() && location_line[char_index++] != ' ') {
}
ASSERT(char_index < location_line.length());
VERIFY(char_index < location_line.length());
size_t target_location_end_index = char_index - 2;

View file

@ -87,7 +87,7 @@ static void map_library(const String& name, int fd)
auto loader = ELF::DynamicLoader::try_create(fd, name);
if (!loader) {
dbgln("Failed to create ELF::DynamicLoader for fd={}, name={}", fd, name);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
loader->set_tls_offset(g_current_tls_offset);
@ -101,7 +101,7 @@ static void map_library(const String& name)
// TODO: Do we want to also look for libs in other paths too?
String path = String::formatted("/usr/lib/{}", name);
int fd = open(path.characters(), O_RDONLY);
ASSERT(fd >= 0);
VERIFY(fd >= 0);
map_library(name, fd);
}
@ -162,19 +162,19 @@ static void initialize_libc(DynamicObject& libc)
// Also, we can't just mark `__libc_init` with "__attribute__((constructor))"
// because it uses getenv() internally, so `environ` has to be initialized before we call `__libc_init`.
auto res = libc.lookup_symbol("environ");
ASSERT(res.has_value());
VERIFY(res.has_value());
*((char***)res.value().address.as_ptr()) = g_envp;
res = libc.lookup_symbol("__environ_is_malloced");
ASSERT(res.has_value());
VERIFY(res.has_value());
*((bool*)res.value().address.as_ptr()) = false;
res = libc.lookup_symbol("exit");
ASSERT(res.has_value());
VERIFY(res.has_value());
g_libc_exit = (LibCExitFunction)res.value().address.as_ptr();
res = libc.lookup_symbol("__libc_init");
ASSERT(res.has_value());
VERIFY(res.has_value());
typedef void libc_init_func();
((libc_init_func*)res.value().address.as_ptr())();
}
@ -203,12 +203,12 @@ static void load_elf(const String& name)
{
for_each_dependency_of(name, [](auto& loader) {
auto dynamic_object = loader.map();
ASSERT(dynamic_object);
VERIFY(dynamic_object);
g_global_objects.append(*dynamic_object);
});
for_each_dependency_of(name, [](auto& loader) {
bool success = loader.link(RTLD_GLOBAL | RTLD_LAZY, g_total_tls_size);
ASSERT(success);
VERIFY(success);
});
}
@ -223,11 +223,11 @@ static NonnullRefPtr<DynamicLoader> commit_elf(const String& name)
}
auto object = loader->load_stage_3(RTLD_GLOBAL | RTLD_LAZY, g_total_tls_size);
ASSERT(object);
VERIFY(object);
if (name == "libsystem.so") {
if (syscall(SC_msyscall, object->base_address().as_ptr())) {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -288,7 +288,7 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
int rc = syscall(SC_msyscall, nullptr);
if (rc < 0) {
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
rc = main_function(argc, argv, envp);
@ -299,7 +299,7 @@ void ELF::DynamicLinker::linker_main(String&& main_program_name, int main_progra
_exit(rc);
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}

View file

@ -60,7 +60,7 @@ RefPtr<DynamicLoader> DynamicLoader::try_create(int fd, String filename)
return {};
}
ASSERT(stat.st_size >= 0);
VERIFY(stat.st_size >= 0);
auto size = static_cast<size_t>(stat.st_size);
if (size < sizeof(Elf32_Ehdr))
return {};
@ -90,11 +90,11 @@ DynamicLoader::~DynamicLoader()
{
if (munmap(m_file_data, m_file_size) < 0) {
perror("munmap");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (close(m_image_fd) < 0) {
perror("close");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -109,7 +109,7 @@ const DynamicObject& DynamicLoader::dynamic_object() const
}
return IterationDecision::Continue;
});
ASSERT(!dynamic_section_address.is_null());
VERIFY(!dynamic_section_address.is_null());
m_cached_dynamic_object = ELF::DynamicObject::create(VirtualAddress(m_elf_image.base_address()), dynamic_section_address);
}
@ -154,7 +154,7 @@ void* DynamicLoader::symbol_for_name(const StringView& name)
RefPtr<DynamicObject> DynamicLoader::map()
{
ASSERT(!m_dynamic_object);
VERIFY(!m_dynamic_object);
if (!m_valid) {
dbgln("DynamicLoader::map failed: image is invalid");
@ -177,10 +177,10 @@ bool DynamicLoader::link(unsigned flags, size_t total_tls_size)
bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size)
{
ASSERT(flags & RTLD_GLOBAL);
VERIFY(flags & RTLD_GLOBAL);
if (m_dynamic_object->has_text_relocations()) {
ASSERT(m_text_segment_load_address.get() != 0);
VERIFY(m_text_segment_load_address.get() != 0);
#ifndef AK_OS_MACOS
// Remap this text region as private.
@ -205,7 +205,7 @@ void DynamicLoader::do_main_relocations(size_t total_tls_size)
switch (do_relocation(total_tls_size, relocation)) {
case RelocationResult::Failed:
dbgln("Loader.so: {} unresolved symbol '{}'", m_filename, relocation.symbol().name());
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
case RelocationResult::ResolveLater:
m_unresolved_relocations.append(relocation);
break;
@ -254,7 +254,7 @@ void DynamicLoader::do_lazy_relocations(size_t total_tls_size)
for (const auto& relocation : m_unresolved_relocations) {
if (auto res = do_relocation(total_tls_size, relocation); res != RelocationResult::Success) {
dbgln("Loader.so: {} unresolved symbol '{}'", m_filename, relocation.symbol().name());
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
}
@ -272,27 +272,27 @@ void DynamicLoader::load_program_headers()
ProgramHeaderRegion region {};
region.set_program_header(program_header.raw_header());
if (region.is_tls_template()) {
ASSERT(!tls_region.has_value());
VERIFY(!tls_region.has_value());
tls_region = region;
} else if (region.is_load()) {
if (region.is_executable()) {
ASSERT(!text_region.has_value());
VERIFY(!text_region.has_value());
text_region = region;
} else {
ASSERT(!data_region.has_value());
VERIFY(!data_region.has_value());
data_region = region;
}
} else if (region.is_dynamic()) {
dynamic_region_desired_vaddr = region.desired_load_address();
} else if (region.is_relro()) {
ASSERT(!relro_region.has_value());
VERIFY(!relro_region.has_value());
relro_region = region;
}
return IterationDecision::Continue;
});
ASSERT(text_region.has_value());
ASSERT(data_region.has_value());
VERIFY(text_region.has_value());
VERIFY(data_region.has_value());
// Process regions in order: .text, .data, .tls
void* requested_load_address = m_elf_image.is_dynamic() ? nullptr : text_region.value().desired_load_address().as_ptr();
@ -303,7 +303,7 @@ void DynamicLoader::load_program_headers()
else
reservation_mmap_flags |= MAP_FIXED;
ASSERT(!text_region.value().is_writable());
VERIFY(!text_region.value().is_writable());
// First, we make a dummy reservation mapping, in order to allocate enough VM
// to hold both text+data contiguously in the address space.
@ -321,13 +321,13 @@ void DynamicLoader::load_program_headers()
auto* reservation = mmap(requested_load_address, total_mapping_size, PROT_NONE, reservation_mmap_flags, 0, 0);
if (reservation == MAP_FAILED) {
perror("mmap reservation");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
// Then we unmap the reservation.
if (munmap(reservation, total_mapping_size) < 0) {
perror("munmap reservation");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
// Now we can map the text segment at the reserved address.
@ -342,10 +342,10 @@ void DynamicLoader::load_program_headers()
if (text_segment_begin == MAP_FAILED) {
perror("mmap text");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ASSERT(requested_load_address == nullptr || requested_load_address == text_segment_begin);
VERIFY(requested_load_address == nullptr || requested_load_address == text_segment_begin);
m_text_segment_size = text_segment_size;
m_text_segment_load_address = VirtualAddress { (FlatPtr)text_segment_begin };
@ -375,7 +375,7 @@ void DynamicLoader::load_program_headers()
if (MAP_FAILED == data_segment) {
perror("mmap data");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
VirtualAddress data_segment_start;
@ -409,7 +409,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
if (symbol.bind() == STB_WEAK)
return RelocationResult::ResolveLater;
dbgln("ERROR: symbol not found: {}.", symbol.name());
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
auto symbol_address = res.value().address;
*patch_ptr += symbol_address.get();
@ -418,7 +418,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
case R_386_PC32: {
auto symbol = relocation.symbol();
auto result = lookup_symbol(symbol);
ASSERT(result.has_value());
VERIFY(result.has_value());
auto relative_offset = result.value().address - m_dynamic_object->base_address().offset(relocation.offset());
*patch_ptr += relative_offset.get();
break;
@ -440,7 +440,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
return RelocationResult::Failed;
}
auto symbol_location = res.value().address;
ASSERT(symbol_location != m_dynamic_object->base_address());
VERIFY(symbol_location != m_dynamic_object->base_address());
*patch_ptr = symbol_location.get();
break;
}
@ -462,7 +462,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
break;
u32 symbol_value = res.value().value;
auto* dynamic_object_of_symbol = res.value().dynamic_object;
ASSERT(dynamic_object_of_symbol);
VERIFY(dynamic_object_of_symbol);
size_t offset_of_tls_end = dynamic_object_of_symbol->tls_offset().value() + dynamic_object_of_symbol->tls_size().value();
*patch_ptr = (offset_of_tls_end - total_tls_size - symbol_value - sizeof(Elf32_Addr));
break;
@ -484,7 +484,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(size_t total_tls_si
default:
// Raise the alarm! Someone needs to implement this relocation type
dbgln("Found a new exciting relocation type {}", relocation.type());
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return RelocationResult::Success;
}
@ -494,8 +494,8 @@ extern "C" void _plt_trampoline(void) __attribute__((visibility("hidden")));
void DynamicLoader::setup_plt_trampoline()
{
ASSERT(m_dynamic_object);
ASSERT(m_dynamic_object->has_plt());
VERIFY(m_dynamic_object);
VERIFY(m_dynamic_object->has_plt());
VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
auto* got_ptr = (FlatPtr*)got_address.as_ptr();

View file

@ -129,7 +129,7 @@ void DynamicObject::parse()
break;
case DT_PLTREL:
m_procedure_linkage_table_relocation_type = entry.val();
ASSERT(m_procedure_linkage_table_relocation_type & (DT_REL | DT_RELA));
VERIFY(m_procedure_linkage_table_relocation_type & (DT_REL | DT_RELA));
break;
case DT_JMPREL:
m_plt_relocation_offset_location = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
@ -172,7 +172,7 @@ void DynamicObject::parse()
break;
default:
dbgln("DynamicObject: DYNAMIC tag handling not implemented for DT_{}", name_for_dtag(entry.tag()));
ASSERT_NOT_REACHED(); // FIXME: Maybe just break out here and return false?
VERIFY_NOT_REACHED(); // FIXME: Maybe just break out here and return false?
break;
}
return IterationDecision::Continue;
@ -193,7 +193,7 @@ void DynamicObject::parse()
DynamicObject::Relocation DynamicObject::RelocationSection::relocation(unsigned index) const
{
ASSERT(index < entry_count());
VERIFY(index < entry_count());
unsigned offset_in_section = index * entry_size();
auto relocation_address = (Elf32_Rel*)address().offset(offset_in_section).as_ptr();
return Relocation(m_dynamic, *relocation_address, offset_in_section);
@ -201,7 +201,7 @@ DynamicObject::Relocation DynamicObject::RelocationSection::relocation(unsigned
DynamicObject::Relocation DynamicObject::RelocationSection::relocation_at_offset(unsigned offset) const
{
ASSERT(offset <= (m_section_size_bytes - m_entry_size));
VERIFY(offset <= (m_section_size_bytes - m_entry_size));
auto relocation_address = (Elf32_Rel*)address().offset(offset).as_ptr();
return Relocation(m_dynamic, *relocation_address, offset);
}
@ -323,7 +323,7 @@ const char* DynamicObject::raw_symbol_string_table_string(Elf32_Word index) cons
DynamicObject::InitializationFunction DynamicObject::init_section_function() const
{
ASSERT(has_init_section());
VERIFY(has_init_section());
return (InitializationFunction)init_section().address().as_ptr();
}
@ -444,14 +444,14 @@ NonnullRefPtr<DynamicObject> DynamicObject::create(VirtualAddress base_address,
VirtualAddress DynamicObject::patch_plt_entry(u32 relocation_offset)
{
auto relocation = plt_relocation_section().relocation_at_offset(relocation_offset);
ASSERT(relocation.type() == R_386_JMP_SLOT);
VERIFY(relocation.type() == R_386_JMP_SLOT);
auto symbol = relocation.symbol();
u8* relocation_address = relocation.address().as_ptr();
auto result = DynamicLoader::lookup_symbol(symbol);
if (!result.has_value()) {
dbgln("did not find symbol: {}", symbol.name());
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
auto symbol_location = result.value().address;

View file

@ -74,7 +74,7 @@ static const char* object_file_type_to_string(Elf32_Half type)
StringView Image::section_index_to_string(unsigned index) const
{
ASSERT(m_valid);
VERIFY(m_valid);
if (index == SHN_UNDEF)
return "Undefined";
if (index >= SHN_LORESERVE)
@ -84,7 +84,7 @@ StringView Image::section_index_to_string(unsigned index) const
unsigned Image::symbol_count() const
{
ASSERT(m_valid);
VERIFY(m_valid);
if (!section_count())
return 0;
return section(m_symbol_table_section_index).entry_count();
@ -146,13 +146,13 @@ void Image::dump() const
unsigned Image::section_count() const
{
ASSERT(m_valid);
VERIFY(m_valid);
return header().e_shnum;
}
unsigned Image::program_header_count() const
{
ASSERT(m_valid);
VERIFY(m_valid);
return header().e_phnum;
}
@ -191,7 +191,7 @@ bool Image::parse()
StringView Image::table_string(unsigned table_index, unsigned offset) const
{
ASSERT(m_valid);
VERIFY(m_valid);
auto& sh = section_header(table_index);
if (sh.sh_type != SHT_STRTAB)
return nullptr;
@ -208,67 +208,67 @@ StringView Image::table_string(unsigned table_index, unsigned offset) const
StringView Image::section_header_table_string(unsigned offset) const
{
ASSERT(m_valid);
VERIFY(m_valid);
return table_string(header().e_shstrndx, offset);
}
StringView Image::table_string(unsigned offset) const
{
ASSERT(m_valid);
VERIFY(m_valid);
return table_string(m_string_table_section_index, offset);
}
const char* Image::raw_data(unsigned offset) const
{
ASSERT(offset < m_size); // Callers must check indices into raw_data()'s result are also in bounds.
VERIFY(offset < m_size); // Callers must check indices into raw_data()'s result are also in bounds.
return reinterpret_cast<const char*>(m_buffer) + offset;
}
const Elf32_Ehdr& Image::header() const
{
ASSERT(m_size >= sizeof(Elf32_Ehdr));
VERIFY(m_size >= sizeof(Elf32_Ehdr));
return *reinterpret_cast<const Elf32_Ehdr*>(raw_data(0));
}
const Elf32_Phdr& Image::program_header_internal(unsigned index) const
{
ASSERT(m_valid);
ASSERT(index < header().e_phnum);
VERIFY(m_valid);
VERIFY(index < header().e_phnum);
return *reinterpret_cast<const Elf32_Phdr*>(raw_data(header().e_phoff + (index * sizeof(Elf32_Phdr))));
}
const Elf32_Shdr& Image::section_header(unsigned index) const
{
ASSERT(m_valid);
ASSERT(index < header().e_shnum);
VERIFY(m_valid);
VERIFY(index < header().e_shnum);
return *reinterpret_cast<const Elf32_Shdr*>(raw_data(header().e_shoff + (index * header().e_shentsize)));
}
Image::Symbol Image::symbol(unsigned index) const
{
ASSERT(m_valid);
ASSERT(index < symbol_count());
VERIFY(m_valid);
VERIFY(index < symbol_count());
auto* raw_syms = reinterpret_cast<const Elf32_Sym*>(raw_data(section(m_symbol_table_section_index).offset()));
return Symbol(*this, index, raw_syms[index]);
}
Image::Section Image::section(unsigned index) const
{
ASSERT(m_valid);
ASSERT(index < section_count());
VERIFY(m_valid);
VERIFY(index < section_count());
return Section(*this, index);
}
Image::ProgramHeader Image::program_header(unsigned index) const
{
ASSERT(m_valid);
ASSERT(index < program_header_count());
VERIFY(m_valid);
VERIFY(index < program_header_count());
return ProgramHeader(*this, index);
}
Image::Relocation Image::RelocationSection::relocation(unsigned index) const
{
ASSERT(index < relocation_count());
VERIFY(index < relocation_count());
auto* rels = reinterpret_cast<const Elf32_Rel*>(m_image.raw_data(offset()));
return Relocation(m_image, rels[index]);
}
@ -291,7 +291,7 @@ Image::RelocationSection Image::Section::relocations() const
Image::Section Image::lookup_section(const String& name) const
{
ASSERT(m_valid);
VERIFY(m_valid);
for (unsigned i = 0; i < section_count(); ++i) {
auto section = this->section(i);
if (section.name() == name)

View file

@ -219,7 +219,7 @@ bool validate_program_headers(const Elf32_Ehdr& elf_header, size_t file_size, co
if (file_size < buffer_size) {
dbgln("We somehow read more from a file than was in the file in the first place!");
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
size_t num_program_headers = elf_header.e_phnum;

View file

@ -65,7 +65,7 @@ void AbstractSlider::set_page_step(int page_step)
void AbstractSlider::set_range(int min, int max)
{
ASSERT(min <= max);
VERIFY(min <= max);
if (m_min == min && m_max == max)
return;
m_min = min;

View file

@ -140,8 +140,8 @@ void AbstractView::update_edit_widget_position()
void AbstractView::begin_editing(const ModelIndex& index)
{
ASSERT(is_editable());
ASSERT(model());
VERIFY(is_editable());
VERIFY(model());
if (m_edit_index == index)
return;
if (!model()->is_editable(index))
@ -152,7 +152,7 @@ void AbstractView::begin_editing(const ModelIndex& index)
}
m_edit_index = index;
ASSERT(aid_create_editing_delegate);
VERIFY(aid_create_editing_delegate);
m_editing_delegate = aid_create_editing_delegate(index);
m_editing_delegate->bind(*model(), index);
m_editing_delegate->set_value(index.data());
@ -164,12 +164,12 @@ void AbstractView::begin_editing(const ModelIndex& index)
m_edit_widget->set_focus(true);
m_editing_delegate->will_begin_editing();
m_editing_delegate->on_commit = [this] {
ASSERT(model());
VERIFY(model());
model()->set_data(m_edit_index, m_editing_delegate->value());
stop_editing();
};
m_editing_delegate->on_rollback = [this] {
ASSERT(model());
VERIFY(model());
stop_editing();
};
}
@ -298,7 +298,7 @@ void AbstractView::mousemove_event(MouseEvent& event)
if (distance_travelled_squared <= drag_distance_threshold)
return ScrollableWidget::mousemove_event(event);
ASSERT(!data_type.is_null());
VERIFY(!data_type.is_null());
if (m_is_dragging)
return;
@ -323,7 +323,7 @@ void AbstractView::mousemove_event(MouseEvent& event)
dbgln("Drag was cancelled!");
break;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}

View file

@ -105,7 +105,7 @@ public:
bool is_checked() const
{
ASSERT(is_checkable());
VERIFY(is_checkable());
return m_checked;
}
void set_checked(bool);

View file

@ -82,7 +82,7 @@ Application* Application::the()
Application::Application(int argc, char** argv)
{
ASSERT(!*s_the);
VERIFY(!*s_the);
*s_the = *this;
m_event_loop = make<Core::EventLoop>();
WindowServerConnection::the();
@ -212,7 +212,7 @@ Gfx::Palette Application::palette() const
void Application::tooltip_show_timer_did_fire()
{
ASSERT(m_tooltip_window);
VERIFY(m_tooltip_window);
Gfx::IntRect desktop_rect = Desktop::the().rect();
const int margin = 30;

View file

@ -196,7 +196,7 @@ void AutocompleteBox::apply_suggestion()
auto suggestion = suggestion_index.data().to_string();
size_t partial_length = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::PartialInputLength).to_i64();
ASSERT(suggestion.length() >= partial_length);
VERIFY(suggestion.length() >= partial_length);
auto completion = suggestion.substring_view(partial_length, suggestion.length() - partial_length);
m_editor->insert_at_cursor_or_replace_selection(completion);
}

View file

@ -59,7 +59,7 @@ public:
void attach(TextEditor& editor)
{
ASSERT(!m_editor);
VERIFY(!m_editor);
m_editor = editor;
}
void detach() { m_editor.clear(); }

View file

@ -136,7 +136,7 @@ void BreadcrumbBar::set_selected_segment(Optional<size_t> index)
}
auto& segment = m_segments[index.value()];
ASSERT(segment.button);
VERIFY(segment.button);
segment.button->set_checked(true);
}

View file

@ -69,7 +69,7 @@ void ColumnsView::select_all()
return;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
});
for (Column& column : columns_for_selection) {
@ -102,12 +102,12 @@ void ColumnsView::paint_event(PaintEvent& event)
auto& column = m_columns[i];
auto* next_column = i + 1 == m_columns.size() ? nullptr : &m_columns[i + 1];
ASSERT(column.width > 0);
VERIFY(column.width > 0);
int row_count = model()->row_count(column.parent_index);
for (int row = 0; row < row_count; row++) {
ModelIndex index = model()->index(row, m_model_column, column.parent_index);
ASSERT(index.is_valid());
VERIFY(index.is_valid());
bool is_selected_row = selection().contains(index);
@ -180,7 +180,7 @@ void ColumnsView::paint_event(PaintEvent& event)
void ColumnsView::push_column(const ModelIndex& parent_index)
{
ASSERT(model());
VERIFY(model());
// Drop columns at the end.
ModelIndex grandparent = model()->parent_index(parent_index);
@ -216,7 +216,7 @@ void ColumnsView::update_column_sizes()
column.width = 10;
for (int row = 0; row < row_count; row++) {
ModelIndex index = model()->index(row, m_model_column, column.parent_index);
ASSERT(index.is_valid());
VERIFY(index.is_valid());
auto text = index.data().to_string();
int row_width = icon_spacing() + icon_size() + icon_spacing() + font().width(text) + icon_spacing() + s_arrow_bitmap_width + icon_spacing();
if (row_width > column.width)

View file

@ -118,7 +118,7 @@ ComboBox::ComboBox()
m_list_view->set_frame_thickness(1);
m_list_view->set_frame_shadow(Gfx::FrameShadow::Plain);
m_list_view->on_selection = [this](auto& index) {
ASSERT(model());
VERIFY(model());
m_list_view->set_activates_on_selection(true);
if (m_updating_model)
selection_updated(index);

View file

@ -43,7 +43,7 @@ Dialog::~Dialog()
int Dialog::exec()
{
ASSERT(!m_event_loop);
VERIFY(!m_event_loop);
m_event_loop = make<Core::EventLoop>();
if (parent() && is<Window>(parent())) {
auto& parent_window = *static_cast<Window*>(parent());

View file

@ -73,7 +73,7 @@ i32 DisplayLink::register_callback(Function<void(i32)> callback)
bool DisplayLink::unregister_callback(i32 callback_id)
{
ASSERT(callbacks().contains(callback_id));
VERIFY(callbacks().contains(callback_id));
callbacks().remove(callback_id);
if (callbacks().is_empty())

View file

@ -46,9 +46,9 @@ DragOperation::~DragOperation()
DragOperation::Outcome DragOperation::exec()
{
ASSERT(!s_current_drag_operation);
ASSERT(!m_event_loop);
ASSERT(m_mime_data);
VERIFY(!s_current_drag_operation);
VERIFY(!m_event_loop);
VERIFY(m_mime_data);
Gfx::ShareableBitmap drag_bitmap;
if (m_mime_data->has_format("image/x-raw-bitmap")) {
@ -79,14 +79,14 @@ DragOperation::Outcome DragOperation::exec()
void DragOperation::done(Outcome outcome)
{
ASSERT(m_outcome == Outcome::None);
VERIFY(m_outcome == Outcome::None);
m_outcome = outcome;
m_event_loop->quit(0);
}
void DragOperation::notify_accepted(Badge<WindowServerConnection>)
{
ASSERT(s_current_drag_operation);
VERIFY(s_current_drag_operation);
s_current_drag_operation->done(Outcome::Accepted);
}

View file

@ -36,13 +36,13 @@ EditingEngine::~EditingEngine()
void EditingEngine::attach(TextEditor& editor)
{
ASSERT(!m_editor);
VERIFY(!m_editor);
m_editor = editor;
}
void EditingEngine::detach()
{
ASSERT(m_editor);
VERIFY(m_editor);
m_editor = nullptr;
}
@ -450,7 +450,7 @@ TextPosition EditingEngine::find_beginning_of_next_word()
has_seen_whitespace = true;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EditingEngine::move_to_beginning_of_next_word()
@ -516,7 +516,7 @@ TextPosition EditingEngine::find_end_of_next_word()
is_first_iteration = false;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EditingEngine::move_to_end_of_next_word()
@ -584,7 +584,7 @@ TextPosition EditingEngine::find_end_of_previous_word()
has_seen_whitespace = true;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EditingEngine::move_to_end_of_previous_word()
@ -648,7 +648,7 @@ TextPosition EditingEngine::find_beginning_of_previous_word()
is_first_iteration = false;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void EditingEngine::move_to_beginning_of_previous_word()
@ -689,7 +689,7 @@ void EditingEngine::move_selected_lines_down()
get_selection_line_boundaries(first_line, last_line);
auto& lines = m_editor->document().lines();
ASSERT(lines.size() != 0);
VERIFY(lines.size() != 0);
if (last_line >= lines.size() - 1)
return;

View file

@ -240,7 +240,7 @@ Icon FileIconProvider::icon_for_path(const String& path, mode_t mode)
for (auto size : target_icon.sizes()) {
auto& emblem = size < 32 ? *s_symlink_emblem_small : *s_symlink_emblem;
auto original_bitmap = target_icon.bitmap_for_size(size);
ASSERT(original_bitmap);
VERIFY(original_bitmap);
auto generated_bitmap = original_bitmap->clone();
if (!generated_bitmap) {
dbgln("Failed to clone {}x{} icon for symlink variant", size, size);

View file

@ -99,7 +99,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_
auto& widget = set_main_widget<GUI::Widget>();
if (!widget.load_from_gml(file_picker_dialog_gml))
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
auto& toolbar = *widget.find_descendant_of_type_named<GUI::ToolBar>("toolbar");
toolbar.set_has_frame(false);

View file

@ -53,7 +53,7 @@ ModelIndex FileSystemModel::Node::index(int column) const
if (&parent->children[row] == this)
return m_model.create_index(row, column, const_cast<Node*>(this));
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool FileSystemModel::Node::fetch_data(const String& full_path, bool is_root)
@ -340,7 +340,7 @@ const FileSystemModel::Node& FileSystemModel::node(const ModelIndex& index) cons
{
if (!index.is_valid())
return *m_root;
ASSERT(index.internal_data());
VERIFY(index.internal_data());
return *(Node*)index.internal_data();
}
@ -361,7 +361,7 @@ ModelIndex FileSystemModel::parent_index(const ModelIndex& index) const
return {};
auto& node = this->node(index);
if (!node.parent) {
ASSERT(&node == m_root);
VERIFY(&node == m_root);
return {};
}
return node.parent->index(index.column());
@ -369,7 +369,7 @@ ModelIndex FileSystemModel::parent_index(const ModelIndex& index) const
Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
{
ASSERT(index.is_valid());
VERIFY(index.is_valid());
if (role == ModelRole::TextAlignment) {
switch (index.column()) {
@ -386,7 +386,7 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
case Column::SymlinkTarget:
return Gfx::TextAlignment::CenterLeft;
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
}
@ -394,7 +394,7 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
if (role == ModelRole::Custom) {
// For GUI::FileSystemModel, custom role means the full path.
ASSERT(index.column() == Column::Name);
VERIFY(index.column() == Column::Name);
return node.full_path();
}
@ -429,7 +429,7 @@ Variant FileSystemModel::data(const ModelIndex& index, ModelRole role) const
case Column::SymlinkTarget:
return node.symlink_target;
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (role == ModelRole::Display) {
@ -581,7 +581,7 @@ String FileSystemModel::column_name(int column) const
case Column::SymlinkTarget:
return "Symlink target";
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool FileSystemModel::accepts_drag(const ModelIndex& index, const Vector<String>& mime_types) const
@ -611,7 +611,7 @@ bool FileSystemModel::is_editable(const ModelIndex& index) const
void FileSystemModel::set_data(const ModelIndex& index, const Variant& data)
{
ASSERT(is_editable(index));
VERIFY(is_editable(index));
Node& node = const_cast<Node&>(this->node(index));
auto dirname = LexicalPath(node.full_path()).dirname();
auto new_full_path = String::formatted("{}/{}", dirname, data.to_string());

Some files were not shown because too many files have changed in this diff Show more