removed lots of asserts
Some of them relied on the side effects of evaluating their argument but
for most of them it just makes more sense to use CHECK.
diff --git a/aos/linux_code/starter/netconsole.cc b/aos/linux_code/starter/netconsole.cc
index 4d32afe..c4ca5b9 100644
--- a/aos/linux_code/starter/netconsole.cc
+++ b/aos/linux_code/starter/netconsole.cc
@@ -7,7 +7,6 @@
#include <fcntl.h>
#include <pthread.h>
#include <sys/stat.h>
-#include <assert.h>
#include "aos/common/logging/logging_impl.h"
#include "aos/common/util/inet_addr.h"
@@ -33,8 +32,8 @@
char buffer[32768];
ssize_t position = 0;
while (true) {
- assert(position >= 0);
- assert(position <= static_cast<ssize_t>(sizeof(buffer)));
+ CHECK_GE(position, 0);
+ CHECK_LE(position, static_cast<ssize_t>(sizeof(buffer)));
if (position != sizeof(buffer)) {
ssize_t read_bytes;
bool good_data = true;
@@ -73,7 +72,7 @@
}
}
if (to_copy->source_address != nullptr) {
- assert(header.msg_namelen >= sizeof(struct sockaddr_in));
+ CHECK_GE(header.msg_namelen, sizeof(struct sockaddr_in));
if (to_copy->source_address->sin_port != hton<uint16_t>(0)) {
if (sender_address.sin_port !=
to_copy->source_address->sin_port) {
@@ -104,8 +103,8 @@
}
}
- assert(position >= 0);
- assert(position <= static_cast<ssize_t>(sizeof(buffer)));
+ CHECK_GE(position, 0);
+ CHECK_LE(position, static_cast<ssize_t>(sizeof(buffer)));
if (position > 0) {
ssize_t sent_bytes = write(to_copy->output, buffer, position);
if (sent_bytes == -1) {
diff --git a/aos/linux_code/starter/starter.cc b/aos/linux_code/starter/starter.cc
index 59aa88d..0fbb7ed 100644
--- a/aos/linux_code/starter/starter.cc
+++ b/aos/linux_code/starter/starter.cc
@@ -10,7 +10,6 @@
#include <sys/inotify.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <assert.h>
#include <signal.h>
#include <stdint.h>
#include <errno.h>
@@ -114,8 +113,8 @@
// After calling this method, this object won't really be doing much of
// anything besides possibly running its callback or something.
void RemoveWatch() {
- assert(watch_ != -1);
- assert(watch_to_remove_ == -1);
+ CHECK_NE(watch_, -1);
+ CHECK_EQ(watch_to_remove_, -1);
if (inotify_rm_watch(notify_fd, watch_) == -1) {
PLOG(WARNING, "inotify_rm_watch(%d, %d) failed", notify_fd, watch_);
@@ -139,7 +138,7 @@
void RemoveWatchFromMap() {
int watch = watch_to_remove_;
if (watch == -1) {
- assert(watch_ != -1);
+ CHECK_NE(watch, -1);
watch = watch_;
}
if (watchers[watch] != this) {
@@ -157,7 +156,7 @@
}
void CreateWatch() {
- assert(watch_ == -1);
+ CHECK_EQ(watch_, -1);
watch_ = inotify_add_watch(notify_fd, filename_.c_str(),
create_ ? IN_CREATE : (IN_ATTRIB |
IN_MODIFY |
@@ -227,7 +226,7 @@
// INotifyReadable calls this method whenever the watch for our file triggers.
void FileNotified(const char *filename) {
- assert(watch_ != -1);
+ CHECK_NE(watch_, -1);
LOG(DEBUG, "got a notification for %s\n", filename_.c_str());
if (!check_filename_.empty()) {