From a8a5e9a3d518c02c1266a907063ff985d293b393 Mon Sep 17 00:00:00 2001 From: leitner Date: Wed, 27 Feb 2008 12:10:05 +0000 Subject: [PATCH] some valgrind de-noising fix subtle typo in sub_of (David Sirovsky) --- CHANGES | 1 + io/io_dontwantread.c | 1 + io/io_dontwantwrite.c | 1 + io/io_wantread.c | 1 + io/io_wantwrite.c | 1 + rangecheck.h | 2 +- test/range.c | 5 +---- 7 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index b6c56fb..678db43 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 0.28: add uint64 pack and unpack routines + fix subtle typo in sub_of (David Sirovsky) 0.27: add fmt_strm diff --git a/io/io_dontwantread.c b/io/io_dontwantread.c index 0343be4..265e425 100644 --- a/io/io_dontwantread.c +++ b/io/io_dontwantread.c @@ -26,6 +26,7 @@ void io_dontwantread(int64 d) { #ifdef HAVE_EPOLL if (io_waitmode==EPOLL) { struct epoll_event x; + byte_zero(&x,sizeof(x)); // to shut up valgrind x.events=0; if (e->wantwrite) x.events|=EPOLLOUT; x.data.fd=d; diff --git a/io/io_dontwantwrite.c b/io/io_dontwantwrite.c index 2daac5d..8c9fef2 100644 --- a/io/io_dontwantwrite.c +++ b/io/io_dontwantwrite.c @@ -26,6 +26,7 @@ void io_dontwantwrite(int64 d) { #ifdef HAVE_EPOLL if (io_waitmode==EPOLL) { struct epoll_event x; + byte_zero(&x,sizeof(x)); // to shut up valgrind x.events=0; if (e->wantread) x.events|=EPOLLIN; x.data.fd=d; diff --git a/io/io_wantread.c b/io/io_wantread.c index 807282e..cd6207e 100644 --- a/io/io_wantread.c +++ b/io/io_wantread.c @@ -32,6 +32,7 @@ void io_wantread(int64 d) { #ifdef HAVE_EPOLL if (io_waitmode==EPOLL) { struct epoll_event x; + byte_zero(&x,sizeof(x)); // to shut up valgrind x.events=EPOLLIN; if (e->wantwrite) x.events|=EPOLLOUT; x.data.fd=d; diff --git a/io/io_wantwrite.c b/io/io_wantwrite.c index 2c0dc41..d5b9b21 100644 --- a/io/io_wantwrite.c +++ b/io/io_wantwrite.c @@ -29,6 +29,7 @@ void io_wantwrite(int64 d) { #ifdef HAVE_EPOLL if (io_waitmode==EPOLL) { struct epoll_event x; + byte_zero(&x,sizeof(x)); // to shut up valgrind x.events=EPOLLOUT; if (e->wantread) x.events|=EPOLLIN; x.data.fd=d; diff --git a/rangecheck.h b/rangecheck.h index f2dd85b..e7afa3a 100644 --- a/rangecheck.h +++ b/rangecheck.h @@ -106,7 +106,7 @@ int range_str4inbuf(const void* buf,size_t len,const void* stringstart); * return 0. Otherwise, return 1. */ #define add_of(c,a,b) ({ typeof(a) __a=a; typeof(b) __b=b; (__b)<1?((__MIN(typeof(c))-(__b)<=(__a))?assign(c,__a+__b):1) : ((__MAX(typeof(c))-(__b)>=(__a))?assign(c,__a+__b):1); }) -#define sub_of(c,a,b) ({ typeof(a) __a=a; typeof(b) __b=b; (__b)<1?((__MAX(typeof(c))-(__b)>=(__a))?assign(c,__a-__b):1) : ((__MIN(typeof(c))+(__b)<=(__a))?assign(c,__a-__b):1); }) +#define sub_of(c,a,b) ({ typeof(a) __a=a; typeof(b) __b=b; (__b)<1?((__MAX(typeof(c))+(__b)>=(__a))?assign(c,__a-__b):1) : ((__MIN(typeof(c))+(__b)<=(__a))?assign(c,__a-__b):1); }) #undef __static diff --git a/test/range.c b/test/range.c index cec53e1..dc5dda0 100644 --- a/test/range.c +++ b/test/range.c @@ -204,10 +204,7 @@ void check_intof() { { unsigned long long a; - /* caveat emptor: */ - a=0; assert(add_of(a,0xfffffff0,0x10)==1); - /* this does NOT work and set a to 0x100000000, just like - * a=0xfffffff0+0x10 sets a to 0 in C! */ + a=0; assert(add_of(a,0xfffffff0ul,0x10)==0 && a==0x100000000); } }