From 3ab3a931b4dd84eedcb35229187e5be8d14f9418 Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Wed, 23 Mar 2011 11:18:08 +0100 Subject: [PATCH] Avoid timedRead() usage - it is to be removed in the next soname bump --- lib/header.c | 6 ++---- lib/package.c | 4 ++-- lib/rpmlead.c | 3 +-- lib/signature.c | 6 +++--- rpmio/rpmio.c | 2 +- rpmio/rpmio.h | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/header.c b/lib/header.c index f2253fe..277d28d 100644 --- a/lib/header.c +++ b/lib/header.c @@ -980,8 +980,7 @@ Header headerRead(FD_t fd, int magicp) if (magicp == HEADER_MAGIC_YES) i += 2; - /* FIX: cast? */ - if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block))) + if (Fread(block, 1, i*sizeof(*block), fd) != i*sizeof(*block)) goto exit; i = 0; @@ -1007,8 +1006,7 @@ Header headerRead(FD_t fd, int magicp) ei[1] = htonl(dl); len -= sizeof(il) + sizeof(dl); - /* FIX: cast? */ - if (timedRead(fd, (char *)&ei[2], len) != len) + if (Fread((char *)&ei[2], 1, len, fd) != len) goto exit; h = headerLoad(ei); diff --git a/lib/package.c b/lib/package.c index e1795dd..51fd20b 100644 --- a/lib/package.c +++ b/lib/package.c @@ -468,7 +468,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, *msg = NULL; memset(block, 0, sizeof(block)); - if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) { + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { rasprintf(&buf, _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx); goto exit; @@ -494,7 +494,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, ei = xmalloc(uc); ei[0] = block[2]; ei[1] = block[3]; - if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) { + if ((xx = Fread((char *)&ei[2], 1, nb, fd)) != nb) { rasprintf(&buf, _("hdr blob(%zd): BAD, read returned %d\n"), nb, xx); goto exit; } diff --git a/lib/rpmlead.c b/lib/rpmlead.c index d41a413..101d3ff 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -116,8 +116,7 @@ rpmRC rpmLeadRead(FD_t fd, rpmlead lead) { assert(lead != NULL); memset(lead, 0, sizeof(*lead)); - /* FIX: remove timed read */ - if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) { + if (Fread(lead, 1, sizeof(*lead), fd) != sizeof(*lead)) { if (Ferror(fd)) { rpmlog(RPMLOG_ERR, _("read failed: %s (%d)\n"), Fstrerror(fd), errno); diff --git a/lib/signature.c b/lib/signature.c index 6d07e4f..ca12be8 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -86,7 +86,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) goto exit; memset(block, 0, sizeof(block)); - if ((xx = timedRead(fd, (void *)block, sizeof(block))) != sizeof(block)) { + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { rasprintf(&buf, _("sigh size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx); goto exit; @@ -117,7 +117,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) ei[1] = block[3]; pe = (entryInfo) &ei[2]; dataStart = (unsigned char *) (pe + il); - if ((xx = timedRead(fd, (void *)pe, nb)) != nb) { + if ((xx = Fread(pe, 1, nb, fd)) != nb) { rasprintf(&buf, _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx); goto exit; @@ -206,7 +206,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) rpm_loff_t archSize = 0; /* Position at beginning of header. */ - if (pad && (trc = timedRead(fd, (void *)block, pad)) != pad) { + if (pad && (trc = Fread(block, 1, pad, fd)) != pad) { rasprintf(&buf, _("sigh pad(%zd): BAD, read %zd bytes\n"), pad, trc); goto exit; diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index c8b9c2b..58c6230 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -639,7 +639,7 @@ static const FDIO_t ufdio = &ufdio_s ; ssize_t timedRead(FD_t fd, void * bufptr, size_t length) { - return ufdio->read(fd, bufptr, length); + return Fread(bufptr, 1, length, fd); } /* =============================================================== */ diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index 4af7ab8..f31c620 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -125,7 +125,7 @@ int ufdCopy(FD_t sfd, FD_t tfd); /** * XXX the name is misleading, this is a legacy wrapper that ensures * only S_ISREG() files are read, nothing to do with timed... - * TODO: get this out of the API + * TODO: get this out of the API, should go out in the next soname bump */ ssize_t timedRead(FD_t fd, void * bufptr, size_t length); -- 2.7.4