From d8fcb0e821ed3c647524b2e88bc291891d2ed8be Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 8 Aug 2020 20:32:50 -0700 Subject: [PATCH] remove some compiler warnings from ~-ing bits field Suppresses 15 compilers warnings. --- lib/sfio/sfdisc.c | 2 +- lib/sfio/sffilbuf.c | 2 +- lib/sfio/sfhdr.h | 10 +++++----- lib/sfio/sfopen.c | 2 +- lib/sfio/sfrd.c | 2 +- lib/sfio/sfread.c | 2 +- lib/sfio/sfsetbuf.c | 2 +- lib/sfio/sfsetfd.c | 2 +- lib/sfio/sfsync.c | 2 +- lib/sfio/sfwr.c | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/sfio/sfdisc.c b/lib/sfio/sfdisc.c index 6500ea859..7e2f28d6e 100644 --- a/lib/sfio/sfdisc.c +++ b/lib/sfio/sfdisc.c @@ -124,7 +124,7 @@ Sfdisc_t *sfdisc(reg Sfio_t * f, reg Sfdisc_t * disc) if (reinit) { SETLOCAL(f); - f->bits &= ~SF_NULL; /* turn off /dev/null handling */ + f->bits &= (unsigned short)~SF_NULL; /* turn off /dev/null handling */ if ((f->bits & SF_MMAP) || (f->mode & SF_INIT)) sfsetbuf(f, NIL(void *), (size_t) SF_UNBOUND); else if (f->data == f->tiny) diff --git a/lib/sfio/sffilbuf.c b/lib/sfio/sffilbuf.c index 437c392b2..ba769b28e 100644 --- a/lib/sfio/sffilbuf.c +++ b/lib/sfio/sffilbuf.c @@ -41,7 +41,7 @@ int _sffilbuf(Sfio_t * f, reg int n) rc = f->getr; justseek = f->bits & SF_JUSTSEEK; - f->bits &= ~SF_JUSTSEEK; + f->bits &= (unsigned short)~SF_JUSTSEEK; for (first = 1;; first = 0, (f->mode &= ~SF_LOCK)) { /* check mode */ if (SFMODE(f, local) != SF_READ && _sfmode(f, SF_READ, local) < 0) diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index 13389d9c7..ba5f1e4fe 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -183,8 +183,8 @@ extern "C" { #define SF_MVSIZE 00002000 #define SFMVSET(f) (((f)->size *= SF_NMAP), ((f)->bits |= SF_MVSIZE) ) #define SFMVUNSET(f) (!((f)->bits&SF_MVSIZE) ? 0 : \ - (((f)->bits &= ~SF_MVSIZE), ((f)->size /= SF_NMAP)) ) -#define SFCLRBITS(f) (SFMVUNSET(f), ((f)->bits &= ~(SF_DCDOWN|SF_MVSIZE)) ) + (((f)->bits &= (unsigned short)~SF_MVSIZE), ((f)->size /= SF_NMAP)) ) +#define SFCLRBITS(f) (SFMVUNSET(f), ((f)->bits &= (unsigned short)~(SF_DCDOWN|SF_MVSIZE)) ) /* bits for the mode field, SF_INIT defined in sfio_t.h */ #define SF_RC 00000010u /* peeking for a record */ @@ -555,17 +555,17 @@ extern "C" { #define SFDCRD(f,buf,n,dc,rv) \ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \ rv = (*dc->readf)(f,buf,n,dc); \ - if(!dcdown) f->bits &= ~SF_DCDOWN; \ + if(!dcdown) f->bits &= (unsigned short)~SF_DCDOWN; \ } #define SFDCWR(f,buf,n,dc,rv) \ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \ rv = (*dc->writef)(f,buf,n,dc); \ - if(!dcdown) f->bits &= ~SF_DCDOWN; \ + if(!dcdown) f->bits &= (unsigned short)~SF_DCDOWN; \ } #define SFDCSK(f,addr,type,dc,rv) \ { int dcdown = f->bits&SF_DCDOWN; f->bits |= SF_DCDOWN; \ rv = (*dc->seekf)(f,addr,type,dc); \ - if(!dcdown) f->bits &= ~SF_DCDOWN; \ + if(!dcdown) f->bits &= (unsigned short)~SF_DCDOWN; \ } /* fast peek of a stream */ diff --git a/lib/sfio/sfopen.c b/lib/sfio/sfopen.c index 70b2f9db6..71c07ddae 100644 --- a/lib/sfio/sfopen.c +++ b/lib/sfio/sfopen.c @@ -58,7 +58,7 @@ Sfio_t *sfopen(reg Sfio_t * f, const char *file, const char *mode) if ((f->flags & SF_RDWR) == SF_RDWR) f->bits |= SF_BOTH; else - f->bits &= ~SF_BOTH; + f->bits &= (unsigned short)~SF_BOTH; if (f->flags & SF_READ) f->mode = (f->mode & ~SF_WRITE) | SF_READ; diff --git a/lib/sfio/sfrd.c b/lib/sfio/sfrd.c index c68be86d2..88922efff 100644 --- a/lib/sfio/sfrd.c +++ b/lib/sfio/sfrd.c @@ -59,7 +59,7 @@ ssize_t sfrd(reg Sfio_t * f, reg void * buf, reg size_t n, GETLOCAL(f, local); if ((rcrv = f->mode & (SF_RC | SF_RV))) f->mode &= ~(SF_RC | SF_RV); - f->bits &= ~SF_JUSTSEEK; + f->bits &= (unsigned short)~SF_JUSTSEEK; if (f->mode & SF_PKRD) SFMTXRETURN(f, -1); diff --git a/lib/sfio/sfread.c b/lib/sfio/sfread.c index 4b4049ba5..e5003927b 100644 --- a/lib/sfio/sfread.c +++ b/lib/sfio/sfread.c @@ -34,7 +34,7 @@ ssize_t sfread(reg Sfio_t * f, void * buf, reg size_t n) GETLOCAL(f, local); justseek = f->bits & SF_JUSTSEEK; - f->bits &= ~SF_JUSTSEEK; + f->bits &= (unsigned short)~SF_JUSTSEEK; if (!buf) SFMTXRETURN(f, (ssize_t) (-1)); diff --git a/lib/sfio/sfsetbuf.c b/lib/sfio/sfsetbuf.c index 302865aa8..eaaeb3c4c 100644 --- a/lib/sfio/sfsetbuf.c +++ b/lib/sfio/sfsetbuf.c @@ -122,7 +122,7 @@ void *sfsetbuf(reg Sfio_t * f, reg void * buf, reg size_t size) osize = f->size; f->flags &= (unsigned short)~SF_MALLOC; - f->bits &= ~SF_MMAP; + f->bits &= (unsigned short)~SF_MMAP; /* pure read/string streams must have a valid string */ if ((f->flags & (SF_RDWR | SF_STRING)) == SF_RDSTR && diff --git a/lib/sfio/sfsetfd.c b/lib/sfio/sfsetfd.c index b95c43d8c..59028db5a 100644 --- a/lib/sfio/sfsetfd.c +++ b/lib/sfio/sfsetfd.c @@ -86,7 +86,7 @@ int sfsetfd(reg Sfio_t * f, reg int newfd) f->endb = f->endr = f->endw = f->data; f->extent = f->here = 0; f->mode = (f->mode & SF_RDWR) | SF_INIT; - f->bits &= ~SF_NULL; /* off /dev/null handling */ + f->bits &= (unsigned short)~SF_NULL; /* off /dev/null handling */ } } diff --git a/lib/sfio/sfsync.c b/lib/sfio/sfsync.c index 273999df4..699b74afc 100644 --- a/lib/sfio/sfsync.c +++ b/lib/sfio/sfsync.c @@ -115,7 +115,7 @@ int sfsync(reg Sfio_t * f) if (!SFISNULL(f) && (f->bits & SF_HOLE)) { /* realize a previously created hole of 0's */ if (SFSK(f, (Sfoff_t) (-1), SEEK_CUR, f->disc) >= 0) (void) SFWR(f, "", 1, f->disc); - f->bits &= ~SF_HOLE; + f->bits &= (unsigned short)~SF_HOLE; } f->mode |= pool; } diff --git a/lib/sfio/sfwr.c b/lib/sfio/sfwr.c index 41738348c..a7e266af8 100644 --- a/lib/sfio/sfwr.c +++ b/lib/sfio/sfwr.c @@ -76,7 +76,7 @@ static ssize_t sfoutput(Sfio_t * f, reg char *buf, reg size_t n) } if ((wr = write(f->file, wbuf, buf - wbuf)) > 0) { w += wr; - f->bits &= ~SF_HOLE; + f->bits &= (unsigned short)~SF_HOLE; } if (wr != (buf - wbuf)) break; @@ -173,7 +173,7 @@ ssize_t sfwr(reg Sfio_t * f, reg const void * buf, reg size_t n, } else { do_write: if ((w = write(f->file, (char *) buf, n)) > 0) - f->bits &= ~SF_HOLE; + f->bits &= (unsigned short)~SF_HOLE; } if (errno == 0) -- 2.40.0