Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1254918 - clang-format NSS: cmd, r=kaie
  • Loading branch information
franziskuskiefer committed Apr 21, 2016
1 parent 459b03f commit c582cda
Show file tree
Hide file tree
Showing 171 changed files with 7,037 additions and 7,668 deletions.
40 changes: 22 additions & 18 deletions cmd/addbuiltin/addbuiltin.c
Expand Up @@ -18,7 +18,8 @@
#include <io.h>
#endif

void dumpbytes(unsigned char *buf, int len)
void
dumpbytes(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len; i++) {
Expand All @@ -30,7 +31,8 @@ void dumpbytes(unsigned char *buf, int len)
printf("\n");
}

char *getTrustString(unsigned int trust)
char *
getTrustString(unsigned int trust)
{
if (trust & CERTDB_TRUSTED) {
if (trust & CERTDB_TRUSTED_CA) {
Expand All @@ -57,7 +59,8 @@ static const SEC_ASN1Template serialTemplate[] = {
{ 0 }
};

void print_crl_info(CERTName *name, SECItem *serial)
void
print_crl_info(CERTName *name, SECItem *serial)
{
PRBool saveWrapeState = SECU_GetWrapEnabled();
SECU_EnableWrap(PR_FALSE);
Expand Down Expand Up @@ -134,7 +137,8 @@ ConvertCRLEntry(SECItem *sdder, PRInt32 crlentry, char *nickname)
return rv;
}

void print_info(SECItem *sdder, CERTCertificate *c)
void
print_info(SECItem *sdder, CERTCertificate *c)
{
PRBool saveWrapeState = SECU_GetWrapEnabled();
SECU_EnableWrap(PR_FALSE);
Expand Down Expand Up @@ -200,8 +204,8 @@ ConvertCertificate(SECItem *sdder, char *nickname, CERTCertTrust *trust,
printf("END\n");
}

if ((trust->sslFlags | trust->emailFlags | trust->objectSigningFlags)
== CERTDB_TERMINAL_RECORD)
if ((trust->sslFlags | trust->emailFlags | trust->objectSigningFlags) ==
CERTDB_TERMINAL_RECORD)
trust_info = "Distrust";
else
trust_info = "Trust for";
Expand Down Expand Up @@ -255,10 +259,11 @@ ConvertCertificate(SECItem *sdder, char *nickname, CERTCertTrust *trust,

PORT_Free(sdder->data);
return (rv);

}

void printheader() {
void
printheader()
{
printf("# \n"
"# This Source Code Form is subject to the terms of the Mozilla Public\n"
"# License, v. 2.0. If a copy of the MPL was not distributed with this\n"
Expand Down Expand Up @@ -332,7 +337,8 @@ void printheader() {
"CKA_LABEL UTF8 \"Mozilla Builtin Roots\"\n");
}

static void Usage(char *progName)
static void
Usage(char *progName)
{
fprintf(stderr, "%s -t trust -n nickname [-i certfile] [-c] [-h]\n", progName);
fprintf(stderr,
Expand Down Expand Up @@ -387,7 +393,8 @@ static secuCommandFlag addbuiltin_options[] =
{ /* opt_CRLEnry */ 'e', PR_TRUE, 0, PR_FALSE },
};

int main(int argc, char **argv)
int
main(int argc, char **argv)
{
SECStatus rv;
char *nickname = NULL;
Expand Down Expand Up @@ -430,8 +437,7 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: you must specify the CRL entry number.\n",
progName);
Usage(progName);
}
else {
} else {
crlentry = atoi(addbuiltin.options[opt_CRLEnry].arg);
if (crlentry < 1) {
fprintf(stderr, "%s: The CRL entry number must be > 0.\n",
Expand Down Expand Up @@ -497,8 +503,7 @@ int main(int argc, char **argv)
if (addbuiltin.options[opt_Distrust].activated) {
trusts = strdup("p,p,p");
decodeTrust = PR_TRUE;
}
else if (addbuiltin.options[opt_Trust].activated) {
} else if (addbuiltin.options[opt_Trust].activated) {
trusts = strdup(addbuiltin.options[opt_Trust].arg);
decodeTrust = PR_TRUE;
}
Expand All @@ -513,8 +518,8 @@ int main(int argc, char **argv)

if (addbuiltin.options[opt_Trust].activated &&
addbuiltin.options[opt_ExcludeHash].activated) {
if ((trust.sslFlags | trust.emailFlags | trust.objectSigningFlags)
!= CERTDB_TERMINAL_RECORD) {
if ((trust.sslFlags | trust.emailFlags | trust.objectSigningFlags) !=
CERTDB_TERMINAL_RECORD) {
fprintf(stderr, "%s: Excluding the hash only allowed with distrust.\n", progName);
Usage(progName);
}
Expand All @@ -526,8 +531,7 @@ int main(int argc, char **argv)

if (addbuiltin.options[opt_DistrustCRL].activated) {
rv = ConvertCRLEntry(&derItem, crlentry, nickname);
}
else {
} else {
rv = ConvertCertificate(&derItem, nickname, &trust,
addbuiltin.options[opt_ExcludeCert].activated,
addbuiltin.options[opt_ExcludeHash].activated);
Expand Down
26 changes: 15 additions & 11 deletions cmd/atob/atob.c
Expand Up @@ -38,12 +38,11 @@ output_binary (void *arg, const unsigned char *obuf, PRInt32 size)
static PRBool
isBase64Char(char c)
{
return ((c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z')
|| (c >= '0' && c <= '9')
|| c == '+'
|| c == '/'
|| c == '=');
return ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '+' || c == '/' ||
c == '=');
}

static SECStatus
Expand All @@ -60,7 +59,8 @@ decode_file(FILE *outFile, FILE *inFile)
}

for (;;) {
if (feof(inFile)) break;
if (feof(inFile))
break;
if (!fgets(ibuf, sizeof(ibuf), inFile)) {
if (ferror(inFile)) {
PORT_SetError(SEC_ERROR_IO);
Expand All @@ -84,7 +84,8 @@ decode_file(FILE *outFile, FILE *inFile)
}

status = NSSBase64Decoder_Update(cx, ibuf, ptr - ibuf);
if (status != SECSuccess) goto loser;
if (status != SECSuccess)
goto loser;
}

return NSSBase64Decoder_Destroy(cx, PR_FALSE);
Expand All @@ -94,7 +95,8 @@ decode_file(FILE *outFile, FILE *inFile)
return status;
}

static void Usage(char *progName)
static void
Usage(char *progName)
{
fprintf(stderr,
"Usage: %s [-i input] [-o output]\n",
Expand All @@ -106,7 +108,8 @@ static void Usage(char *progName)
exit(-1);
}

int main(int argc, char **argv)
int
main(int argc, char **argv)
{
char *progName;
SECStatus rv;
Expand Down Expand Up @@ -147,7 +150,8 @@ int main(int argc, char **argv)
break;
}
}
if (!inFile) inFile = stdin;
if (!inFile)
inFile = stdin;
if (!outFile) {
#if defined(WIN32)
int smrv = _setmode(_fileno(stdout), _O_BINARY);
Expand Down

0 comments on commit c582cda

Please sign in to comment.