RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall
Root: /v/rpm/cvs Email: rse@rpm5.org
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)
+
/*@access pgpDig @*/
/*@access pgpDigParams @*/
@@ -24,7 +26,6 @@
extern int _pgp_print;
/*@=redecl@*/
-#if defined(WITH_GCRYPT)
static
void rpmgcDump(const char * msg, gcry_sexp_t sexp)
{
@@ -40,14 +41,12 @@
/*@=modfilesys@*/
return;
}
-#endif
/**
* Convert hex to binary nibble.
* @param c hex character
* @return binary nibble
*/
-#if defined(WITH_GCRYPT)
static
unsigned char nibble(char c)
/*@*/
@@ -60,13 +59,11 @@
return (unsigned char)((int)(c - 'a') + 10);
return (unsigned char) '\0';
}
-#endif
static
int rpmgcSetRSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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]);
/*@=type@*/
return memcmp(signhash16, sigp->signhash16, sizeof(sigp->signhash16));
-#else
- return 0;
-#endif
}
static
int rpmgcVerifyRSA(pgpDig dig)
/*@*/
{
-#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(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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)
/*@*/
{
-#if defined(WITH_GCRYPT)
rpmgc gc = dig->impl;
gcry_error_t rc;
@@ -243,9 +228,6 @@
gcry_sexp_release(gc->sig); gc->sig = NULL;
/*@=moduncon -noeffectuncon @*/
return (rc ? 0 : 1);
-#else
- return 0;
-#endif
}
/*@-globuse -mustmod @*/
@@ -256,7 +238,6 @@
/*@globals fileSystem @*/
/*@modifies dig, fileSystem @*/
{
-#if defined(WITH_GCRYPT)
rpmgc gc = dig->impl;
unsigned int nb;
int rc = 0;
@@ -306,9 +287,6 @@
}
/*@=moduncon =noeffectuncon @*/
return rc;
-#else
- return 1;
-#endif
}
/*@=globuse =mustmod @*/
@@ -317,7 +295,6 @@
void rpmgcClean(void * impl)
/*@modifies impl @*/
{
-#if defined(WITH_GCRYPT)
rpmgc gc = impl;
/*@-moduncon -noeffectuncon @*/
if (gc != NULL) {
@@ -371,7 +348,6 @@
}
}
/*@=moduncon =noeffectuncon @*/
-#endif
}
/*@=mustmod@*/
@@ -379,11 +355,9 @@
void * rpmgcFree(/*@only@*/ void * impl)
/*@modifies impl @*/
{
-#if defined(WITH_GCRYPT)
rpmgc gc = impl;
rpmgcClean(impl);
gc = _free(gc);
-#endif
return NULL;
}
@@ -391,19 +365,16 @@
void * rpmgcInit(void)
/*@*/
{
-#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)
+
/*@access pgpDig @*/
/*@access pgpDigParams @*/
@@ -31,7 +33,6 @@
int rpmnssSetRSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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)
/*@*/
{
-#if defined(WITH_NSS)
rpmnss nss = dig->impl;
int rc;
@@ -96,16 +93,12 @@
/*@=moduncon =nullstate @*/
return rc;
-#else
- return 0;
-#endif /* WITH_NSS */
}
static
int rpmnssSetDSA(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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)
/*@*/
{
-#if defined(WITH_NSS)
rpmnss nss = dig->impl;
int rc;
@@ -137,12 +126,8 @@
/*@=moduncon =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, /*@null@*/ const rpmuint8_t * pend)
/*@*/
{
-#if defined(WITH_NSS)
rpmnss nss = dig->impl;
int rc = 0;
@@ -342,9 +325,6 @@
}
/*@=moduncon@*/
return rc;
-#else
- return 1;
-#endif /* WITH_NSS */
}
/*@-mustmod@*/
@@ -352,7 +332,6 @@
void rpmnssClean(void * impl)
/*@modifies impl @*/
{
-#if defined(WITH_NSS)
rpmnss nss = impl;
/*@-moduncon@*/
if (nss != NULL) {
@@ -374,7 +353,6 @@
}
/*@=moduncon@*/
}
-#endif /* WITH_NSS */
}
/*@=mustmod@*/
@@ -382,13 +360,11 @@
void * rpmnssFree(/*@only@*/ void * impl)
/*@*/
{
-#if defined(WITH_NSS)
rpmnss nss = impl;
if (nss != NULL) {
rpmnssClean(impl);
nss = _free(nss);
}
-#endif /* WITH_NSS */
return NULL;
}
@@ -397,7 +373,6 @@
/*@globals _rpmnss_init @*/
/*@modifies _rpmnss_init @*/
{
-#if defined(WITH_NSS)
rpmnss nss = xcalloc(1, sizeof(*nss));
/*@-moduncon@*/
@@ -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)
+
/*@access pgpDig @*/
/*@access pgpDigParams @*/
@@ -30,7 +32,6 @@
extern int _pgp_print;
/*@=redecl@*/
-#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(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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]);
/*@=type@*/
return memcmp(signhash16, sigp->signhash16, sizeof(sigp->signhash16));
-#else
- return 1;
-#endif /* WITH_SSL */
}
static
int rpmsslVerifyRSA(pgpDig dig)
/*@*/
{
-#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(/*@only@*/ DIGEST_CTX ctx, pgpDig dig, pgpDigParams sigp)
/*@modifies 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)
/*@*/
{
-#if defined(WITH_SSL)
rpmssl ssl = dig->impl;
int rc;
@@ -227,9 +214,6 @@
/*@=moduncon@*/
return rc;
-#else
- return 0;
-#endif /* WITH_SSL */
}
static
@@ -238,7 +222,6 @@
/*@unused@*/ /*@null@*/ const rpmuint8_t * pend)
/*@*/
{
-#if defined(WITH_SSL)
rpmssl ssl = dig->impl;
unsigned int nb = ((pgpMpiBits(p) + 7) >> 3);
int rc = 0;
@@ -286,9 +269,6 @@
}
/*@=moduncon@*/
return rc;
-#else
- return 1;
-#endif /* WITH_SSL */
}
/*@-mustmod@*/
@@ -296,7 +276,6 @@
void rpmsslClean(void * impl)
/*@modifies impl @*/
{
-#if defined(WITH_SSL)
rpmssl ssl = impl;
/*@-moduncon@*/
if (ssl != NULL) {
@@ -318,7 +297,6 @@
}
}
/*@=moduncon@*/
-#endif /* WITH_SSL */
}
/*@=mustmod@*/
@@ -326,11 +304,9 @@
void * rpmsslFree(/*@only@*/ void * impl)
/*@modifies 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)
/*@*/
{
-#if defined(WITH_SSL)
rpmssl ssl = xcalloc(1, sizeof(*ssl));
/*@-moduncon@*/
ERR_load_crypto_strings();
/*@=moduncon@*/
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
+
@@ .
Received on Wed Aug 20 09:36:13 2008