/pidgin/main: 2897add11757: Silence some coverity false positives

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon May 12 15:13:52 EDT 2014


Changeset: 2897add117575c515365af62936267cf02dc944d
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-12 21:13 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/2897add11757

Description:

Silence some coverity false positives

diffstat:

 libpurple/internal.h                   |   8 ++++++++
 libpurple/plugins/perl/common/module.h |  11 +++++++++++
 libpurple/protocols/jabber/jabber.c    |   2 +-
 libpurple/protocols/jabber/si.c        |   5 ++++-
 libpurple/xmlnode.c                    |   4 +---
 5 files changed, 25 insertions(+), 5 deletions(-)

diffs (91 lines):

diff --git a/libpurple/internal.h b/libpurple/internal.h
--- a/libpurple/internal.h
+++ b/libpurple/internal.h
@@ -174,6 +174,14 @@
 
 #endif /* __clang__ */
 
+#ifdef __COVERITY__
+
+/* avoid TAINTED_SCALAR warning */
+#undef g_utf8_next_char
+#define g_utf8_next_char(p) (char *)((p) + 1)
+
+#endif
+
 /* Safer ways to work with static buffers. When using non-static
  * buffers, either use g_strdup_* functions (preferred) or use
  * g_strlcpy/g_strlcpy directly. */
diff --git a/libpurple/plugins/perl/common/module.h b/libpurple/plugins/perl/common/module.h
--- a/libpurple/plugins/perl/common/module.h
+++ b/libpurple/plugins/perl/common/module.h
@@ -71,6 +71,17 @@ typedef struct group *Purple__Group;
 #include "whiteboard.h"
 #include "xmlnode.h"
 
+#ifdef __COVERITY__
+
+/* avoid extra_comma false positives */
+#undef SvPOK_only
+#define SvPOK_only(sv) { \
+	SvFLAGS(sv) &= ~(SVf_OK | SVf_IVisUV | SVf_UTF8); \
+	SvFLAGS(sv) |= (SVf_POK | SVp_POK); \
+	}
+
+#endif /* __COVERITY__ */
+
 /* account.h */
 typedef PurpleAccount *			Purple__Account;
 typedef PurpleAccountOption *		Purple__Account__Option;
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -474,7 +474,7 @@ void jabber_send_raw(JabberStream *js, c
 	g_return_if_fail(data != NULL);
 
 	/* because printing a tab to debug every minute gets old */
-	if(strcmp(data, "\t")) {
+	if (data && strcmp(data, "\t") != 0) {
 		const char *username;
 		char *text = NULL, *last_part = NULL, *tag_start = NULL;
 
diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c
--- a/libpurple/protocols/jabber/si.c
+++ b/libpurple/protocols/jabber/si.c
@@ -1715,11 +1715,13 @@ void jabber_si_parse(JabberStream *js, c
 
 	if((filesize_c = xmlnode_get_attrib(file, "size")))
 		filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10);
+
+#ifndef __COVERITY__
 	/* TODO 3.0.0: When the core uses a guint64, this is redundant.
 	 * See #8477.
 	 *
 	 * It may not be necessary on 64-bit machine.
-	 * coverity[result_independent_of_operands]
+	 * It raises result_independent_of_operands coverity false positive.
 	 */
 	if (filesize_64 > G_MAXSIZE) {
 		/* Should this pop up a warning? */
@@ -1727,6 +1729,7 @@ void jabber_si_parse(JabberStream *js, c
 		                     " -- see #8477 for more details.");
 		return;
 	}
+#endif
 	filesize = filesize_64;
 
 	if(!(feature = xmlnode_get_child(si, "feature")))
diff --git a/libpurple/xmlnode.c b/libpurple/xmlnode.c
--- a/libpurple/xmlnode.c
+++ b/libpurple/xmlnode.c
@@ -842,9 +842,7 @@ xmlnode_copy(const xmlnode *src)
 			sibling->next = xmlnode_copy(child);
 			sibling = sibling->next;
 		} else {
-			ret->child = xmlnode_copy(child);
-			/* coverity[copy_paste_error] */
-			sibling = ret->child;
+			ret->child = sibling = xmlnode_copy(child);
 		}
 		sibling->parent = ret;
 	}



More information about the Commits mailing list