Bug 1019381 - Cherrypick clang and gcc warning fixes from upstream jemalloc. r=glandium
authorChris Peterson <cpeterson@mozilla.com>
Wed, 28 May 2014 19:02:11 -0700
changeset 199512 257269554ad9c047f5b8f2d26420c137d7d5b3bd
parent 199511 d089350aff818ac688847038226fb4ec6071dca0
child 199513 d89d4281fd8d5d51634491a7f100695c89071112
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs1019381
milestone32.0a1
Bug 1019381 - Cherrypick clang and gcc warning fixes from upstream jemalloc. r=glandium
memory/jemalloc/0006-Fix-clang-warnings.patch
memory/jemalloc/src/src/prof.c
memory/jemalloc/src/src/util.c
memory/jemalloc/update.sh
new file mode 100644
--- /dev/null
+++ b/memory/jemalloc/0006-Fix-clang-warnings.patch
@@ -0,0 +1,93 @@
+diff --git a/src/prof.c b/src/prof.c
+--- a/src/prof.c
++++ b/src/prof.c
+@@ -1057,25 +1057,25 @@ label_open_close_error:
+ 		prof_dump_ctx_cleanup(ctx.p, &ctx_ql);
+ 	malloc_mutex_unlock(&prof_dump_mtx);
+ 	return (true);
+ }
+ 
+ #define	DUMP_FILENAME_BUFSIZE	(PATH_MAX + 1)
+ #define	VSEQ_INVALID		UINT64_C(0xffffffffffffffff)
+ static void
+-prof_dump_filename(char *filename, char v, int64_t vseq)
++prof_dump_filename(char *filename, char v, uint64_t vseq)
+ {
+ 
+ 	cassert(config_prof);
+ 
+ 	if (vseq != VSEQ_INVALID) {
+ 	        /* "<prefix>.<pid>.<seq>.v<vseq>.heap" */
+ 		malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
+-		    "%s.%d.%"PRIu64".%c%"PRId64".heap",
++		    "%s.%d.%"PRIu64".%c%"PRIu64".heap",
+ 		    opt_prof_prefix, (int)getpid(), prof_dump_seq, v, vseq);
+ 	} else {
+ 	        /* "<prefix>.<pid>.<seq>.<v>.heap" */
+ 		malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
+ 		    "%s.%d.%"PRIu64".%c.heap",
+ 		    opt_prof_prefix, (int)getpid(), prof_dump_seq, v);
+ 	}
+ 	prof_dump_seq++;
+diff --git a/src/util.c b/src/util.c
+--- a/src/util.c
++++ b/src/util.c
+@@ -95,17 +95,17 @@ buferror(int err, char *buf, size_t bufl
+ 	return (strerror_r(err, buf, buflen));
+ #endif
+ }
+ 
+ uintmax_t
+ malloc_strtoumax(const char *restrict nptr, char **restrict endptr, int base)
+ {
+ 	uintmax_t ret, digit;
+-	int b;
++	unsigned b;
+ 	bool neg;
+ 	const char *p, *ns;
+ 
+ 	p = nptr;
+ 	if (base < 0 || base == 1 || base > 36) {
+ 		ns = p;
+ 		set_errno(EINVAL);
+ 		ret = UINTMAX_MAX;
+@@ -376,17 +376,19 @@ malloc_vsnprintf(char *str, size_t size,
+ 		val = va_arg(ap, ssize_t);				\
+ 		break;							\
+ 	case 'z' | 0x80:						\
+ 		val = va_arg(ap, size_t);				\
+ 		break;							\
+ 	case 'p': /* Synthetic; used for %p. */				\
+ 		val = va_arg(ap, uintptr_t);				\
+ 		break;							\
+-	default: not_reached();						\
++	default: 							\
++		not_reached();						\
++		val = 0;						\
+ 	}								\
+ } while (0)
+ 
+ 	i = 0;
+ 	f = format;
+ 	while (true) {
+ 		switch (*f) {
+ 		case '\0': goto label_out;
+@@ -543,17 +545,17 @@ malloc_vsnprintf(char *str, size_t size,
+ 				buf[1] = '\0';
+ 				APPEND_PADDED_S(buf, 1, width, left_justify);
+ 				f++;
+ 				break;
+ 			} case 's':
+ 				assert(len == '?' || len == 'l');
+ 				assert_not_implemented(len != 'l');
+ 				s = va_arg(ap, char *);
+-				slen = (prec < 0) ? strlen(s) : prec;
++				slen = (prec < 0) ? strlen(s) : (size_t)prec;
+ 				APPEND_PADDED_S(s, slen, width, left_justify);
+ 				f++;
+ 				break;
+ 			case 'p': {
+ 				uintmax_t val;
+ 				char buf[X2S_BUFSIZE];
+ 
+ 				GET_ARG_NUMERIC(val, 'p');
--- a/memory/jemalloc/src/src/prof.c
+++ b/memory/jemalloc/src/src/prof.c
@@ -1057,25 +1057,25 @@ label_open_close_error:
 		prof_dump_ctx_cleanup(ctx.p, &ctx_ql);
 	malloc_mutex_unlock(&prof_dump_mtx);
 	return (true);
 }
 
 #define	DUMP_FILENAME_BUFSIZE	(PATH_MAX + 1)
 #define	VSEQ_INVALID		UINT64_C(0xffffffffffffffff)
 static void
-prof_dump_filename(char *filename, char v, int64_t vseq)
+prof_dump_filename(char *filename, char v, uint64_t vseq)
 {
 
 	cassert(config_prof);
 
 	if (vseq != VSEQ_INVALID) {
 	        /* "<prefix>.<pid>.<seq>.v<vseq>.heap" */
 		malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
-		    "%s.%d.%"PRIu64".%c%"PRId64".heap",
+		    "%s.%d.%"PRIu64".%c%"PRIu64".heap",
 		    opt_prof_prefix, (int)getpid(), prof_dump_seq, v, vseq);
 	} else {
 	        /* "<prefix>.<pid>.<seq>.<v>.heap" */
 		malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
 		    "%s.%d.%"PRIu64".%c.heap",
 		    opt_prof_prefix, (int)getpid(), prof_dump_seq, v);
 	}
 	prof_dump_seq++;
--- a/memory/jemalloc/src/src/util.c
+++ b/memory/jemalloc/src/src/util.c
@@ -95,17 +95,17 @@ buferror(int err, char *buf, size_t bufl
 	return (strerror_r(err, buf, buflen));
 #endif
 }
 
 uintmax_t
 malloc_strtoumax(const char *restrict nptr, char **restrict endptr, int base)
 {
 	uintmax_t ret, digit;
-	int b;
+	unsigned b;
 	bool neg;
 	const char *p, *ns;
 
 	p = nptr;
 	if (base < 0 || base == 1 || base > 36) {
 		ns = p;
 		set_errno(EINVAL);
 		ret = UINTMAX_MAX;
@@ -376,17 +376,19 @@ malloc_vsnprintf(char *str, size_t size,
 		val = va_arg(ap, ssize_t);				\
 		break;							\
 	case 'z' | 0x80:						\
 		val = va_arg(ap, size_t);				\
 		break;							\
 	case 'p': /* Synthetic; used for %p. */				\
 		val = va_arg(ap, uintptr_t);				\
 		break;							\
-	default: not_reached();						\
+	default: 							\
+		not_reached();						\
+		val = 0;						\
 	}								\
 } while (0)
 
 	i = 0;
 	f = format;
 	while (true) {
 		switch (*f) {
 		case '\0': goto label_out;
@@ -543,17 +545,17 @@ malloc_vsnprintf(char *str, size_t size,
 				buf[1] = '\0';
 				APPEND_PADDED_S(buf, 1, width, left_justify);
 				f++;
 				break;
 			} case 's':
 				assert(len == '?' || len == 'l');
 				assert_not_implemented(len != 'l');
 				s = va_arg(ap, char *);
-				slen = (prec < 0) ? strlen(s) : prec;
+				slen = (prec < 0) ? strlen(s) : (size_t)prec;
 				APPEND_PADDED_S(s, slen, width, left_justify);
 				f++;
 				break;
 			case 'p': {
 				uintmax_t val;
 				char buf[X2S_BUFSIZE];
 
 				GET_ARG_NUMERIC(val, 'p');
old mode 100755
new mode 100644
--- a/memory/jemalloc/update.sh
+++ b/memory/jemalloc/update.sh
@@ -14,13 +14,14 @@ autoconf
 git describe --long --abbrev=40 > VERSION
 rm -rf .git .gitignore autom4te.cache
 
 patch -p1 < ../0001-Use-a-configure-test-to-detect-whether-to-use-a-cons.patch
 patch -p1 < ../0002-Use-ULL-prefix-instead-of-LLU-for-unsigned-long-long.patch
 patch -p1 < ../0003-Don-t-use-msvc_compat-s-C99-headers-with-MSVC-versio.patch
 patch -p1 < ../0004-Try-to-use-__builtin_ffsl-if-ffsl-is-unavailable.patch
 patch -p1 < ../0005-Check-for-__builtin_ffsl-before-ffsl.patch
+patch -p1 < ../0006-Fix-clang-warnings.patch
 
 cd ..
 hg addremove -q src
 
 echo "jemalloc has now been updated.  Don't forget to run hg commit!"