Eliminate useless pgpDig nbytes counter
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 20 May 2009 14:22:51 +0000 (17:22 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 20 May 2009 14:22:51 +0000 (17:22 +0300)
- nothing at all uses this, dont bother
- if plaintext size of digests is needed, the correct place to calculate
  it is in the digest routines, not manual beancounting all over the place

lib/package.c
lib/rpmchecksig.c
rpmio/digest.h

index b8ce8d5..ebb1135 100644 (file)
@@ -376,7 +376,6 @@ verifyinfo_exit:
     dig = pgpNewDig();
     if (dig == NULL)
        goto verifyinfo_exit;
-    dig->nbytes = 0;
 
     sigtd.tag = info.tag;
     sigtd.type = info.type;
@@ -404,22 +403,18 @@ verifyinfo_exit:
        b = (unsigned char *) rpm_header_magic;
        nb = sizeof(rpm_header_magic);
         (void) rpmDigestUpdate(ctx, b, nb);
-        dig->nbytes += nb;
 
        b = (unsigned char *) ildl;
        nb = sizeof(ildl);
         (void) rpmDigestUpdate(ctx, b, nb);
-        dig->nbytes += nb;
 
        b = (unsigned char *) pe;
        nb = (htonl(ildl[0]) * sizeof(*pe));
         (void) rpmDigestUpdate(ctx, b, nb);
-        dig->nbytes += nb;
 
        b = (unsigned char *) dataStart;
        nb = htonl(ildl[1]);
         (void) rpmDigestUpdate(ctx, b, nb);
-        dig->nbytes += nb;
        } break;
     default:
        sigtd.data = _free(sigtd.data); /* Hmm...? */
@@ -556,7 +551,6 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
     Header sigh = NULL;
     rpmSigTag sigtag;
     struct rpmtd_s sigtd;
-    size_t nb;
     Header h = NULL;
     char * msg;
     rpmRC rc = RPMRC_FAIL;     /* assume failure */
@@ -632,9 +626,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
     h = NULL;
     msg = NULL;
 
-    nb = -fd->stats->ops[FDSTAT_READ].bytes;
     rc = rpmpkgReadHeader(keyring, vsflags, fd, &h, &msg);
-    nb += fd->stats->ops[FDSTAT_READ].bytes;
 
     if (rc != RPMRC_OK || h == NULL) {
        rpmlog(RPMLOG_ERR, _("%s: headerRead failed: %s"), fn,
@@ -655,7 +647,6 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
        rc = RPMRC_FAIL;
        goto exit;
     }
-    dig->nbytes = 0;
 
     /* Retrieve the tag parameters from the signature header. */
     if (!headerGet(sigh, sigtag, &sigtd, hgeflags)) {
@@ -679,9 +670,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
            break;
        ctx = rpmDigestInit(hashalgo, RPMDIGEST_NONE);
        (void) rpmDigestUpdate(ctx, rpm_header_magic, sizeof(rpm_header_magic));
-       dig->nbytes += sizeof(rpm_header_magic);
        (void) rpmDigestUpdate(ctx, utd.data, utd.count);
-       dig->nbytes += utd.count;
        rpmtdFreeData(&utd);
     }  break;
     case RPMSIGTAG_GPG:
@@ -693,9 +682,7 @@ static rpmRC rpmpkgRead(rpmKeyring keyring, rpmVSFlags vsflags,
        /* fallthrough */
     case RPMSIGTAG_MD5:
        /* Legacy signatures need the compressed payload in the digest too. */
-       while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0)
-           dig->nbytes += count;
-       dig->nbytes += nb;      /* XXX include size of header blob. */
+       while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0) {}
        if (count < 0) {
            rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"),
                                        fn, Fstrerror(fd));
index eb807db..b8660e6 100644 (file)
@@ -459,15 +459,12 @@ static int readFile(FD_t fd, const char * fn, pgpDig dig,
     int rc = 1;
     Header h = NULL;
 
-    dig->nbytes = 0;
     /* Read the header from the package. */
     if ((h = headerRead(fd, HEADER_MAGIC_YES)) == NULL) {
        rpmlog(RPMLOG_ERR, _("%s: headerRead failed\n"), fn);
        goto exit;
     }
 
-    dig->nbytes += headerSizeof(h, HEADER_MAGIC_YES);
-
     if (headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
        struct rpmtd_s utd;
     
@@ -483,8 +480,7 @@ static int readFile(FD_t fd, const char * fn, pgpDig dig,
     }
 
     /* Read the payload from the package. */
-    while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0)
-       dig->nbytes += count;
+    while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0) {}
     if (count < 0) {
        rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"), fn, Fstrerror(fd));
        goto exit;
index 32856e4..e934df8 100644 (file)
@@ -42,8 +42,6 @@ struct pgpDig_s {
     struct pgpDigParams_s signature;
     struct pgpDigParams_s pubkey;
 
-    size_t nbytes;             /*!< No. bytes of plain text. */
-
     /* DSA/RSA parameters */
     SECKEYPublicKey *keydata;
     SECItem *sigdata;