: (X) <= UINT_MAX / (Y) ? (unsigned int) (X) * (unsigned int) (Y) \
: UINT_MAX)
+/* A special function that is intended to explicitly ignore results of
+ * functions marked with __attribute__((warn_unused_result)), if necessary. */
+void ovs_ignore(bool);
+
/* Like the standard assert macro, except:
*
* - Writes the failure message to the log.
? (void) 0 \
: ovs_assert_failure(OVS_SOURCE_LOCATOR, __func__, #CONDITION))
#else
-#define ovs_assert(CONDITION) ((void) (CONDITION))
+#define ovs_assert ovs_ignore
#endif
OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
}
aio_suspend(&p, 1, NULL);
} else {
- ignore(aio_return(aiocb));
+ ovs_ignore(aio_return(aiocb));
ap->aiocb_tail++;
byteq_advance_tail(&ap->byteq, aiocb->aio_nbytes);
n++;
aiocb->aio_sigevent.sigev_notify = SIGEV_NONE;
if (aio_write(aiocb) == -1) {
async_append_flush(ap);
- ignore(write(ap->fd, data, size));
+ ovs_ignore(write(ap->fd, data, size));
return;
}
{
if (detach) {
if (chdir_) {
- ignore(chdir("/"));
+ ovs_ignore(chdir("/"));
}
close_standard_fds();
}
}
if (monitor) {
- ignore(write(daemonize_fd, unw_bt,
- dep * sizeof(struct unw_backtrace)));
+ ovs_ignore(write(daemonize_fd, unw_bt,
+ dep * sizeof(struct unw_backtrace)));
} else {
/* Since there is no monitor daemon running, write backtrace
* in current process.
backtrace_capture(&bt);
if (monitor && daemonize_fd > -1) {
- ignore(write(daemonize_fd, &bt, sizeof bt));
+ ovs_ignore(write(daemonize_fd, &bt, sizeof bt));
} else {
int log_fd = vlog_get_log_file_fd_unsafe();
send_backtrace_to_monitor();
raise(sig_nr);
}
- ignore(write(signal_fds[1], "", 1));
+ ovs_ignore(write(signal_fds[1], "", 1));
#else
SetEvent(wevent);
#endif
#include <poll.h>
#include <unistd.h>
#include "openvswitch/poll-loop.h"
+#include "openvswitch/util.h"
#include "socket-util.h"
/* Initializes 'latch' as initially unset. */
void
latch_set(struct latch *latch)
{
- ignore(write(latch->fds[1], "", 1));
+ ovs_ignore(write(latch->fds[1], "", 1));
}
/* Returns true if 'latch' is set, false otherwise. Does not reset 'latch'
ph.sigfigs = 0;
ph.snaplen = 1518;
ph.network = 1; /* Ethernet */
- ignore(fwrite(&ph, sizeof ph, 1, p_file->file));
+ ovs_ignore(fwrite(&ph, sizeof ph, 1, p_file->file));
fflush(p_file->file);
}
prh.ts_subsec = tv.tv_usec;
prh.incl_len = dp_packet_size(buf);
prh.orig_len = dp_packet_size(buf);
- ignore(fwrite(&prh, sizeof prh, 1, p_file->file));
- ignore(fwrite(data_dp, dp_packet_size(buf), 1, p_file->file));
+ ovs_ignore(fwrite(&prh, sizeof prh, 1, p_file->file));
+ ovs_ignore(fwrite(data_dp, dp_packet_size(buf), 1, p_file->file));
fflush(p_file->file);
}
static void
sigchld_handler(int signr OVS_UNUSED)
{
- ignore(write(fds[1], "", 1));
+ ovs_ignore(write(fds[1], "", 1));
}
char *env = getenv("OVS_CTL_TIMEOUT");
if (env && env[0]) {
- ignore(str_to_uint(env, 10, &secs));
+ ovs_ignore(str_to_uint(env, 10, &secs));
}
}
if (secs) {
* __attribute__((warn_unused_result)) and you genuinely want to ignore
* its return value. (Note that every scalar type can be implicitly
* converted to bool.) */
-void ignore(bool x OVS_UNUSED) { }
+void ovs_ignore(bool x OVS_UNUSED) { }
/* Returns an appropriate delimiter for inserting just before the 0-based item
* 'index' in a list that has 'total' items in it. */
bool is_file_name_absolute(const char *);
char *follow_symlinks(const char *filename);
-
-void ignore(bool x OVS_UNUSED);
\f
/* Bitwise tests. */
OVS_NO_THREAD_SAFETY_ANALYSIS
{
if (log_fd >= 0) {
- ignore(write(log_fd, s, strlen(s)));
+ ovs_ignore(write(log_fd, s, strlen(s)));
}
}
async_append_flush(log_writer);
}
} else {
- ignore(write(log_fd, s.string, s.length));
+ ovs_ignore(write(log_fd, s.string, s.length));
}
}
ovs_mutex_unlock(&log_file_mutex);
/* Remove any partially written data, ignoring errors since there is
* nothing further we can do. */
- ignore(ftruncate(fileno(file->stream), file->offset));
+ ovs_ignore(ftruncate(fileno(file->stream), file->offset));
file->error = ovsdb_io_error(error, "%s: write failed",
file->display_name);
#include "openvswitch/ofp-match.h"
#include "openvswitch/ofp-print.h"
#include "openvswitch/match.h"
+#include "openvswitch/util.h"
#include "classifier-private.h"
static void
hash = flow_hash_fields(flow, NX_HASH_FIELDS_NW_SRC, hash);
hash = flow_hash_fields(flow, NX_HASH_FIELDS_NW_DST, hash);
hash = flow_hash_fields(flow, NX_HASH_FIELDS_SYMMETRIC_L3, hash);
- ignore(hash);
+ ovs_ignore(hash);
}
static void
/* Parse TCP flags. */
if (dp_packet_size(&packet) >= ETH_HEADER_LEN) {
uint16_t tcp_flags = parse_tcp_flags(&packet, NULL, NULL, NULL);
- ignore(tcp_flags);
+ ovs_ignore(tcp_flags);
}
/* Count headers. */
int count = flow_count_vlan_headers(&flow);
- ignore(count);
+ ovs_ignore(count);
/* Extract metadata. */
struct match flow_metadata;
/* Obtain miniflow hash. */
uint32_t hash = miniflow_hash_5tuple(miniflow, 0);
- ignore(hash);
+ ovs_ignore(hash);
/* Check that the flow equals its miniflow. */
for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) {
}
ovs_mutex_unlock(&aux->mutex);
} else {
- ignore(ccmap_find(aux->ccmap, hash));
+ ovs_ignore(ccmap_find(aux->ccmap, hash));
}
}
} else {
for (i = 0; i < n_elems; i++) {
- ignore(ccmap_find(aux->ccmap, hash_int(i, 0)));
+ ovs_ignore(ccmap_find(aux->ccmap, hash_int(i, 0)));
}
}
return NULL;
}
ovs_mutex_unlock(&aux->mutex);
} else {
- ignore(find(aux->cmap, i));
+ ovs_ignore(find(aux->cmap, i));
}
}
} else {
for (i = 0; i < n_elems; i++) {
- ignore(find(aux->cmap, i));
+ ovs_ignore(find(aux->cmap, i));
}
}
return NULL;
/* Iteration. */
xgettimeofday(&start);
CMAP_FOR_EACH (e, node, &cmap) {
- ignore(e);
+ ovs_ignore(e);
}
printf("cmap iterate: %5d ms\n", elapsed(&start));
CMAP_NODE_FOR_EACH (e, node, nodes[i]) {
if (OVS_LIKELY(e->value == value + i)) {
- ignore(e); /* Found result. */
+ ovs_ignore(e); /* Found result. */
break;
}
}
/* Iteration. */
xgettimeofday(&start);
CMAP_FOR_EACH (e, node, &cmap) {
- ignore(e);
+ ovs_ignore(e);
}
printf("cmap iterate: %5d ms\n", elapsed(&start));
fat_rwlock_unlock(&aux->fatlock);
} else {
fat_rwlock_rdlock(&aux->fatlock);
- ignore(hfind(aux->hmap, i));
+ ovs_ignore(hfind(aux->hmap, i));
fat_rwlock_unlock(&aux->fatlock);
}
}
} else {
for (i = 0; i < n_elems; i++) {
- ignore(hfind(aux->hmap, i));
+ ovs_ignore(hfind(aux->hmap, i));
}
}
return NULL;
xgettimeofday(&start);
HMAP_FOR_EACH (e, node, &hmap) {
- ignore(e);
+ ovs_ignore(e);
}
printf("hmap iterate: %5d ms\n", elapsed(&start));
start = running_time_ms;
for (i = 0; i < n_ids_per_thread; i++) {
- ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
+ ovs_ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
}
thread_working_ms[tid] = elapsed(&start);
start = running_time_ms;
for (i = 0; i < n_ids_per_thread; i++) {
- ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
+ ovs_ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
id_fpool_free_id(aux->pool, tid, th_ids[i]);
- ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
+ ovs_ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
}
thread_working_ms[tid] = elapsed(&start);
if (elapsed(&start) >= TIMEOUT_MS) {
break;
}
- ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
+ ovs_ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
swap_u32(&th_ids[i], &th_ids[random_range(i + 1)]);
id_fpool_free_id(aux->pool, tid, th_ids[i]);
- ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
+ ovs_ignore(id_fpool_new_id(aux->pool, tid, &th_ids[i]));
}
thread_working_ms[tid] = elapsed(&start);
start = running_time_ms;
for (i = 0; i < n_ids_per_thread; i++) {
ovs_mutex_lock(aux->lock);
- ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
+ ovs_ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
id_pool_free_id(aux->pool, th_ids[i]);
- ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
+ ovs_ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
ovs_mutex_unlock(aux->lock);
}
thread_working_ms[tid] = elapsed(&start);
break;
}
ovs_mutex_lock(aux->lock);
- ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
+ ovs_ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
swap_u32(&th_ids[i], &th_ids[random_range(i + 1)]);
id_pool_free_id(aux->pool, th_ids[i]);
- ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
+ ovs_ignore(id_pool_alloc_id(aux->pool, &th_ids[i]));
ovs_mutex_unlock(aux->lock);
}
thread_working_ms[tid] = elapsed(&start);