Skip to content

Commit d5062f6

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 13d4ea6 commit d5062f6

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
@@ -1746,15 +1746,15 @@ static int x509_info_cert_policies(char **buf, size_t *size,
17461746
/*
17471747
* Return an informational string about the certificate.
17481748
*/
1749-
#define BEFORE_COLON 18
1750-
#define BC "18"
1749+
#define MBEDTLS_BEFORE_COLON 18
1750+
#define MBEDTLS_BEFORE_COLON_STR "18"
17511751
int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
17521752
const mbedtls_x509_crt *crt)
17531753
{
17541754
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
17551755
size_t n;
17561756
char *p;
1757-
char key_size_str[BEFORE_COLON];
1757+
char key_size_str[MBEDTLS_BEFORE_COLON];
17581758

17591759
p = buf;
17601760
n = size;
@@ -1808,13 +1808,13 @@ int mbedtls_x509_crt_info(char *buf, size_t size, const char *prefix,
18081808
MBEDTLS_X509_SAFE_SNPRINTF;
18091809

18101810
/* Key size */
1811-
if ((ret = mbedtls_x509_key_size_helper(key_size_str, BEFORE_COLON,
1811+
if ((ret = mbedtls_x509_key_size_helper(key_size_str, MBEDTLS_BEFORE_COLON,
18121812
mbedtls_pk_get_name(&crt->pk))) != 0) {
18131813
return ret;
18141814
}
18151815

1816-
ret = mbedtls_snprintf(p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str,
1817-
(int) mbedtls_pk_get_bitlen(&crt->pk));
1816+
ret = mbedtls_snprintf(p, n, "\n%s%-" MBEDTLS_BEFORE_COLON_STR "s: %d bits",
1817+
prefix, key_size_str, (int) mbedtls_pk_get_bitlen(&crt->pk));
18181818
MBEDTLS_X509_SAFE_SNPRINTF;
18191819

18201820
/*

library/x509_csr.c

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

522522
#if !defined(MBEDTLS_X509_REMOVE_INFO)
523-
#define BEFORE_COLON 14
524-
#define BC "14"
523+
#define MBEDTLS_BEFORE_COLON 14
524+
#define MBEDTLS_BEFORE_COLON_STR "14"
525525
/*
526526
* Return an informational string about the CSR.
527527
*/
@@ -531,7 +531,7 @@ int mbedtls_x509_csr_info(char *buf, size_t size, const char *prefix,
531531
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
532532
size_t n;
533533
char *p;
534-
char key_size_str[BEFORE_COLON];
534+
char key_size_str[MBEDTLS_BEFORE_COLON];
535535

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

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

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

564564
/*

0 commit comments

Comments
 (0)