Skip to contentSkip to conversation

nss: Avoid converting enum to void*

PATCH New Khem Raj 1 participant 1 message Aug 27, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 nss: Avoid converting enum to void*

Found with clang-11

---
 ...ix-Do-not-use-NULL-where-0-is-needed.patch | 46 +++++++++++++++++++
 meta-oe/recipes-support/nss/nss_3.54.bb       |  1 +
 2 files changed, 47 insertions(+)
 create mode 100644 meta-oe/recipes-support/nss/nss/0001-pkix-Do-not-use-NULL-where-0-is-needed.patch
meta-oe/recipes-support/nss/nss/0001-pkix-Do-not-use-NULL-where-0-is-needed.patch new file +46 -0
new file mode 100644
index 0000000000..432312da25
@@ -0,0 +1,46 @@
+From 1136cad77c2dc7d8e1daa317877676733e805f29 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Wed, 26 Aug 2020 17:30:40 -0700
+Subject: [PATCH] pkix: Do not use NULL where 0 is needed
+
+Clang finds this error
+
+pkix_logger.c:316:32: error: cast to smaller integer type 'PKIX_ERRORCLASS' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
+        logger->logComponent = (PKIX_ERRORCLASS)NULL;
+                               ^~~~~~~~~~~~~~~~~~~~~
+pkix_logger.c:617:32: error: cast to smaller integer type 'PKIX_ERRORCLASS' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
+        logger->logComponent = (PKIX_ERRORCLASS)NULL;
+                               ^~~~~~~~~~~~~~~~~~~~~
+2 errors generated.
+
+Upstream-Status: Submitted [https://bugzilla.mozilla.org/show_bug.cgi?id=1661378]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ nss/lib/libpkix/pkix/util/pkix_logger.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/nss/lib/libpkix/pkix/util/pkix_logger.c b/nss/lib/libpkix/pkix/util/pkix_logger.c
+index a916e6e..10f537a 100644
+--- a/nss/lib/libpkix/pkix/util/pkix_logger.c
++++ b/nss/lib/libpkix/pkix/util/pkix_logger.c
+@@ -313,7 +313,7 @@ pkix_Logger_Destroy(
+ 
+         logger->callback = NULL;
+         PKIX_DECREF(logger->context);
+-        logger->logComponent = (PKIX_ERRORCLASS)NULL;
++        logger->logComponent = (PKIX_ERRORCLASS)0;
+ 
+ cleanup:
+ 
+@@ -614,7 +614,7 @@ PKIX_Logger_Create(
+ 
+         logger->callback = callback;
+         logger->maxLevel = 0;
+-        logger->logComponent = (PKIX_ERRORCLASS)NULL;
++        logger->logComponent = (PKIX_ERRORCLASS)0;
+ 
+         PKIX_INCREF(loggerContext);
+         logger->context = loggerContext;
+-- 
+2.28.0
+
meta-oe/recipes-support/nss/nss_3.54.bb +1 -0
index dc5cafbf1c..882145c1ef 100644
@@ -32,6 +32,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSIO
            file://system-pkcs11.txt \
            file://nss-fix-nsinstall-build.patch \
            file://0001-freebl-add-a-configure-option-to-disable-ARM-HW-cryp.patch \
+           file://0001-pkix-Do-not-use-NULL-where-0-is-needed.patch \
            "
 
 SRC_URI[sha256sum] = "dab18bbfcf5e347934cda664df75ce9fd912a5772686c40d3c805e53c08d6e43"
Signature · 1 line
2.28.0