Skip to content

Commit b5c079b

Browse files
committed
fix: rename BEFORE_COLON and BC to avoid conflicts
Namespace BEFORE_COLON and BC defines by prepending MBEDTLS_ and expanding BC to BEFORE_COLON_STR. This is to avoid naming conflicts with third-party code. No functional change. Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
1 parent 6a9cf11 commit b5c079b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

library/x509_crt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,15 +1743,15 @@ static int x509_info_cert_policies(char **buf, size_t *size,
17431743
/*
17441744
* Return an informational string about the certificate.
17451745
*/
1746-
#define BEFORE_COLON 18
1747-
#define BC "18"
1746+
#define MBEDTLS_BEFORE_COLON 18
1747+
#define MBEDTLS_BEFORE_COLON_STR "18"
17481748
int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
17491749
const mbedtls_x509_crt *crt)
17501750
{
17511751
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
17521752
size_t n;
17531753
char *p;
1754-
char key_size_str[BEFORE_COLON];
1754+
char key_size_str[MBEDTLS_BEFORE_COLON];
17551755

17561756
p = buf;
17571757
n = size;
@@ -1805,13 +1805,13 @@ int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
18051805
MBEDTLS_X509_SAFE_SNPRINTF;
18061806

18071807
/* Key size */
1808-
if ((ret = mbedtls_x509_key_size_helper(key_size_str, BEFORE_COLON,
1808+
if ((ret = mbedtls_x509_key_size_helper(key_size_str, MBEDTLS_BEFORE_COLON,
18091809
mbedtls_pk_get_name(&crt->pk))) != 0) {
18101810
return ret;
18111811
}
18121812

1813-
ret = mbedtls_snprintf(p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str,
1814-
(int) mbedtls_pk_get_bitlen(&crt->pk));
1813+
ret = mbedtls_snprintf(p, n, "\n%s%-" MBEDTLS_BEFORE_COLON_STR "s: %d bits",
1814+
prefix, key_size_str, (int) mbedtls_pk_get_bitlen(&crt->pk));
18151815
MBEDTLS_X509_SAFE_SNPRINTF;
18161816

18171817
/*

library/x509_csr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ int mbedtls_x509_csr_parse_file(mbedtls_x509_csr *csr, const char *path)
519519
#endif /* MBEDTLS_FS_IO */
520520

521521
#if !defined(MBEDTLS_X509_REMOVE_INFO)
522-
#define BEFORE_COLON 14
523-
#define BC "14"
522+
#define MBEDTLS_BEFORE_COLON 14
523+
#define MBEDTLS_BEFORE_COLON_STR "14"
524524
/*
525525
* Return an informational string about the CSR.
526526
*/
@@ -530,7 +530,7 @@ int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
530530
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
531531
size_t n;
532532
char *p;
533-
char key_size_str[BEFORE_COLON];
533+
char key_size_str[MBEDTLS_BEFORE_COLON];
534534

535535
p = buf;
536536
n = size;
@@ -551,13 +551,13 @@ int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
551551
csr->sig_opts);
552552
MBEDTLS_X509_SAFE_SNPRINTF;
553553

554-
if ((ret = mbedtls_x509_key_size_helper(key_size_str, BEFORE_COLON,
554+
if ((ret = mbedtls_x509_key_size_helper(key_size_str, MBEDTLS_BEFORE_COLON,
555555
mbedtls_pk_get_name(&csr->pk))) != 0) {
556556
return ret;
557557
}
558558

559-
ret = mbedtls_snprintf(p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str,
560-
(int) mbedtls_pk_get_bitlen(&csr->pk));
559+
ret = mbedtls_snprintf(p, n, "\n%s%-" MBEDTLS_BEFORE_COLON_STR "s: %d bits\n",
560+
prefix, key_size_str, (int) mbedtls_pk_get_bitlen(&csr->pk));
561561
MBEDTLS_X509_SAFE_SNPRINTF;
562562

563563
/*

0 commit comments

Comments
 (0)