On 04/14/2015 05:27 PM, Andy Zhou wrote: > Gcc complains about: > lib/perf-counter.c:43:13: error: ignoring return value of 'read', > declared with attribute warn_unused_result [-Werror=unused-result] > read(fd__, counter, sizeof(*counter)); > > Signed-off-by: Andy Zhou <az...@nicira.com> > --- > lib/perf-counter.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/perf-counter.c b/lib/perf-counter.c > index 7bd7834..10cc97f 100644 > --- a/lib/perf-counter.c > +++ b/lib/perf-counter.c > @@ -39,8 +39,10 @@ static int fd__ = 0; > uint64_t > perf_counter_read(uint64_t *counter) > { > - if (fd__ > 0) { > - read(fd__, counter, sizeof(*counter)); > + if (fd__ <= 0) {
Did you mean to reverse this condition? It seems like it should be how it was (fd__ > 0). > + if (read(fd__, counter, sizeof(*counter)) < 0) { > + *counter = 0; > + } > } else { > *counter = 0; > } > This isn't required by any means, but I'd be tempted to rework it so you only have to set counter to 0 once, so something like: { int res = -1; if (fd__ > 0) { res = read(fd__, counter, sizeof(*counter)); } if (res < 0) { *counter = 0; } ... -- Russell Bryant _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev