Skip to content

Commit

Permalink
Bug 1309068 - Enable -Wshadow, r=franziskus
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : eee25e22a1211223b9ba4a27a9511d9b417c9771
  • Loading branch information
martinthomson committed Feb 14, 2018
1 parent 46bcdec commit a9eace3
Show file tree
Hide file tree
Showing 70 changed files with 569 additions and 591 deletions.
6 changes: 3 additions & 3 deletions cmd/bltest/blapitest.c
Expand Up @@ -3724,7 +3724,7 @@ main(int argc, char **argv)
/* test the RSA_PopulatePrivateKey function */
if (bltest.commands[cmd_RSAPopulate].activated) {
unsigned int keySize = 1024;
unsigned long exponent = 65537;
unsigned long keyExponent = 65537;
int rounds = 1;
int ret = -1;

Expand All @@ -3735,12 +3735,12 @@ main(int argc, char **argv)
rounds = PORT_Atoi(bltest.options[opt_Rounds].arg);
}
if (bltest.options[opt_Exponent].activated) {
exponent = PORT_Atoi(bltest.options[opt_Exponent].arg);
keyExponent = PORT_Atoi(bltest.options[opt_Exponent].arg);
}

for (i = 0; i < rounds; i++) {
printf("Running RSA Populate test round %d\n", i);
ret = doRSAPopulateTest(keySize, exponent);
ret = doRSAPopulateTest(keySize, keyExponent);
if (ret != 0) {
break;
}
Expand Down
46 changes: 22 additions & 24 deletions cmd/certutil/certutil.c
Expand Up @@ -782,17 +782,17 @@ ValidateCert(CERTCertDBHandle *handle, char *name, char *date,
fprintf(stdout, "%s: certificate is valid\n", progName);
GEN_BREAK(SECSuccess)
} else {
char *name;
char *nick;
CERTVerifyLogNode *node;

node = log->head;
while (node) {
if (node->cert->nickname != NULL) {
name = node->cert->nickname;
nick = node->cert->nickname;
} else {
name = node->cert->subjectName;
nick = node->cert->subjectName;
}
fprintf(stderr, "%s : %s\n", name,
fprintf(stderr, "%s : %s\n", nick,
SECU_Strerror(node->error));
CERT_DestroyCertificate(node->cert);
node = node->next;
Expand Down Expand Up @@ -999,7 +999,7 @@ DeleteKey(char *nickname, secuPWData *pwdata)

slot = PK11_GetInternalKeySlot();
if (PK11_NeedLogin(slot)) {
SECStatus rv = PK11_Authenticate(slot, PR_TRUE, pwdata);
rv = PK11_Authenticate(slot, PR_TRUE, pwdata);
if (rv != SECSuccess) {
SECU_PrintError(progName, "could not authenticate to token %s.",
PK11_GetTokenName(slot));
Expand Down Expand Up @@ -1066,7 +1066,7 @@ PrintBuildFlags()
}

static void
PrintSyntax(char *progName)
PrintSyntax()
{
#define FPS fprintf(stderr,
FPS "Type %s -H for more detailed descriptions\n", progName);
Expand Down Expand Up @@ -1838,7 +1838,7 @@ luBuildFlags(enum usage_level ul, const char *command)
}

static void
LongUsage(char *progName, enum usage_level ul, const char *command)
LongUsage(enum usage_level ul, const char *command)
{
luA(ul, command);
luB(ul, command);
Expand Down Expand Up @@ -1866,14 +1866,14 @@ LongUsage(char *progName, enum usage_level ul, const char *command)
}

static void
Usage(char *progName)
Usage()
{
PR_fprintf(PR_STDERR,
"%s - Utility to manipulate NSS certificate databases\n\n"
"Usage: %s <command> -d <database-directory> <options>\n\n"
"Valid commands:\n",
progName, progName);
LongUsage(progName, usage_selected, NULL);
LongUsage(usage_selected, NULL);
PR_fprintf(PR_STDERR, "\n"
"%s -H <command> : Print available options for the given command\n"
"%s -H : Print complete help output of all commands and options\n"
Expand Down Expand Up @@ -2269,10 +2269,10 @@ flagArray opFlagsArray[] =
{ NAME_SIZE(verify_recover), CKF_VERIFY_RECOVER },
{ NAME_SIZE(wrap), CKF_WRAP },
{ NAME_SIZE(unwrap), CKF_UNWRAP },
{ NAME_SIZE(derive), CKF_DERIVE },
{ NAME_SIZE(derive), CKF_DERIVE }
};

int opFlagsCount = sizeof(opFlagsArray) / sizeof(flagArray);
int opFlagsCount = PR_ARRAY_SIZE(opFlagsArray);

flagArray attrFlagsArray[] =
{
Expand All @@ -2286,14 +2286,13 @@ flagArray attrFlagsArray[] =
{ NAME_SIZE(insensitive), PK11_ATTR_INSENSITIVE },
{ NAME_SIZE(extractable), PK11_ATTR_EXTRACTABLE },
{ NAME_SIZE(unextractable), PK11_ATTR_UNEXTRACTABLE }

};

int attrFlagsCount = sizeof(attrFlagsArray) / sizeof(flagArray);
int attrFlagsCount = PR_ARRAY_SIZE(attrFlagsArray);

#define MAX_STRING 30
CK_ULONG
GetFlags(char *flagsString, flagArray *flagArray, int count)
GetFlags(char *flagsString, flagArray *flags, int count)
{
CK_ULONG flagsValue = strtol(flagsString, NULL, 0);
int i;
Expand All @@ -2303,10 +2302,10 @@ GetFlags(char *flagsString, flagArray *flagArray, int count)
}
while (*flagsString) {
for (i = 0; i < count; i++) {
if (strncmp(flagsString, flagArray[i].name, flagArray[i].nameSize) ==
if (strncmp(flagsString, flags[i].name, flags[i].nameSize) ==
0) {
flagsValue |= flagArray[i].value;
flagsString += flagArray[i].nameSize;
flagsValue |= flags[i].value;
flagsString += flags[i].nameSize;
if (*flagsString != 0) {
flagsString++;
}
Expand Down Expand Up @@ -2691,14 +2690,13 @@ certutil_main(int argc, char **argv, PRBool initialize)
rv = SECU_ParseCommandLine(argc, argv, progName, &certutil);

if (rv != SECSuccess)
Usage(progName);
Usage();

if (certutil.commands[cmd_PrintSyntax].activated) {
PrintSyntax(progName);
PrintSyntax();
}

if (certutil.commands[cmd_PrintHelp].activated) {
int i;
char buf[2];
const char *command = NULL;
for (i = 0; i < max_cmd; i++) {
Expand All @@ -2715,7 +2713,7 @@ certutil_main(int argc, char **argv, PRBool initialize)
break;
}
}
LongUsage(progName, (command ? usage_selected : usage_all), command);
LongUsage((command ? usage_selected : usage_all), command);
exit(1);
}

Expand Down Expand Up @@ -2823,7 +2821,7 @@ certutil_main(int argc, char **argv, PRBool initialize)
if (certutil.options[opt_DBPrefix].arg) {
certPrefix = certutil.options[opt_DBPrefix].arg;
} else {
Usage(progName);
Usage();
}
}

Expand All @@ -2832,7 +2830,7 @@ certutil_main(int argc, char **argv, PRBool initialize)
if (certutil.options[opt_SourcePrefix].arg) {
srcCertPrefix = certutil.options[opt_SourcePrefix].arg;
} else {
Usage(progName);
Usage();
}
}

Expand Down Expand Up @@ -2916,7 +2914,7 @@ certutil_main(int argc, char **argv, PRBool initialize)
return 255;
}
if (commandsEntered == 0) {
Usage(progName);
Usage();
}

if (certutil.commands[cmd_ListCerts].activated ||
Expand Down
14 changes: 7 additions & 7 deletions cmd/crlutil/crlutil.c
Expand Up @@ -770,7 +770,7 @@ GenerateCRL(CERTCertDBHandle *certHandle, char *certNickName,
}

static void
Usage(char *progName)
Usage()
{
fprintf(stderr,
"Usage: %s -L [-n nickname] [-d keydir] [-P dbprefix] [-t crlType]\n"
Expand Down Expand Up @@ -908,7 +908,7 @@ main(int argc, char **argv)
while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
switch (optstate->option) {
case '?':
Usage(progName);
Usage();
break;

case 'T':
Expand Down Expand Up @@ -1038,17 +1038,17 @@ main(int argc, char **argv)
}

if (deleteCRL && !nickName)
Usage(progName);
Usage();
if (importCRL && !inFile)
Usage(progName);
Usage();
if (showFileCRL && !inFile)
Usage(progName);
Usage();
if ((generateCRL && !nickName) ||
(modifyCRL && !inFile && !nickName))
Usage(progName);
Usage();
if (!(listCRL || deleteCRL || importCRL || showFileCRL || generateCRL ||
modifyCRL || test || erase))
Usage(progName);
Usage();

if (listCRL || showFileCRL) {
readonly = PR_TRUE;
Expand Down
1 change: 0 additions & 1 deletion cmd/crmftest/testcrmf.c
Expand Up @@ -577,7 +577,6 @@ Decode(void)
printf("WARNING: The DER contained %d messages.\n", numMsgs);
}
for (i = 0; i < numMsgs; i++) {
SECStatus rv;
printf("crmftest: Processing cert request %d\n", i);
certReqMsg = CRMF_CertReqMessagesGetCertReqMsgAtIndex(certReqMsgs, i);
if (certReqMsg == NULL) {
Expand Down
7 changes: 3 additions & 4 deletions cmd/dbtest/dbtest.c
Expand Up @@ -58,7 +58,7 @@ getPassword(PK11SlotInfo *slot, PRBool retry, void *arg)
}

static void
Usage(const char *progName)
Usage()
{
printf("Usage: %s [-r] [-f] [-i] [-d dbdir ] \n",
progName);
Expand Down Expand Up @@ -96,7 +96,7 @@ main(int argc, char **argv)
switch (optstate->option) {
case 'h':
default:
Usage(progName);
Usage();
break;

case 'r':
Expand All @@ -122,7 +122,7 @@ main(int argc, char **argv)
}
PL_DestroyOptState(optstate);
if (optstatus == PL_OPT_BAD)
Usage(progName);
Usage();

if (dbDir) {
char *tmp = dbDir;
Expand Down Expand Up @@ -181,7 +181,6 @@ main(int argc, char **argv)
ret = SUCCESS;
if (doInitTest) {
PK11SlotInfo *slot = PK11_GetInternalKeySlot();
SECStatus rv;
int passwordSuccess = 0;
int type = CKM_DES3_CBC;
SECItem keyid = { 0, NULL, 0 };
Expand Down
10 changes: 4 additions & 6 deletions cmd/httpserv/httpserv.c
Expand Up @@ -682,6 +682,7 @@ handle_connection(
}
if (arena) {
PORT_FreeArena(arena, PR_FALSE);
arena = NULL;
}
if (!request || !request->tbsRequest ||
!request->tbsRequest->requestList ||
Expand Down Expand Up @@ -753,11 +754,11 @@ handle_connection(

{
PRTime now = PR_Now();
PLArenaPool *arena = NULL;
CERTOCSPSingleResponse *sr;
CERTOCSPSingleResponse **singleResponses;
SECItem *ocspResponse;

PORT_Assert(!arena);
arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);

if (unknown) {
Expand Down Expand Up @@ -787,8 +788,8 @@ handle_connection(
} else {
PR_Write(ssl_sock, outOcspHeader, strlen(outOcspHeader));
PR_Write(ssl_sock, ocspResponse->data, ocspResponse->len);
PORT_FreeArena(arena, PR_FALSE);
}
PORT_FreeArena(arena, PR_FALSE);
}
CERT_DestroyOCSPRequest(request);
break;
Expand Down Expand Up @@ -1357,7 +1358,6 @@ main(int argc, char **argv)
caRevoIter = &caRevoInfos->link;
do {
PRFileDesc *inFile;
int rv = SECFailure;
SECItem crlDER;
crlDER.data = NULL;

Expand Down Expand Up @@ -1413,11 +1413,9 @@ main(int argc, char **argv)

if (provideOcsp) {
if (caRevoInfos) {
PRCList *caRevoIter;

caRevoIter = &caRevoInfos->link;
do {
caRevoInfo *revoInfo = (caRevoInfo *)caRevoIter;
revoInfo = (caRevoInfo *)caRevoIter;
if (revoInfo->nickname)
PORT_Free(revoInfo->nickname);
if (revoInfo->crlFilename)
Expand Down
8 changes: 4 additions & 4 deletions cmd/lib/secutil.c
Expand Up @@ -1528,9 +1528,9 @@ SECU_PrintDumpDerIssuerAndSerial(FILE *out, SECItem *der, char *m,
unsigned int i;
for (i = 0; i < c->serialNumber.len; ++i) {
unsigned char *chardata = (unsigned char *)(c->serialNumber.data);
unsigned char c = *(chardata + i);
unsigned char ch = *(chardata + i);

fprintf(out, "\\x%02x", c);
fprintf(out, "\\x%02x", ch);
}
fprintf(out, "\" }\n");
}
Expand Down Expand Up @@ -3137,7 +3137,7 @@ typedef enum {
static int
secu_PrintSignedDataSigOpt(FILE *out, SECItem *der, const char *m,
int level, SECU_PPFunc inner,
SignatureOptionType withSignature)
SignatureOptionType signatureOption)
{
PLArenaPool *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
CERTSignedData *sd;
Expand All @@ -3164,7 +3164,7 @@ secu_PrintSignedDataSigOpt(FILE *out, SECItem *der, const char *m,
}
rv = (*inner)(out, &sd->data, "Data", level + 1);

if (withSignature) {
if (signatureOption == withSignature) {
SECU_PrintAlgorithmID(out, &sd->signatureAlgorithm, "Signature Algorithm",
level + 1);
DER_ConvertBitString(&sd->signature);
Expand Down
2 changes: 0 additions & 2 deletions cmd/listsuites/listsuites.c
Expand Up @@ -64,9 +64,7 @@ main(int argc, char **argv)
/* disable all the SSL3 cipher suites */
for (i = 0; i < SSL_NumImplementedCiphers; i++) {
PRUint16 suite = cipherSuites[i];
SECStatus rv;
PRBool enabled;
PRErrorCode err;
SSLCipherSuiteInfo info;

rv = SSL_CipherPrefGetDefault(suite, &enabled);
Expand Down
4 changes: 2 additions & 2 deletions cmd/lowhashtest/lowhashtest.c
Expand Up @@ -390,7 +390,7 @@ testSHA512(NSSLOWInitContext *initCtx)
}

static void
Usage(char *progName)
Usage()
{
fprintf(stderr, "Usage: %s [algorithm]\n",
progName);
Expand Down Expand Up @@ -436,7 +436,7 @@ main(int argc, char **argv)
rv += testSHA512(initCtx);
} else {
SECU_PrintError(progName, "Unsupported hash type %s\n", argv[0]);
Usage(progName);
Usage();
}

NSSLOW_Shutdown(initCtx);
Expand Down
10 changes: 5 additions & 5 deletions cmd/modutil/install-ds.c
Expand Up @@ -88,11 +88,11 @@ static const char* errString[] = {

static char* PR_Strdup(const char* str);

#define PAD(x) \
{ \
int i; \
for (i = 0; i < x; i++) \
printf(" "); \
#define PAD(x) \
{ \
int pad_i; \
for (pad_i = 0; pad_i < (x); pad_i++) \
printf(" "); \
}
#define PADINC 4

Expand Down

0 comments on commit a9eace3

Please sign in to comment.