Skip to content

Commit db6a2cc

Browse files
authored
Merge pull request #8077 from douzzer/20241015-C89-pedantic-fixes
20241015-C89-pedantic-fixes
2 parents 4fd33b6 + ffc0721 commit db6a2cc

19 files changed

Lines changed: 131 additions & 126 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20858,7 +20858,7 @@ static const ASNItem subjDirAttrASN[] = {
2085820858
enum {
2085920859
SUBJDIRATTRASN_IDX_SEQ = 0,
2086020860
SUBJDIRATTRASN_IDX_OID,
20861-
SUBJDIRATTRASN_IDX_SET,
20861+
SUBJDIRATTRASN_IDX_SET
2086220862
};
2086320863

2086420864
/* Number of items in ASN.1 template for BasicConstraints. */
@@ -23526,9 +23526,9 @@ typedef struct DecodeInstr {
2352623526
/* Tag expected. */
2352723527
byte tag;
2352823528
/* Operation to perform: step in or go over */
23529-
byte op:1;
23529+
WC_BITFIELD op:1;
2353023530
/* ASN.1 item is optional. */
23531-
byte optional:1;
23531+
WC_BITFIELD optional:1;
2353223532
} DecodeInstr;
2353323533

2353423534
/* Step into ASN.1 item. */
@@ -40761,7 +40761,7 @@ enum {
4076140761
HOLDER_IDX_ISSUERSERIAL_SEQ,
4076240762
HOLDER_IDX_GN_SEQ,
4076340763
HOLDER_IDX_SERIAL_INT,
40764-
HOLDER_IDX_GN_SEQ_OPT1,
40764+
HOLDER_IDX_GN_SEQ_OPT1
4076540765
};
4076640766

4076740767
/* Number of items in ASN template for an X509 Acert. */
@@ -40885,7 +40885,7 @@ static const ASNItem AttCertIssuerASN[] =
4088540885
};
4088640886

4088740887
enum {
40888-
ATTCERTISSUER_IDX_GN_SEQ,
40888+
ATTCERTISSUER_IDX_GN_SEQ
4088940889
};
4089040890

4089140891
/* Number of items in ASN template for an X509 Acert. */

wolfcrypt/src/pkcs7.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ struct PKCS7State {
118118
word32 peakUsed; /* most bytes used for struct at any one time */
119119
word32 peakRead; /* most bytes used by read buffer */
120120
#endif
121-
byte multi:1; /* flag for if content is in multiple parts */
122-
byte flagOne:1;
123-
byte detached:1; /* flag to indicate detached signature is present */
124-
byte noContent:1;/* indicates content isn't included in bundle */
125-
byte degenerate:1;
126-
byte indefLen:1; /* flag to indicate indef-length encoding used */
121+
WC_BITFIELD multi:1; /* flag for if content is in multiple parts */
122+
WC_BITFIELD flagOne:1;
123+
WC_BITFIELD detached:1; /* flag to indicate detached signature is present */
124+
WC_BITFIELD noContent:1;/* indicates content isn't included in bundle */
125+
WC_BITFIELD degenerate:1;
126+
WC_BITFIELD indefLen:1; /* flag to indicate indef-length encoding used */
127127
};
128128

129129

@@ -1523,7 +1523,7 @@ typedef struct ESD {
15231523
wc_HashAlg hash;
15241524
enum wc_HashType hashType;
15251525
byte contentDigest[WC_MAX_DIGEST_SIZE + 2]; /* content only + ASN.1 heading */
1526-
byte contentDigestSet:1;
1526+
WC_BITFIELD contentDigestSet:1;
15271527
byte contentAttribsDigest[WC_MAX_DIGEST_SIZE];
15281528
byte encContentDigest[MAX_ENCRYPTED_KEY_SZ];
15291529

@@ -6829,9 +6829,9 @@ typedef struct WC_PKCS7_KARI {
68296829
word32 sharedInfoSz; /* size of ECC-CMS-SharedInfo encoded */
68306830
byte ukmOwner; /* do we own ukm buffer? 1:yes, 0:no */
68316831
byte direction; /* WC_PKCS7_ENCODE | WC_PKCS7_DECODE */
6832-
byte decodedInit : 1; /* indicates decoded was initialized */
6833-
byte recipKeyInit : 1; /* indicates recipKey was initialized */
6834-
byte senderKeyInit : 1; /* indicates senderKey was initialized */
6832+
WC_BITFIELD decodedInit:1; /* indicates decoded was initialized */
6833+
WC_BITFIELD recipKeyInit:1; /* indicates recipKey was initialized */
6834+
WC_BITFIELD senderKeyInit:1; /* indicates senderKey was initialized */
68356835
} WC_PKCS7_KARI;
68366836

68376837

wolfssl/wolfcrypt/aes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ struct Aes {
388388
byte over;
389389
byte aOver;
390390
byte cOver;
391-
byte gcmKeySet:1;
392-
byte nonceSet:1;
393-
byte ctrSet:1;
391+
WC_BITFIELD gcmKeySet:1;
392+
WC_BITFIELD nonceSet:1;
393+
WC_BITFIELD ctrSet:1;
394394
#endif
395-
byte isAllocated:1; /* flag indicates if structure was allocated */
395+
WC_BITFIELD isAllocated:1; /* flag indicates if structure was allocated */
396396
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
397397
void *CipherLifecycleTag; /* used for dummy allocation and initialization,
398398
* trackable by sanitizers.

wolfssl/wolfcrypt/asn.h

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ typedef struct ASNItem {
224224
/* BER/DER tag to expect. */
225225
byte tag;
226226
/* Whether the ASN.1 item is constructed. */
227-
byte constructed:1;
227+
WC_BITFIELD constructed:1;
228228
/* Whether to parse the header only or skip data. If
229229
* ASNSetData.data.buffer.data is supplied then this option gets
230230
* overwritten and the child nodes get ignored. */
231-
byte headerOnly:1;
231+
WC_BITFIELD headerOnly:1;
232232
/* Whether ASN.1 item is optional.
233233
* - 0 means not optional
234234
* - 1 means is optional
@@ -1273,8 +1273,9 @@ enum Extensions_Sum {
12731273
#ifdef WOLFSSL_DUAL_ALG_CERTS
12741274
SUBJ_ALT_PUB_KEY_INFO_OID = 186, /* 2.5.29.72 subject alt public key info */
12751275
ALT_SIG_ALG_OID = 187, /* 2.5.29.73 alt sig alg */
1276-
ALT_SIG_VAL_OID = 188 /* 2.5.29.74 alt sig val */
1276+
ALT_SIG_VAL_OID = 188, /* 2.5.29.74 alt sig val */
12771277
#endif
1278+
WOLF_ENUM_DUMMY_LAST_ELEMENT(Extensions_Sum)
12781279
};
12791280

12801281
enum CertificatePolicy_Sum {
@@ -1941,63 +1942,63 @@ struct DecodedCert {
19411942
int criticalExt;
19421943

19431944
/* Option Bits */
1944-
byte subjectCNStored : 1; /* have we saved a copy we own */
1945-
byte extSubjKeyIdSet : 1; /* Set when the SKID was read from cert */
1946-
byte extAuthKeyIdSet : 1; /* Set when the AKID was read from cert */
1945+
WC_BITFIELD subjectCNStored:1; /* have we saved a copy we own */
1946+
WC_BITFIELD extSubjKeyIdSet:1; /* Set when the SKID was read from cert */
1947+
WC_BITFIELD extAuthKeyIdSet:1; /* Set when the AKID was read from cert */
19471948
#ifndef IGNORE_NAME_CONSTRAINTS
1948-
byte extNameConstraintSet : 1;
1949+
WC_BITFIELD extNameConstraintSet:1;
19491950
#endif
1950-
byte isCA : 1; /* CA basic constraint true */
1951-
byte pathLengthSet : 1; /* CA basic const path length set */
1952-
byte weOwnAltNames : 1; /* altNames haven't been given to copy */
1953-
byte extKeyUsageSet : 1;
1954-
byte extExtKeyUsageSet : 1; /* Extended Key Usage set */
1951+
WC_BITFIELD isCA:1; /* CA basic constraint true */
1952+
WC_BITFIELD pathLengthSet:1; /* CA basic const path length set */
1953+
WC_BITFIELD weOwnAltNames:1; /* altNames haven't been given to copy */
1954+
WC_BITFIELD extKeyUsageSet:1;
1955+
WC_BITFIELD extExtKeyUsageSet:1; /* Extended Key Usage set */
19551956
#ifdef HAVE_OCSP
1956-
byte ocspNoCheckSet : 1; /* id-pkix-ocsp-nocheck set */
1957-
#endif
1958-
byte extCRLdistSet : 1;
1959-
byte extAuthInfoSet : 1;
1960-
byte extBasicConstSet : 1;
1961-
byte extPolicyConstSet : 1;
1962-
byte extPolicyConstRxpSet : 1; /* requireExplicitPolicy set */
1963-
byte extPolicyConstIpmSet : 1; /* inhibitPolicyMapping set */
1964-
byte extSubjAltNameSet : 1;
1965-
byte inhibitAnyOidSet : 1;
1966-
byte selfSigned : 1; /* Indicates subject and issuer are same */
1957+
WC_BITFIELD ocspNoCheckSet:1; /* id-pkix-ocsp-nocheck set */
1958+
#endif
1959+
WC_BITFIELD extCRLdistSet:1;
1960+
WC_BITFIELD extAuthInfoSet:1;
1961+
WC_BITFIELD extBasicConstSet:1;
1962+
WC_BITFIELD extPolicyConstSet:1;
1963+
WC_BITFIELD extPolicyConstRxpSet:1; /* requireExplicitPolicy set */
1964+
WC_BITFIELD extPolicyConstIpmSet:1; /* inhibitPolicyMapping set */
1965+
WC_BITFIELD extSubjAltNameSet:1;
1966+
WC_BITFIELD inhibitAnyOidSet:1;
1967+
WC_BITFIELD selfSigned:1; /* Indicates subject and issuer are same */
19671968
#ifdef WOLFSSL_SEP
1968-
byte extCertPolicySet : 1;
1969-
#endif
1970-
byte extCRLdistCrit : 1;
1971-
byte extAuthInfoCrit : 1;
1972-
byte extBasicConstCrit : 1;
1973-
byte extPolicyConstCrit : 1;
1974-
byte extSubjAltNameCrit : 1;
1975-
byte extAuthKeyIdCrit : 1;
1969+
WC_BITFIELD extCertPolicySet:1;
1970+
#endif
1971+
WC_BITFIELD extCRLdistCrit:1;
1972+
WC_BITFIELD extAuthInfoCrit:1;
1973+
WC_BITFIELD extBasicConstCrit:1;
1974+
WC_BITFIELD extPolicyConstCrit:1;
1975+
WC_BITFIELD extSubjAltNameCrit:1;
1976+
WC_BITFIELD extAuthKeyIdCrit:1;
19761977
#ifndef IGNORE_NAME_CONSTRAINTS
1977-
byte extNameConstraintCrit : 1;
1978+
WC_BITFIELD extNameConstraintCrit:1;
19781979
#endif
1979-
byte extSubjKeyIdCrit : 1;
1980-
byte extKeyUsageCrit : 1;
1981-
byte extExtKeyUsageCrit : 1;
1980+
WC_BITFIELD extSubjKeyIdCrit:1;
1981+
WC_BITFIELD extKeyUsageCrit:1;
1982+
WC_BITFIELD extExtKeyUsageCrit:1;
19821983
#ifdef WOLFSSL_SUBJ_DIR_ATTR
1983-
byte extSubjDirAttrSet : 1;
1984+
WC_BITFIELD extSubjDirAttrSet:1;
19841985
#endif
19851986
#ifdef WOLFSSL_SUBJ_INFO_ACC
1986-
byte extSubjInfoAccSet : 1;
1987+
WC_BITFIELD extSubjInfoAccSet:1;
19871988
#endif
19881989
#ifdef WOLFSSL_DUAL_ALG_CERTS
1989-
byte extSapkiSet : 1;
1990-
byte extAltSigAlgSet : 1;
1991-
byte extAltSigValSet : 1;
1990+
WC_BITFIELD extSapkiSet:1;
1991+
WC_BITFIELD extAltSigAlgSet:1;
1992+
WC_BITFIELD extAltSigValSet:1;
19921993
#endif /* WOLFSSL_DUAL_ALG_CERTS */
19931994
#ifdef WOLFSSL_SEP
1994-
byte extCertPolicyCrit : 1;
1995+
WC_BITFIELD extCertPolicyCrit:1;
19951996
#endif
19961997
#ifdef WOLFSSL_CERT_REQ
1997-
byte isCSR : 1; /* Do we intend on parsing a CSR? */
1998+
WC_BITFIELD isCSR:1; /* Do we intend on parsing a CSR? */
19981999
#endif
19992000
#ifdef HAVE_RPK
2000-
byte isRPK : 1; /* indicate the cert is Raw-Public-Key cert in RFC7250 */
2001+
WC_BITFIELD isRPK:1; /* indicate the cert is Raw-Public-Key cert in RFC7250 */
20012002
#endif
20022003
#ifdef WC_ASN_UNKNOWN_EXT_CB
20032004
wc_UnknownExtCallback unknownExtCallback;
@@ -2034,7 +2035,7 @@ struct Signer {
20342035
word32 keyOID; /* key type */
20352036
word16 keyUsage;
20362037
byte maxPathLen;
2037-
byte selfSigned : 1;
2038+
WC_BITFIELD selfSigned:1;
20382039
const byte* publicKey;
20392040
int nameLen;
20402041
char* name; /* common name */
@@ -2572,10 +2573,10 @@ struct OcspEntry
25722573
byte* rawCertId; /* raw bytes of the CertID */
25732574
int rawCertIdSize; /* num bytes in raw CertID */
25742575
/* option bits - using 32-bit for alignment */
2575-
word32 ownStatus:1; /* do we need to free the status
2576+
WC_BITFIELD ownStatus:1; /* do we need to free the status
25762577
* response list */
2577-
word32 isDynamic:1; /* was dynamically allocated */
2578-
word32 used:1; /* entry used */
2578+
WC_BITFIELD isDynamic:1; /* was dynamically allocated */
2579+
WC_BITFIELD used:1; /* entry used */
25792580
};
25802581

25812582
/* TODO: Long-term, it would be helpful if we made this struct and other OCSP

wolfssl/wolfcrypt/asn_public.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ typedef struct EncryptedInfo {
332332
char name[NAME_SZ]; /* cipher name, such as "DES-CBC" */
333333
byte iv[IV_SZ]; /* salt or encrypted IV */
334334

335-
word16 set:1; /* if encryption set */
335+
WC_BITFIELD set:1; /* if encryption set */
336336
#endif
337337
} EncryptedInfo;
338338

@@ -347,7 +347,7 @@ typedef struct WOLFSSL_ASN1_INTEGER {
347347

348348
unsigned char* data;
349349
unsigned int dataMax; /* max size of data buffer */
350-
unsigned int isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
350+
WC_BITFIELD isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
351351

352352
int length; /* Length of DER encoding. */
353353
int type; /* ASN.1 type. Includes negative flag. */
@@ -549,13 +549,13 @@ typedef struct Cert {
549549
void* decodedCert; /* internal DecodedCert allocated from heap */
550550
byte* der; /* Pointer to buffer of current DecodedCert cache */
551551
void* heap; /* heap hint */
552-
byte basicConstSet:1; /* Indicator for when Basic Constraint is set */
552+
WC_BITFIELD basicConstSet:1; /* Indicator for when Basic Constraint is set */
553553
#ifdef WOLFSSL_ALLOW_ENCODING_CA_FALSE
554-
byte isCaSet:1; /* Indicator for when isCA is set */
554+
WC_BITFIELD isCaSet:1; /* Indicator for when isCA is set */
555555
#endif
556-
byte pathLenSet:1; /* Indicator for when path length is set */
556+
WC_BITFIELD pathLenSet:1; /* Indicator for when path length is set */
557557
#ifdef WOLFSSL_ALT_NAMES
558-
byte altNamesCrit:1; /* Indicator of criticality of SAN extension */
558+
WC_BITFIELD altNamesCrit:1; /* Indicator of criticality of SAN extension */
559559
#endif
560560
} Cert;
561561

@@ -937,9 +937,9 @@ typedef struct _wc_CertPIV {
937937
word32 signedNonceSz; /* Identiv Only */
938938

939939
/* flags */
940-
word16 compression:2;
941-
word16 isX509:1;
942-
word16 isIdentiv:1;
940+
WC_BITFIELD compression:2;
941+
WC_BITFIELD isX509:1;
942+
WC_BITFIELD isIdentiv:1;
943943
} wc_CertPIV;
944944

945945
WOLFSSL_API int wc_ParseCertPIV(wc_CertPIV* cert, const byte* buf, word32 totalSz);
@@ -1007,7 +1007,7 @@ enum Asn1PrintOpt {
10071007
/* Don't show text representations of primitive types. */
10081008
ASN1_PRINT_OPT_SHOW_NO_TEXT,
10091009
/* Don't show dump text representations of primitive types. */
1010-
ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT,
1010+
ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT
10111011
};
10121012

10131013
/* ASN.1 print options. */
@@ -1019,17 +1019,17 @@ typedef struct Asn1PrintOptions {
10191019
/* Number of spaces to indent for each change in depth. */
10201020
word8 indent;
10211021
/* Draw branches instead of indenting. */
1022-
word8 draw_branch:1;
1022+
WC_BITFIELD draw_branch:1;
10231023
/* Show raw data of primitive types as octets. */
1024-
word8 show_data:1;
1024+
WC_BITFIELD show_data:1;
10251025
/* Show header data as octets. */
1026-
word8 show_header_data:1;
1026+
WC_BITFIELD show_header_data:1;
10271027
/* Show the wolfSSL OID value for OBJECT_ID. */
1028-
word8 show_oid:1;
1028+
WC_BITFIELD show_oid:1;
10291029
/* Don't show text representations of primitive types. */
1030-
word8 show_no_text:1;
1030+
WC_BITFIELD show_no_text:1;
10311031
/* Don't show dump text representations of primitive types. */
1032-
word8 show_no_dump_text:1;
1032+
WC_BITFIELD show_no_dump_text:1;
10331033
} Asn1PrintOptions;
10341034

10351035
/* ASN.1 item data. */

wolfssl/wolfcrypt/chacha20_poly1305.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ typedef struct ChaChaPoly_Aead {
7272
word32 dataLen;
7373

7474
byte state;
75-
byte isEncrypt:1;
75+
WC_BITFIELD isEncrypt:1;
7676
} ChaChaPoly_Aead;
7777

7878

wolfssl/wolfcrypt/curve25519.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ struct curve25519_key {
9797
#endif
9898

9999
/* bit fields */
100-
byte pubSet:1;
101-
byte privSet:1;
102-
byte isAllocated:1; /* flag indicates if structure was allocated */
100+
WC_BITFIELD pubSet:1;
101+
WC_BITFIELD privSet:1;
102+
WC_BITFIELD isAllocated:1; /* flag indicates if structure was allocated */
103103
};
104104

105105
enum {

wolfssl/wolfcrypt/curve448.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ struct curve448_key {
5858
#endif
5959

6060
/* bit fields */
61-
byte pubSet:1;
62-
byte privSet:1;
61+
WC_BITFIELD pubSet:1;
62+
WC_BITFIELD privSet:1;
6363
};
6464

6565
enum {

wolfssl/wolfcrypt/ecc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ struct ecc_point {
467467
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK)
468468
ecc_key* key;
469469
#endif
470-
byte isAllocated:1;
470+
WC_BITFIELD isAllocated:1;
471471
};
472472

473473
/* ECC Flags */
@@ -590,12 +590,12 @@ struct ecc_key {
590590
mp_int* sign_k;
591591
#else
592592
mp_int sign_k[1];
593-
byte sign_k_set:1;
593+
WC_BITFIELD sign_k_set:1;
594594
#endif
595595
#endif
596596
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \
597597
defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
598-
byte deterministic:1;
598+
WC_BITFIELD deterministic:1;
599599
enum wc_HashType hashType;
600600
#endif
601601

0 commit comments

Comments
 (0)