RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Ralf S. Engelschall
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   20-Aug-2008 09:36:13
  Branch: HEAD                             Handle: 2008082007361201

  Modified files:
    rpm                     CHANGES
    rpm/rpmio               rpmgc.c rpmnss.c rpmssl.c

  Log:
    Simplify conditional code and remove compile-time warnings in
    rpmio/rpm{nss,gc,ssl}.c after AFB recently changed the "rpmxxxImplVecs"
    structures from "always existing" to "conditionally existing". Now
    that they are conditionally existing all the code it references can be
    wrapped with a single pre-processor "#if". At the same time this fixes
    compile-time warnings related to "unreferenced symbols".

  Summary:
    Revision    Changes     Path
    1.2531      +1  -0      rpm/CHANGES
    2.9         +4  -33     rpm/rpmio/rpmgc.c
    1.18        +4  -31     rpm/rpmio/rpmnss.c
    2.15        +4  -31     rpm/rpmio/rpmssl.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2530 -r1.2531 CHANGES
  --- rpm/CHANGES       19 Aug 2008 20:51:44 -0000      1.2530
  +++ rpm/CHANGES       20 Aug 2008 07:36:12 -0000      1.2531
  @@ -1,5 +1,6 @@
   
   5.1.0 -> 5.2a0:
  +    - rse: simplify conditional code and remove compile-time warnings in 
rpmio/rpm{nss,gc,ssl}.c
       - jbj: python: simplify Makefile.am
       - jbj: display sysinfo path with --showrc.
       - jbj: remove internal zlib.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmgc.c
  ============================================================================
  $ cvs diff -u -r2.8 -r2.9 rpmgc.c
  --- rpm/rpmio/rpmgc.c 5 Aug 2008 13:00:52 -0000       2.8
  +++ rpm/rpmio/rpmgc.c 20 Aug 2008 07:36:13 -0000      2.9
  @@ -13,6 +13,8 @@
   
   #include "debug.h"
   
  +#if defined(WITH_GCRYPT)
  +
   /[EMAIL PROTECTED] pgpDig @*/
   /[EMAIL PROTECTED] pgpDigParams @*/
   
  @@ -24,7 +26,6 @@
   extern int _pgp_print;
   /[EMAIL PROTECTED]@*/
   
  -#if defined(WITH_GCRYPT)
   static
   void rpmgcDump(const char * msg, gcry_sexp_t sexp)
   {
  @@ -40,14 +41,12 @@
   /[EMAIL PROTECTED]@*/
       return;
   }
  -#endif
   
   /**
    * Convert hex to binary nibble.
    * @param c            hex character
    * @return             binary nibble
    */
  -#if defined(WITH_GCRYPT)
   static
   unsigned char nibble(char c)
        /[EMAIL PROTECTED]/
  @@ -60,13 +59,11 @@
        return (unsigned char)((int)(c - 'a') + 10);
       return (unsigned char) '\0';
   }
  -#endif
   
   static
   int rpmgcSetRSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = dig->impl;
       unsigned int nbits = gcry_mpi_get_nbits(gc->c);
       unsigned int nb = (nbits + 7) >> 3;
  @@ -145,16 +142,12 @@
       signhash16[1] = (rpmuint8_t) (nibble(s[2]) << 4) | nibble(s[3]);
   /[EMAIL PROTECTED]@*/
       return memcmp(signhash16, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 0;
  -#endif
   }
   
   static
   int rpmgcVerifyRSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = dig->impl;
       gcry_error_t rc;
   
  @@ -183,16 +176,12 @@
       gcry_sexp_release(gc->sig);              gc->sig = NULL;
   
       return (rc ? 0 : 1);
  -#else
  -    return 0;
  -#endif
   }
   
   static
   int rpmgcSetDSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = dig->impl;
       gcry_error_t rc;
       int xx;
  @@ -210,16 +199,12 @@
   
       /* Compare leading 16 bits of digest for quick check. */
       return memcmp(dig->sha1, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 0;
  -#endif
   }
   
   static
   int rpmgcVerifyDSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = dig->impl;
       gcry_error_t rc;
   
  @@ -243,9 +228,6 @@
       gcry_sexp_release(gc->sig);              gc->sig = NULL;
   /[EMAIL PROTECTED] -noeffectuncon @*/
       return (rc ? 0 : 1);
  -#else
  -    return 0;
  -#endif
   }
   
   /[EMAIL PROTECTED] -mustmod @*/
  @@ -256,7 +238,6 @@
        /[EMAIL PROTECTED] fileSystem @*/
        /[EMAIL PROTECTED] dig, fileSystem @*/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = dig->impl;
       unsigned int nb;
       int rc = 0;
  @@ -306,9 +287,6 @@
       }
   /[EMAIL PROTECTED] =noeffectuncon @*/
       return rc;
  -#else
  -    return 1;
  -#endif
   }
   /[EMAIL PROTECTED] =mustmod @*/
   
  @@ -317,7 +295,6 @@
   void rpmgcClean(void * impl)
        /[EMAIL PROTECTED] impl @*/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = impl;
   /[EMAIL PROTECTED] -noeffectuncon @*/
       if (gc != NULL) {
  @@ -371,7 +348,6 @@
        }
       }
   /[EMAIL PROTECTED] =noeffectuncon @*/
  -#endif
   }
   /[EMAIL PROTECTED]@*/
   
  @@ -379,11 +355,9 @@
   void * rpmgcFree(/[EMAIL PROTECTED]@*/ void * impl)
        /[EMAIL PROTECTED] impl @*/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = impl;
       rpmgcClean(impl);
       gc = _free(gc);
  -#endif
       return NULL;
   }
   
  @@ -391,19 +365,16 @@
   void * rpmgcInit(void)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_GCRYPT)
       rpmgc gc = xcalloc(1, sizeof(*gc));
       return (void *) gc;
  -#else
  -    return NULL;
  -#endif
   }
   
  -#if defined(WITH_GCRYPT)
   struct pgpImplVecs_s rpmgcImplVecs = {
        rpmgcSetRSA, rpmgcVerifyRSA,
        rpmgcSetDSA, rpmgcVerifyDSA,
        rpmgcMpiItem, rpmgcClean,
        rpmgcFree, rpmgcInit
   };
  +
   #endif
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmnss.c
  ============================================================================
  $ cvs diff -u -r1.17 -r1.18 rpmnss.c
  --- rpm/rpmio/rpmnss.c        5 Aug 2008 13:01:12 -0000       1.17
  +++ rpm/rpmio/rpmnss.c        20 Aug 2008 07:36:13 -0000      1.18
  @@ -13,6 +13,8 @@
   
   #include "debug.h"
   
  +#if defined(WITH_NSS)
  +
   /[EMAIL PROTECTED] pgpDig @*/
   /[EMAIL PROTECTED] pgpDigParams @*/
   
  @@ -31,7 +33,6 @@
   int rpmnssSetRSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = dig->impl;
       int xx;
   
  @@ -74,16 +75,12 @@
   
       /* Compare leading 16 bits of digest for quick check. */
       return memcmp(dig->md5, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 1;
  -#endif       /* WITH_NSS */
   }
   
   static
   int rpmnssVerifyRSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = dig->impl;
       int rc;
   
  @@ -96,16 +93,12 @@
   /[EMAIL PROTECTED] =nullstate @*/
   
       return rc;
  -#else
  -    return 0;
  -#endif       /* WITH_NSS */
   }
   
   static
   int rpmnssSetDSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = dig->impl;
       int xx;
   
  @@ -115,16 +108,12 @@
   
       /* Compare leading 16 bits of digest for quick check. */
       return memcmp(dig->sha1, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 1;
  -#endif       /* WITH_NSS */
   }
   
   static
   int rpmnssVerifyDSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = dig->impl;
       int rc;
   
  @@ -137,12 +126,8 @@
   /[EMAIL PROTECTED] =nullstate @*/
   
       return rc;
  -#else
  -    return 0;
  -#endif       /* WITH_NSS */
   }
   
  -#if defined(WITH_NSS)
   /**
    * @return           0 on success
    */
  @@ -255,14 +240,12 @@
   {
       return rpmnssNewPublicKey(dsaKey);
   }
  -#endif       /* WITH_NSS */
   
   static
   int rpmnssMpiItem(const char * pre, pgpDig dig, int itemno,
                const rpmuint8_t * p, /[EMAIL PROTECTED]@*/ const rpmuint8_t * 
pend)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = dig->impl;
       int rc = 0;
   
  @@ -342,9 +325,6 @@
       }
   /[EMAIL PROTECTED]@*/
       return rc;
  -#else
  -    return 1;
  -#endif       /* WITH_NSS */
   }
   
   /[EMAIL PROTECTED]@*/
  @@ -352,7 +332,6 @@
   void rpmnssClean(void * impl)
        /[EMAIL PROTECTED] impl @*/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = impl;
   /[EMAIL PROTECTED]@*/
       if (nss != NULL) {
  @@ -374,7 +353,6 @@
        }
   /[EMAIL PROTECTED]@*/
       }
  -#endif       /* WITH_NSS */
   }
   /[EMAIL PROTECTED]@*/
   
  @@ -382,13 +360,11 @@
   void * rpmnssFree(/[EMAIL PROTECTED]@*/ void * impl)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = impl;
       if (nss != NULL) {
        rpmnssClean(impl);
        nss = _free(nss);
       }
  -#endif       /* WITH_NSS */
       return NULL;
   }
   
  @@ -397,7 +373,6 @@
        /[EMAIL PROTECTED] _rpmnss_init @*/
        /[EMAIL PROTECTED] _rpmnss_init @*/
   {
  -#if defined(WITH_NSS)
       rpmnss nss = xcalloc(1, sizeof(*nss));
   
   /[EMAIL PROTECTED]@*/
  @@ -406,16 +381,14 @@
       _rpmnss_init = 1;
   
       return (void *) nss;
  -#else
  -    return NULL;
  -#endif       /* WITH_NSS */
   }
   
  -#if defined(WITH_NSS)
   struct pgpImplVecs_s rpmnssImplVecs = {
        rpmnssSetRSA, rpmnssVerifyRSA,
        rpmnssSetDSA, rpmnssVerifyDSA,
        rpmnssMpiItem, rpmnssClean,
        rpmnssFree, rpmnssInit
   };
  +
   #endif
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmssl.c
  ============================================================================
  $ cvs diff -u -r2.14 -r2.15 rpmssl.c
  --- rpm/rpmio/rpmssl.c        5 Aug 2008 13:54:08 -0000       2.14
  +++ rpm/rpmio/rpmssl.c        20 Aug 2008 07:36:13 -0000      2.15
  @@ -19,6 +19,8 @@
   
   #include "debug.h"
   
  +#if defined(WITH_SSL)
  +
   /[EMAIL PROTECTED] pgpDig @*/
   /[EMAIL PROTECTED] pgpDigParams @*/
   
  @@ -30,7 +32,6 @@
   extern int _pgp_print;
   /[EMAIL PROTECTED]@*/
   
  -#if defined(WITH_SSL)
   /**
    * Convert hex to binary nibble.
    * @param c            hex character
  @@ -48,13 +49,11 @@
        return (unsigned char)((int)(c - 'a') + 10);
       return (unsigned char) '\0';
   }
  -#endif       /* WITH_SSL */
   
   static
   int rpmsslSetRSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = dig->impl;
       unsigned int nbits = BN_num_bits(ssl->c);
       unsigned int nb = (nbits + 7) >> 3;
  @@ -130,16 +129,12 @@
       signhash16[1] = (rpmuint8_t) (nibble(s[2]) << 4) | nibble(s[3]);
   /[EMAIL PROTECTED]@*/
       return memcmp(signhash16, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 1;
  -#endif       /* WITH_SSL */
   }
   
   static
   int rpmsslVerifyRSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = dig->impl;
       unsigned char * rsahm;
       unsigned char * dbuf;
  @@ -191,16 +186,12 @@
       }
   
       return rc;
  -#else
  -    return 0;
  -#endif       /* WITH_SSL */
   }
   
   static
   int rpmsslSetDSA(/[EMAIL PROTECTED]@*/ DIGEST_CTX ctx, pgpDig dig, 
pgpDigParams sigp)
        /[EMAIL PROTECTED] dig @*/
   {
  -#if defined(WITH_SSL)
       int xx;
   
       /* Set DSA hash. */
  @@ -208,16 +199,12 @@
   
       /* Compare leading 16 bits of digest for quick check. */
       return memcmp(dig->sha1, sigp->signhash16, sizeof(sigp->signhash16));
  -#else
  -    return 1;
  -#endif       /* WITH_SSL */
   }
   
   static
   int rpmsslVerifyDSA(pgpDig dig)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = dig->impl;
       int rc;
   
  @@ -227,9 +214,6 @@
   /[EMAIL PROTECTED]@*/
   
       return rc;
  -#else
  -    return 0;
  -#endif       /* WITH_SSL */
   }
   
   static
  @@ -238,7 +222,6 @@
                /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ const rpmuint8_t * 
pend)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = dig->impl;
       unsigned int nb = ((pgpMpiBits(p) + 7) >> 3);
       int rc = 0;
  @@ -286,9 +269,6 @@
       }
   /[EMAIL PROTECTED]@*/
       return rc;
  -#else
  -    return 1;
  -#endif       /* WITH_SSL */
   }
   
   /[EMAIL PROTECTED]@*/
  @@ -296,7 +276,6 @@
   void rpmsslClean(void * impl)
        /[EMAIL PROTECTED] impl @*/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = impl;
   /[EMAIL PROTECTED]@*/
       if (ssl != NULL) {
  @@ -318,7 +297,6 @@
        }
       }
   /[EMAIL PROTECTED]@*/
  -#endif       /* WITH_SSL */
   }
   /[EMAIL PROTECTED]@*/
   
  @@ -326,11 +304,9 @@
   void * rpmsslFree(/[EMAIL PROTECTED]@*/ void * impl)
        /[EMAIL PROTECTED] impl @*/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = impl;
       rpmsslClean(impl);
       ssl = _free(ssl);
  -#endif       /* WITH_SSL */
       return NULL;
   }
   
  @@ -338,22 +314,19 @@
   void * rpmsslInit(void)
        /[EMAIL PROTECTED]/
   {
  -#if defined(WITH_SSL)
       rpmssl ssl = xcalloc(1, sizeof(*ssl));
   /[EMAIL PROTECTED]@*/
       ERR_load_crypto_strings();
   /[EMAIL PROTECTED]@*/
       return (void *) ssl;
  -#else
  -    return NULL;
  -#endif       /* WITH_SSL */
   }
   
  -#if defined(WITH_SSL)
   struct pgpImplVecs_s rpmsslImplVecs = {
        rpmsslSetRSA, rpmsslVerifyRSA,
        rpmsslSetDSA, rpmsslVerifyDSA,
        rpmsslMpiItem, rpmsslClean,
        rpmsslFree, rpmsslInit
   };
  +
   #endif
  +
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to