/pidgin/main: cdc53b913dd4: Clang warnings: gg prpl and perl's S...

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Oct 4 05:51:15 EDT 2013


Changeset: cdc53b913dd41dee249059a7fa9ec02ec39b8d59
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2013-10-04 11:51 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/cdc53b913dd4

Description:

Clang warnings: gg prpl and perl's SvUPGRADE

diffstat:

 configure.ac                            |  24 ++++++++++++++++++++++++
 libpurple/plugins/perl/common/Cipher.xs |  10 +++++-----
 libpurple/plugins/perl/perl-common.h    |   6 ++++++
 libpurple/protocols/gg/Makefile.am      |   2 +-
 4 files changed, 36 insertions(+), 6 deletions(-)

diffs (109 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1986,6 +1986,30 @@ Use --disable-perl if you do not need Pe
 ])
 fi
 
+if test "$enable_perl" = yes ; then
+	AC_CACHE_CHECK(for new SvUPGRADE in perl API, ac_cv_perl_have_new_svupgrade, [
+		orig_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS $PERL_CFLAGS"
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+			#include <EXTERN.h>
+			#include <perl.h>
+		]], [[
+			PerlInterpreter *my_perl;
+			SV *sv;
+			if (!SvUPGRADE(sv, SVt_PV)) {
+				/* SvUPGRADE is an expression, so it doesn't
+				 * terminate in case of failure */
+			}
+		]])],
+			[ac_cv_perl_have_new_svupgrade=no],
+			[ac_cv_perl_have_new_svupgrade=yes])
+		CFLAGS="$orig_CFLAGS"
+		])
+	if test $ac_cv_perl_have_new_svupgrade = yes; then
+		AC_DEFINE(HAVE_NEW_SVUPGRADE, 1, [Define if you have SvUPGRADE terminating in case of failure.])
+	fi
+fi
+
 dnl #######################################################################
 dnl # SSL support
 dnl #
diff --git a/libpurple/plugins/perl/common/Cipher.xs b/libpurple/plugins/perl/common/Cipher.xs
--- a/libpurple/plugins/perl/common/Cipher.xs
+++ b/libpurple/plugins/perl/common/Cipher.xs
@@ -67,7 +67,7 @@ purple_cipher_digest_region(name, data_s
 		size_t max_digest_len = 100;
 	CODE:
 		data = (guchar *)SvPV(data_sv, data_len);
-		SvUPGRADE(digest, SVt_PV);
+		SvUPGRADE_common(digest, SVt_PV);
 		buff = (guchar *)SvGROW(digest, max_digest_len);
 		digest_len = purple_cipher_digest_region(name, data, data_len, buff, max_digest_len);
 		if(digest_len == -1) {
@@ -182,7 +182,7 @@ purple_cipher_context_digest(context, di
 		size_t digest_size;
 	CODE:
 		digest_size = purple_cipher_context_get_digest_size(context);
-		SvUPGRADE(digest, SVt_PV);
+		SvUPGRADE_common(digest, SVt_PV);
 		buff = (guchar *)SvGROW(digest, digest_size);
 		if (purple_cipher_context_digest(context, buff, digest_size)) {
 			SvCUR_set(digest, digest_size);
@@ -205,7 +205,7 @@ purple_cipher_context_digest_to_str(cont
 	CODE:
 		digest_size = purple_cipher_context_get_digest_size(context);
 		str_len = 2 * digest_size;
-		SvUPGRADE(digest_s, SVt_PV);
+		SvUPGRADE_common(digest_s, SVt_PV);
 		buff = SvGROW(digest_s, str_len + 1);
 		if (purple_cipher_context_digest_to_str(context, buff, str_len + 1)) {
 			SvCUR_set(digest_s, str_len);
@@ -231,7 +231,7 @@ purple_cipher_context_encrypt(context, i
 	CODE:
 		data = (guchar *)SvPV(input, input_len);
 		output_len = input_len + purple_cipher_context_get_block_size(context);
-		SvUPGRADE(output, SVt_PV);
+		SvUPGRADE_common(output, SVt_PV);
 		buff = (guchar *)SvGROW(output, output_len);
 		ret = purple_cipher_context_encrypt(context, data, input_len, buff, output_len);
 		if (ret >= 0) {
@@ -258,7 +258,7 @@ purple_cipher_context_decrypt(context, i
 	CODE:
 		data = (guchar *)SvPV(input, input_len);
 		output_len = input_len + purple_cipher_context_get_block_size(context);
-		SvUPGRADE(output, SVt_PV);
+		SvUPGRADE_common(output, SVt_PV);
 		buff = (guchar *)SvGROW(output, output_len);
 		ret = purple_cipher_context_decrypt(context, data, input_len, buff, output_len);
 		if (ret >= 0) {
diff --git a/libpurple/plugins/perl/perl-common.h b/libpurple/plugins/perl/perl-common.h
--- a/libpurple/plugins/perl/perl-common.h
+++ b/libpurple/plugins/perl/perl-common.h
@@ -35,6 +35,12 @@
 #define PURPLE_PERL_BOOT(x) \
 	purple_perl_callXS(boot_Purple__##x, cv, mark)
 
+#ifdef HAVE_NEW_SVUPGRADE
+#	define SvUPGRADE_common(a, b) SvUPGRADE(a, b)
+#else
+#	define SvUPGRADE_common(a, b) if (!SvUPGRADE(a, b)) { croak("Cannot upgrade variable"); }
+#endif
+
 typedef struct _PurplePerlInfoStrings PurplePerlInfoStrings;
 
 typedef struct
diff --git a/libpurple/protocols/gg/Makefile.am b/libpurple/protocols/gg/Makefile.am
--- a/libpurple/protocols/gg/Makefile.am
+++ b/libpurple/protocols/gg/Makefile.am
@@ -1,6 +1,6 @@
 #V=0
 #CFLAGS = -g -O0
-GADU_EXTRA = -Wall -Wextra -fno-inline
+GADU_EXTRA =
 #GADU_EXTRA += -Werror
 
 pkgdir = $(libdir)/purple-$(PURPLE_MAJOR_VERSION)



More information about the Commits mailing list