From: mdw Date: Wed, 6 Dec 2000 20:33:27 +0000 (+0000) Subject: Make flags be macros rather than enumerations, to ensure that they're X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/commitdiff_plain/16efd15b675c87d22a4fd9fb12d7bb26f2a36031 Make flags be macros rather than enumerations, to ensure that they're unsigned. --- diff --git a/dsig.c b/dsig.c index a1e945d..a34cca2 100644 --- a/dsig.c +++ b/dsig.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: dsig.c,v 1.5 2000/10/08 12:12:09 mdw Exp $ + * $Id: dsig.c,v 1.6 2000/12/06 20:33:27 mdw Exp $ * * Verify signatures on distribuitions of files * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: dsig.c,v $ + * Revision 1.6 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.5 2000/10/08 12:12:09 mdw * Shut up some warnings. * @@ -876,11 +880,9 @@ static void fhex(FILE *fp, const void *p, size_t sz) static int sign(int argc, char *argv[]) { - enum { - f_raw = 1, - f_bin = 2, - f_bogus = 4 - }; +#define f_raw 1u +#define f_bin 2u +#define f_bogus 4u unsigned f = 0; const char *kt = 0; @@ -1118,17 +1120,19 @@ static int sign(int argc, char *argv[]) if (f & f_bogus) die(EXIT_FAILURE, "error(s) occurred while creating signature"); return (EXIT_SUCCESS); + +#undef f_raw +#undef f_bin +#undef f_bogus } /*----- Signature verification --------------------------------------------*/ static int verify(int argc, char *argv[]) { - enum { - f_bogus = 1, - f_bin = 2, - f_ok = 4 - }; +#define f_bogus 1u +#define f_bin 2u +#define f_ok 4u unsigned f = 0; unsigned verb = 1; @@ -1347,6 +1351,10 @@ done: puts("OK signature verified"); } return (f & f_bogus ? EXIT_FAILURE : EXIT_SUCCESS); + +#undef f_bogus +#undef f_bin +#undef f_ok } /*----- Main code ---------------------------------------------------------*/ @@ -1409,9 +1417,7 @@ int main(int argc, char *argv[]) cmd *c = 0, *cc = 0; size_t n; - enum { - f_bogus = 1 - }; +#define f_bogus 1u /* --- Initialize the library --- */ @@ -1479,6 +1485,8 @@ int main(int argc, char *argv[]) if (!cc) die(EXIT_FAILURE, "unknown command `%s'", argv[0]); return (cc->func(argc, argv)); + +#undef f_bogus } /*----- That's all, folks -------------------------------------------------*/ diff --git a/fipstest.h b/fipstest.h index fa150e2..9596d8a 100644 --- a/fipstest.h +++ b/fipstest.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: fipstest.h,v 1.2 2000/08/11 21:34:34 mdw Exp $ + * $Id: fipstest.h,v 1.3 2000/12/06 20:33:27 mdw Exp $ * * FIPS140 randomness tests * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: fipstest.h,v $ + * Revision 1.3 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.2 2000/08/11 21:34:34 mdw * Change to use the new thresholds given in the draft FIPS140-2. * @@ -53,13 +57,11 @@ #define FIPSTEST_BUFSZ 2500 -enum { - FIPSTEST_OK = 0, - FIPSTEST_MONOBIT = 1, - FIPSTEST_POKER = 2, - FIPSTEST_RUNS = 4, - FIPSTEST_LONGRUNS = 8 -}; +#define FIPSTEST_OK 0u +#define FIPSTEST_MONOBIT 1u +#define FIPSTEST_POKER 2u +#define FIPSTEST_RUNS 4u +#define FIPSTEST_LONGRUNS 8u /*----- Functions provided ------------------------------------------------*/ diff --git a/hashsum.c b/hashsum.c index db7d7f7..5776d93 100644 --- a/hashsum.c +++ b/hashsum.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: hashsum.c,v 1.4 2000/08/04 23:23:44 mdw Exp $ + * $Id: hashsum.c,v 1.5 2000/12/06 20:33:27 mdw Exp $ * * Hash files using some secure hash function * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: hashsum.c,v $ + * Revision 1.5 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.4 2000/08/04 23:23:44 mdw * Various fixes. * @@ -82,16 +86,14 @@ static const gchash *hashtab[] = { 0 }; -enum { - f_binary = 1, - f_bogus = 2, - f_verbose = 4, - f_check = 8, - f_files = 16, - f_raw = 32, - f_oddhash = 64, - f_escape = 128 -}; +#define f_binary 1u +#define f_bogus 2u +#define f_verbose 4u +#define f_check 8u +#define f_files 16u +#define f_raw 32u +#define f_oddhash 64u +#define f_escape 128u /*----- Support functions -------------------------------------------------*/ diff --git a/key.h b/key.h index 4ce7b7c..980c561 100644 --- a/key.h +++ b/key.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: key.h,v 1.6 2000/06/17 11:27:43 mdw Exp $ + * $Id: key.h,v 1.7 2000/12/06 20:33:27 mdw Exp $ * * Simple key management * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: key.h,v $ + * Revision 1.7 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.6 2000/06/17 11:27:43 mdw * Add key fetching interface. * @@ -141,10 +145,8 @@ typedef struct key_file { /* --- Key file flags --- */ -enum { - KF_WRITE = 1, /* File opened for writing */ - KF_MODIFIED = 2 /* File has been modified */ -}; +#define KF_WRITE 1u /* File opened for writing */ +#define KF_MODIFIED 2u /* File has been modified */ /* --- Iterating over keys --- * * diff --git a/keyutil.c b/keyutil.c index 174bbfe..fac8813 100644 --- a/keyutil.c +++ b/keyutil.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: keyutil.c,v 1.10 2000/10/08 12:02:21 mdw Exp $ + * $Id: keyutil.c,v 1.11 2000/12/06 20:33:27 mdw Exp $ * * Simple key manager program * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: keyutil.c,v $ + * Revision 1.11 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.10 2000/10/08 12:02:21 mdw * Use @MP_EQ@ instead of @MP_CMP@. * @@ -182,13 +186,11 @@ typedef struct keyopts { key *p; /* Parameters key-data */ } keyopts; -enum { - f_bogus = 1, /* Error in parsing */ - f_lock = 2, /* Passphrase-lock private key */ - f_quiet = 4, /* Don't show a progress indicator */ - f_limlee = 8, /* Generate Lim-Lee primes */ - f_subgroup = 16 /* Generate a subgroup */ -}; +#define f_bogus 1u /* Error in parsing */ +#define f_lock 2u /* Passphrase-lock private key */ +#define f_quiet 4u /* Don't show a progress indicator */ +#define f_limlee 8u /* Generate Lim-Lee primes */ +#define f_subgroup 16u /* Generate a subgroup */ /* --- @dolock@ --- * * @@ -912,11 +914,9 @@ typedef struct listopts { /* --- Listing flags --- */ -enum { - f_newline = 2, /* Write newline before next entry */ - f_attr = 4, /* Written at least one attribute */ - f_utc = 8 /* Emit UTC time, not local time */ -}; +#define f_newline 2u /* Write newline before next entry */ +#define f_attr 4u /* Written at least one attribute */ +#define f_utc 8u /* Emit UTC time, not local time */ /* --- @showkeydata@ --- * * @@ -1627,9 +1627,7 @@ int main(int argc, char *argv[]) { unsigned f = 0; - enum { - f_bogus = 1 - }; +#define f_bogus 1u /* --- Initialization --- */ diff --git a/limlee.h b/limlee.h index bccfccb..2802585 100644 --- a/limlee.h +++ b/limlee.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: limlee.h,v 1.2 2000/08/18 19:16:51 mdw Exp $ + * $Id: limlee.h,v 1.3 2000/12/06 20:33:27 mdw Exp $ * * Generate Lim-Lee primes * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: limlee.h,v $ + * Revision 1.3 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.2 2000/08/18 19:16:51 mdw * New stepper interface for constructing Lim-Lee primes. * @@ -102,9 +106,7 @@ typedef struct limlee_primeops { /* --- Flags --- */ -enum { - LIMLEE_KEEPFACTORS = 1 -}; +#define LIMLEE_KEEPFACTORS 1u /*----- The Lim-Lee stepper function --------------------------------------*/ diff --git a/lmem.h b/lmem.h index 36204c6..3f84c6e 100644 --- a/lmem.h +++ b/lmem.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: lmem.h,v 1.3 2000/07/29 21:58:15 mdw Exp $ + * $Id: lmem.h,v 1.4 2000/12/06 20:33:27 mdw Exp $ * * Locked memory allocation * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: lmem.h,v $ + * Revision 1.4 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.3 2000/07/29 21:58:15 mdw * (l_destroy): New function for destroying locked memory blocks. * @@ -72,9 +76,7 @@ typedef struct l_node { unsigned f; /* Various flags */ } l_node; -enum { - LF_ALLOC = 1 -}; +#define LF_ALLOC 1u /* --- Locked memory buffer state --- */ @@ -88,9 +90,7 @@ typedef struct lmem { int err; char *emsg; /* Error indicators */ } lmem; -enum { - LF_LOCKED = 1 -}; +#define LF_LOCKED 1u /*----- Functions provided ------------------------------------------------*/ diff --git a/mkphrase.c b/mkphrase.c index f315108..2d1ea1b 100644 --- a/mkphrase.c +++ b/mkphrase.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mkphrase.c,v 1.1 2000/08/06 10:50:55 mdw Exp $ + * $Id: mkphrase.c,v 1.2 2000/12/06 20:33:27 mdw Exp $ * * Generate passphrases from word lists * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: mkphrase.c,v $ + * Revision 1.2 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.1 2000/08/06 10:50:55 mdw * (mkphrase): New program for generating random passphrases with measured * strength. @@ -321,10 +325,8 @@ int main(int argc, char *argv[]) dstr dd = DSTR_INIT; unsigned i; - enum { - f_bogus = 1, - f_showp = 2 - }; +#define f_bogus 1u +#define f_showp 2u ego(argv[0]); for (;;) { diff --git a/passphrase.c b/passphrase.c index e19aed4..b0268d3 100644 --- a/passphrase.c +++ b/passphrase.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: passphrase.c,v 1.2 2000/06/17 11:49:37 mdw Exp $ + * $Id: passphrase.c,v 1.3 2000/12/06 20:33:27 mdw Exp $ * * Reading of passphrases (Unix-specific) * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: passphrase.c,v $ + * Revision 1.3 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.2 2000/06/17 11:49:37 mdw * New pixie protocol allowing application to request passphrases and send * them to the pixie. @@ -58,9 +62,7 @@ static int fd = -1; static unsigned flags = 0; -enum { - f_fail = 1 -}; +#define f_fail 1u /*----- Main code ---------------------------------------------------------*/ diff --git a/pixie.c b/pixie.c index 300a2f7..d4aefdf 100644 --- a/pixie.c +++ b/pixie.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: pixie.c,v 1.6 2000/10/08 12:06:46 mdw Exp $ + * $Id: pixie.c,v 1.7 2000/12/06 20:33:27 mdw Exp $ * * Passphrase pixie for Catacomb * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: pixie.c,v $ + * Revision 1.7 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.6 2000/10/08 12:06:46 mdw * Change size passed to socket function to be a @size_t@. Insert missing * type name for flag declaration. @@ -128,10 +132,8 @@ static const char *command = 0; static lmem lm; static unsigned flags = 0; -enum { - F_SYSLOG = 1, - F_FETCH = 2 -}; +#define F_SYSLOG 1u +#define F_FETCH 2u /*----- Event logging -----------------------------------------------------*/ @@ -1228,13 +1230,11 @@ int main(int argc, char *argv[]) size_t sz; unsigned f = 0; - enum { - f_bogus = 1, - f_client = 2, - f_stdin = 4, - f_daemon = 8, - f_syslog = 16 - }; +#define f_bogus 1u +#define f_client 2u +#define f_stdin 4u +#define f_daemon 8u +#define f_syslog 16u /* --- Initialize libraries --- */ diff --git a/rspit.c b/rspit.c index f4f177d..b9c8e72 100644 --- a/rspit.c +++ b/rspit.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rspit.c,v 1.12 2000/10/08 15:49:18 mdw Exp $ + * $Id: rspit.c,v 1.13 2000/12/06 20:33:27 mdw Exp $ * * Spit out random numbers * @@ -30,6 +30,10 @@ /*----- Revision history --------------------------------------------------* * * $Log: rspit.c,v $ + * Revision 1.13 2000/12/06 20:33:27 mdw + * Make flags be macros rather than enumerations, to ensure that they're + * unsigned. + * * Revision 1.12 2000/10/08 15:49:18 mdw * Remove failed kludge for shutting up a warning. * @@ -237,14 +241,12 @@ static char **argv; static unsigned flags = 0; -enum { - f_progress = 1, - f_file = 2, - f_fips = 4, - f_maurer = 8, - f_timer = 16, - f_discard = 32 -}; +#define f_progress 1u +#define f_file 2u +#define f_fips 4u +#define f_maurer 8u +#define f_timer 16u +#define f_discard 32u /*----- Help options ------------------------------------------------------*/