diff --git a/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp b/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
index 9cd0ad14016714f5368c986ae34d0497de26c3d9..fce0e3027655e34e12ad2d015bde97d42b5dfa0c 100644
--- a/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
+++ b/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp
@@ -133,8 +133,10 @@
             }
         }
         else if (item.isNode()) {
+#ifdef qdoc
             QXmlNodeModelIndex i = item.toNodeModelIndex();
             // process node
+#endif // qdoc
         }
         item = result.next();
     }
@@ -163,8 +165,10 @@
                     break;
                 default:
                     if (v.userType() == qMetaTypeId<QXmlName>()) {
+#ifdef qdoc
                         QXmlName n = qvariant_cast<QXmlName>(v);
                         // process QXmlName n...
+#endif // qdoc
                     }
                     else {
                         // error
@@ -173,8 +177,10 @@
             }
         }
         else if (item.isNode()) {
+#ifdef qdoc
             QXmlNodeModelIndex i = item.toNodeModelIndex();
             // process node
+#endif // qdoc
         }
         item = result.next();
     }
diff --git a/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp b/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
index 64b639865b00a46b7fc908b7b0e73c401d04af24..baca131ddb36e9af2542874f4baeed3500694c8c 100644
--- a/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
+++ b/doc/src/snippets/code/src_xmlpatterns_api_qxmlresultitems.cpp
@@ -50,7 +50,8 @@ if (query.isValid()) {
         // use item
         item = result.next();
     }
-    if (result.hasError())
-        /* Runtime error! */;
+    if (result.hasError()) {
+        /* Runtime error! */
+    }
 }
 //! [0]
diff --git a/src/xmlpatterns/functions/qstringvaluefns.cpp b/src/xmlpatterns/functions/qstringvaluefns.cpp
index 06567215f50e0071ca4178ae44b3f9b104ccfa5a..2343737b53c95d0c7ccc29fccbadb9dd2e0569d0 100644
--- a/src/xmlpatterns/functions/qstringvaluefns.cpp
+++ b/src/xmlpatterns/functions/qstringvaluefns.cpp
@@ -345,8 +345,8 @@ Item EncodeString::evaluateSingleton(const DynamicContext::Ptr &context) const
     if(!item)
         return CommonValues::EmptyString;
 
-    return AtomicString::fromValue(item.stringValue().toUtf8().toPercentEncoding(m_excludeChars,
-                                                                        m_includeChars).constData());
+    const QByteArray value = item.stringValue().toUtf8().toPercentEncoding(m_excludeChars, m_includeChars);
+    return AtomicString::fromValue(QLatin1String(value));
 }
 
 const char *const EncodeForURIFN::include = "#!*'()";
diff --git a/tests/auto/xmlpatternssdk/TestBaseLine.cpp b/tests/auto/xmlpatternssdk/TestBaseLine.cpp
index f8b62d30efc1edf61d3304fcb2e37c15df721d1d..5168565527fe7bfc8eef153ffaf85b747fbfc9eb 100644
--- a/tests/auto/xmlpatternssdk/TestBaseLine.cpp
+++ b/tests/auto/xmlpatternssdk/TestBaseLine.cpp
@@ -179,12 +179,11 @@ void TestBaseLine::toXML(XMLWriter &receiver) const
 
 bool TestBaseLine::isChildrenDeepEqual(const QDomNodeList &cl1, const QDomNodeList &cl2)
 {
-    const unsigned int len = cl1.length();
+    const int len = cl1.length();
 
     if(len == cl2.length())
     {
-        for(unsigned int i = 0; i < len; ++i)
-        {
+        for (int i = 0; i < len; ++i) {
             if(!isDeepEqual(cl1.at(i), cl2.at(i)))
                 return false;
         }
@@ -197,21 +196,19 @@ bool TestBaseLine::isChildrenDeepEqual(const QDomNodeList &cl1, const QDomNodeLi
 
 bool TestBaseLine::isAttributesEqual(const QDomNamedNodeMap &cl1, const QDomNamedNodeMap &cl2)
 {
-    const unsigned int len = cl1.length();
+    const int len = cl1.length();
     pDebug() << "LEN:" << len;
 
     if(len == cl2.length())
     {
-        for(unsigned int i1 = 0; i1 < len; ++i1)
-        {
+        for (int i1 = 0; i1 < len; ++i1) {
             const QDomNode attr1(cl1.item(i1));
             Q_ASSERT(!attr1.isNull());
 
             /* This is set if attr1 cannot be found at all in cl2. */
             bool earlyExit = false;
 
-            for(unsigned int i2 = 0; i2 < len; ++i2)
-            {
+            for (int i2 = 0; i2 < len; ++i2) {
                 const QDomNode attr2(cl2.item(i2));
                 Q_ASSERT(!attr2.isNull());
                 pDebug() << "ATTR1:" << attr1.localName() << attr1.namespaceURI() << attr1.prefix() << attr1.nodeName();
diff --git a/tests/auto/xmlpatternssdk/XMLWriter.cpp b/tests/auto/xmlpatternssdk/XMLWriter.cpp
index 40f4a4e87fe4bd2f5d41764d5def5ca80afa732d..a81a986420fd240da717d887c50f797387b3b8b1 100644
--- a/tests/auto/xmlpatternssdk/XMLWriter.cpp
+++ b/tests/auto/xmlpatternssdk/XMLWriter.cpp
@@ -571,8 +571,9 @@ bool XMLWriter::startDTD(const QString &name,
 
     if(!systemId.isEmpty())
     {
-        if(publicId.isEmpty())
+        if (publicId.isEmpty()) {
             serialize(" SYSTEM");
+        }
 
         serialize(" \"");
         serialize(systemId);