In some environments, builds would fail with the following error:
lib/stopwatch.c: In function ‘stopwatch_exit’:
lib/stopwatch.c:448:5: error: ignoring return value of ‘write’, declared
with attribute warn_unused_result [-Werror=unused-result]
write(stopwatch_pipe[1], &pkt, sizeof pkt);
This patch explicitly ignores the return value of write().
This also fixes some minor coding style issues.
Signed-off-by: Justin Pettit <[email protected]>
---
lib/stopwatch.c | 25 +++++++++++++------------
lib/stopwatch.h | 8 +++++---
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/lib/stopwatch.c b/lib/stopwatch.c
index 80677d000030..a241433838b8 100644
--- a/lib/stopwatch.c
+++ b/lib/stopwatch.c
@@ -24,6 +24,7 @@
#include "ovs-thread.h"
#include <unistd.h>
#include "socket-util.h"
+#include "util.h"
VLOG_DEFINE_THIS_MODULE(stopwatch);
@@ -236,7 +237,7 @@ add_sample(struct stopwatch *sw, unsigned long long
new_sample)
static bool
stopwatch_get_stats_protected(const char *name,
- struct stopwatch_stats *stats)
+ struct stopwatch_stats *stats)
{
struct stopwatch *perf;
@@ -311,7 +312,7 @@ stopwatch_show_protected(int argc, const char *argv[],
struct ds *s)
static void
stopwatch_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
- const char *argv[], void *ignore OVS_UNUSED)
+ const char *argv[], void *ignore OVS_UNUSED)
{
struct ds s = DS_EMPTY_INITIALIZER;
bool success;
@@ -330,15 +331,15 @@ stopwatch_show(struct unixctl_conn *conn, int argc
OVS_UNUSED,
static void
stopwatch_reset(struct unixctl_conn *conn, int argc OVS_UNUSED,
- const char *argv[], void *ignore OVS_UNUSED)
+ const char *argv[], void *aux OVS_UNUSED)
{
struct stopwatch_packet pkt = {
.op = OP_RESET,
};
if (argc > 1) {
- ovs_strlcpy(pkt.name, argv[1], sizeof(pkt.name));
+ ovs_strlcpy(pkt.name, argv[1], sizeof pkt.name);
}
- write(stopwatch_pipe[1], &pkt, sizeof(pkt));
+ ignore(write(stopwatch_pipe[1], &pkt, sizeof pkt));
unixctl_command_reply(conn, "");
}
@@ -406,7 +407,7 @@ stopwatch_thread(void *ign OVS_UNUSED)
while (!should_exit) {
struct stopwatch_packet pkt;
- while (read(stopwatch_pipe[0], &pkt, sizeof(pkt)) > 0) {
+ while (read(stopwatch_pipe[0], &pkt, sizeof pkt) > 0) {
ovs_mutex_lock(&stopwatches_lock);
switch (pkt.op) {
case OP_START_SAMPLE:
@@ -445,7 +446,7 @@ stopwatch_exit(void)
.op = OP_SHUTDOWN,
};
- write(stopwatch_pipe[1], &pkt, sizeof pkt);
+ ignore(write(stopwatch_pipe[1], &pkt, sizeof pkt));
xpthread_join(stopwatch_thread_id, NULL);
/* Process is exiting and we have joined the only
@@ -506,8 +507,8 @@ stopwatch_start(const char *name, unsigned long long ts)
.op = OP_START_SAMPLE,
.time = ts,
};
- ovs_strlcpy(pkt.name, name, sizeof(pkt.name));
- write(stopwatch_pipe[1], &pkt, sizeof(pkt));
+ ovs_strlcpy(pkt.name, name, sizeof pkt.name);
+ ignore(write(stopwatch_pipe[1], &pkt, sizeof pkt));
}
void
@@ -517,8 +518,8 @@ stopwatch_stop(const char *name, unsigned long long ts)
.op = OP_END_SAMPLE,
.time = ts,
};
- ovs_strlcpy(pkt.name, name, sizeof(pkt.name));
- write(stopwatch_pipe[1], &pkt, sizeof(pkt));
+ ovs_strlcpy(pkt.name, name, sizeof pkt.name);
+ ignore(write(stopwatch_pipe[1], &pkt, sizeof pkt));
}
void
@@ -529,7 +530,7 @@ stopwatch_sync(void)
};
ovs_mutex_lock(&stopwatches_lock);
- write(stopwatch_pipe[1], &pkt, sizeof(pkt));
+ ignore(write(stopwatch_pipe[1], &pkt, sizeof pkt));
ovs_mutex_cond_wait(&stopwatches_sync, &stopwatches_lock);
ovs_mutex_unlock(&stopwatches_lock);
}
diff --git a/lib/stopwatch.h b/lib/stopwatch.h
index 6ee7291d9230..91abd64e4c11 100644
--- a/lib/stopwatch.h
+++ b/lib/stopwatch.h
@@ -26,12 +26,14 @@ enum stopwatch_units {
struct stopwatch_stats {
unsigned long long count; /* Total number of samples. */
- enum stopwatch_units unit; /* Unit of following values. */
+ enum stopwatch_units unit; /* Unit of following values. */
unsigned long long max; /* Maximum value. */
unsigned long long min; /* Minimum value. */
double pctl_95; /* 95th percentile. */
- double ewma_50; /* Exponentially weighted moving average
(alpha 0.50). */
- double ewma_1; /* Exponentially weighted moving average
(alpha 0.01). */
+ double ewma_50; /* Exponentially weighted moving average
+ (alpha 0.50). */
+ double ewma_1; /* Exponentially weighted moving average
+ (alpha 0.01). */
};
/* Create a new stopwatch.
--
2.7.4
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev