From b4df02565f4cbfaee421556279e38d37e6e3169d Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 14 Apr 2015 00:32:03 +0000 Subject: [PATCH] MFC r280716,280767,280914: - Correct type for checkAgainst. - Staticify flags that are not used outside the file scope. - Fix warnings. - Constify parameters. git-svn-id: svn://svn.freebsd.org/base/stable/10@281513 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/md5/Makefile | 3 --- sbin/md5/md5.c | 34 +++++++++++++++++----------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/sbin/md5/Makefile b/sbin/md5/Makefile index eabf129f6..c39aaa74c 100644 --- a/sbin/md5/Makefile +++ b/sbin/md5/Makefile @@ -13,9 +13,6 @@ MLINKS= md5.1 rmd160.1 \ md5.1 sha256.1 \ md5.1 sha512.1 -NO_WMISSING_VARIABLE_DECLARATIONS= -WFORMAT?= 1 - DPADD= ${LIBMD} LDADD= -lmd diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 823d09b2c..f4c56ac86 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -42,11 +42,11 @@ __FBSDID("$FreeBSD$"); #define TEST_BLOCK_COUNT 100000 #define MDTESTCOUNT 8 -int qflag; -int rflag; -int sflag; -unsigned char* checkAgainst; -int checksFailed; +static int qflag; +static int rflag; +static int sflag; +static char* checkAgainst; +static int checksFailed; typedef void (DIGEST_Init)(void *); typedef void (DIGEST_Update)(void *, const unsigned char *, size_t); @@ -70,11 +70,11 @@ typedef struct Algorithm_t { } Algorithm_t; static void MD5_Update(MD5_CTX *, const unsigned char *, size_t); -static void MDString(Algorithm_t *, const char *); -static void MDTimeTrial(Algorithm_t *); -static void MDTestSuite(Algorithm_t *); -static void MDFilter(Algorithm_t *, int); -static void usage(Algorithm_t *); +static void MDString(const Algorithm_t *, const char *); +static void MDTimeTrial(const Algorithm_t *); +static void MDTestSuite(const Algorithm_t *); +static void MDFilter(const Algorithm_t *, int); +static void usage(const Algorithm_t *); typedef union { MD5_CTX md5; @@ -91,7 +91,7 @@ typedef union { /* algorithm function table */ -struct Algorithm_t Algorithm[] = { +static const struct Algorithm_t Algorithm[] = { { "md5", "MD5", &MD5TestOutput, (DIGEST_Init*)&MD5Init, (DIGEST_Update*)&MD5_Update, (DIGEST_End*)&MD5End, &MD5Data, &MD5File }, @@ -216,7 +216,7 @@ main(int argc, char *argv[]) * Digests a string and prints the result. */ static void -MDString(Algorithm_t *alg, const char *string) +MDString(const Algorithm_t *alg, const char *string) { size_t len = strlen(string); char buf[HEX_DIGEST_LENGTH]; @@ -240,7 +240,7 @@ MDString(Algorithm_t *alg, const char *string) * Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks. */ static void -MDTimeTrial(Algorithm_t *alg) +MDTimeTrial(const Algorithm_t *alg) { DIGEST_CTX context; struct rusage before, after; @@ -282,7 +282,7 @@ MDTimeTrial(Algorithm_t *alg) * Digests a reference suite of strings and prints the results. */ -const char *MDTestInput[MDTESTCOUNT] = { +static const char *MDTestInput[MDTESTCOUNT] = { "", "a", "abc", @@ -350,7 +350,7 @@ const char *RIPEMD160_TestOutput[MDTESTCOUNT] = { }; static void -MDTestSuite(Algorithm_t *alg) +MDTestSuite(const Algorithm_t *alg) { int i; char buffer[HEX_DIGEST_LENGTH]; @@ -370,7 +370,7 @@ MDTestSuite(Algorithm_t *alg) * Digests the standard input and prints the result. */ static void -MDFilter(Algorithm_t *alg, int tee) +MDFilter(const Algorithm_t *alg, int tee) { DIGEST_CTX context; unsigned int len; @@ -387,7 +387,7 @@ MDFilter(Algorithm_t *alg, int tee) } static void -usage(Algorithm_t *alg) +usage(const Algorithm_t *alg) { fprintf(stderr, "usage: %s [-pqrtx] [-c string] [-s string] [files ...]\n", alg->progname); -- 2.45.0