[libxml2] Fix unused variable warnings with disabled features
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Fix unused variable warnings with disabled features
- Date: Tue, 22 Feb 2022 21:29:05 +0000 (UTC)
commit c41bc10da31a4a4e5416270110b6d1b79606cad1
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Tue Feb 22 19:57:12 2022 +0100
Fix unused variable warnings with disabled features
SAX2.c | 65 ++++++++++++++++++++++++++++++++++++++------------------------
encoding.c | 3 +++
parser.c | 4 ++++
tree.c | 3 +++
xmlIO.c | 3 +++
xmllint.c | 3 +++
xzlib.c | 8 ++++++++
7 files changed, 64 insertions(+), 25 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 23cfac60..9a093bcd 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -180,31 +180,6 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
NULL, 0, 0, msg, str1);
}
-/**
- * xmlNsErrMsg:
- * @ctxt: an XML parser context
- * @error: the error number
- * @msg: the error message
- * @str1: an error string
- * @str2: an error string
- *
- * Handle a namespace error
- */
-static void LIBXML_ATTR_FORMAT(3,0)
-xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
- const char *msg, const xmlChar *str1, const xmlChar *str2)
-{
- if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
- (ctxt->instate == XML_PARSER_EOF))
- return;
- if (ctxt != NULL)
- ctxt->errNo = error;
- __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
- XML_ERR_ERROR, NULL, 0,
- (const char *) str1, (const char *) str2,
- NULL, 0, 0, msg, str1, str2);
-}
-
/**
* xmlNsWarnMsg:
* @ctxt: an XML parser context
@@ -709,6 +684,9 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
xmlAttributePtr attr;
xmlChar *name = NULL, *prefix = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) attr;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -776,6 +754,9 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlElementPtr elem = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) elem;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -822,6 +803,9 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNotationPtr nota = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nota;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -1051,6 +1035,31 @@ xmlSAX2EndDocument(void *ctx)
}
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) ||
defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+/**
+ * xmlNsErrMsg:
+ * @ctxt: an XML parser context
+ * @error: the error number
+ * @msg: the error message
+ * @str1: an error string
+ * @str2: an error string
+ *
+ * Handle a namespace error
+ */
+static void LIBXML_ATTR_FORMAT(3,0)
+xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
+ const char *msg, const xmlChar *str1, const xmlChar *str2)
+{
+ if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
+ (ctxt->instate == XML_PARSER_EOF))
+ return;
+ if (ctxt != NULL)
+ ctxt->errNo = error;
+ __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
+ XML_ERR_ERROR, NULL, 0,
+ (const char *) str1, (const char *) str2,
+ NULL, 0, 0, msg, str1, str2);
+}
+
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
@@ -1144,6 +1153,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nsret;
+
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
@@ -1206,6 +1218,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nsret;
+
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
diff --git a/encoding.c b/encoding.c
index d242ca7d..0847934a 100644
--- a/encoding.c
+++ b/encoding.c
@@ -2780,6 +2780,9 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
int tofree = 0;
int i, handler_in_list = 0;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) handler_in_list;
+
if (handler == NULL) return(-1);
if (handler->name == NULL) return(-1);
if (handlers != NULL) {
diff --git a/parser.c b/parser.c
index 9978cbe2..5384e556 100644
--- a/parser.c
+++ b/parser.c
@@ -1104,6 +1104,10 @@ xmlHasFeature(xmlFeature feature)
static void
xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
xmlSAXHandlerPtr sax;
+
+ /* Avoid unused variable warning if features are disabled. */
+ (void) sax;
+
if (ctxt == NULL) return;
sax = ctxt->sax;
#ifdef LIBXML_SAX1_ENABLED
diff --git a/tree.c b/tree.c
index 32d66339..cbaec5b0 100644
--- a/tree.c
+++ b/tree.c
@@ -6534,6 +6534,9 @@ xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name,
{
xmlAttrPtr prop;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) useDTD;
+
if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL))
return(NULL);
diff --git a/xmlIO.c b/xmlIO.c
index ef6319a6..c510a7e9 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -3821,6 +3821,9 @@ xmlParserGetDirectory(const char *filename) {
*/
xmlParserInputPtr
xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
+ /* Avoid unused variable warning if features are disabled. */
+ (void) ctxt;
+
#ifdef LIBXML_HTTP_ENABLED
if ((ret != NULL) && (ret->buf != NULL) &&
(ret->buf->readcallback == xmlIOHTTPRead) &&
diff --git a/xmllint.c b/xmllint.c
index ee6bfdc5..b314189f 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -3853,6 +3853,9 @@ main(int argc, char **argv) {
xmlFreePattern(patternc);
#endif
+ /* Avoid unused label warning if features are disabled. */
+ goto error;
+
error:
xmlCleanupParser();
xmlMemoryDump();
diff --git a/xzlib.c b/xzlib.c
index 9a347385..62cb2b0f 100644
--- a/xzlib.c
+++ b/xzlib.c
@@ -389,6 +389,10 @@ xz_head(xz_statep state)
int flags;
unsigned len;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) flags;
+ (void) len;
+
/* allocate read buffers and inflate memory */
if (state->size == 0) {
/* allocate buffers */
@@ -536,6 +540,10 @@ xz_decomp(xz_statep state)
lzma_action action = LZMA_RUN;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) crc;
+ (void) len;
+
/* fill output buffer up to end of deflate stream */
had = strm->avail_out;
do {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]