Bug 1307958 - -Werror=sign-compare in ./js subdirectory draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:00:03 +0900
changeset 81068 d049d4d11ddc23b590f2d55fada3e70a3afa87d7
parent 81067 612a9d760177fb896e2c29c5dda0c00995a75087
child 81069 c0526a9cca00673125f3ba7bea4966aa3b423232
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [default view] [failures only]
bugs1307958
Bug 1307958 - -Werror=sign-compare in ./js subdirectory
mozilla-M-C-006-js-libffi-sign-compare.patch
new file mode 100644
--- /dev/null
+++ b/mozilla-M-C-006-js-libffi-sign-compare.patch
@@ -0,0 +1,129 @@
+# HG changeset patch
+# User ISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
+# Parent  13d34baa6d3798979a22e5594ecf96e5eae46ac5
+Bug 1307958 - -Werror=sign-compare in ./js subdirectory
+
+diff --git a/js/src/ctypes/libffi/src/x86/ffi64.c b/js/src/ctypes/libffi/src/x86/ffi64.c
+--- a/js/src/ctypes/libffi/src/x86/ffi64.c
++++ b/js/src/ctypes/libffi/src/x86/ffi64.c
+@@ -216,17 +216,17 @@ classify_argument (ffi_type *type, enum 
+ 	ffi_type **ptr;
+ 	int i;
+ 	enum x86_64_reg_class subclasses[MAX_CLASSES];
+ 
+ 	/* If the struct is larger than 32 bytes, pass it on the stack.  */
+ 	if (type->size > 32)
+ 	  return 0;
+ 
+-	for (i = 0; i < words; i++)
++	for (i = 0; (size_t) i < words; i++)
+ 	  classes[i] = X86_64_NO_CLASS;
+ 
+ 	/* Zero sized arrays or structures are NO_CLASS.  We return 0 to
+ 	   signalize memory class, so handle it as special case.  */
+ 	if (!words)
+ 	  {
+ 	    classes[0] = X86_64_NO_CLASS;
+ 	    return 1;
+@@ -237,17 +237,17 @@ classify_argument (ffi_type *type, enum 
+ 	  {
+ 	    size_t num;
+ 
+ 	    byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
+ 
+ 	    num = classify_argument (*ptr, subclasses, byte_offset % 8);
+ 	    if (num == 0)
+ 	      return 0;
+-	    for (i = 0; i < num; i++)
++	    for (i = 0; (size_t) i < num; i++)
+ 	      {
+ 		size_t pos = byte_offset / 8;
+ 		classes[i + pos] =
+ 		  merge_classes (subclasses[i], classes[i + pos]);
+ 	      }
+ 
+ 	    byte_offset += (*ptr)->size;
+ 	  }
+@@ -256,23 +256,23 @@ classify_argument (ffi_type *type, enum 
+ 	  {
+ 	    /* When size > 16 bytes, if the first one isn't
+ 	       X86_64_SSE_CLASS or any other ones aren't
+ 	       X86_64_SSEUP_CLASS, everything should be passed in
+ 	       memory.  */
+ 	    if (classes[0] != X86_64_SSE_CLASS)
+ 	      return 0;
+ 
+-	    for (i = 1; i < words; i++)
++	    for (i = 1; (size_t) i < words; i++)
+ 	      if (classes[i] != X86_64_SSEUP_CLASS)
+ 		return 0;
+ 	  }
+ 
+ 	/* Final merger cleanup.  */
+-	for (i = 0; i < words; i++)
++	for (i = 0; (size_t) i < words; i++)
+ 	  {
+ 	    /* If one class is MEMORY, everything should be passed in
+ 	       memory.  */
+ 	    if (classes[i] == X86_64_MEMORY_CLASS)
+ 	      return 0;
+ 
+ 	    /* The X86_64_SSEUP_CLASS should be always preceded by
+ 	       X86_64_SSE_CLASS or X86_64_SSEUP_CLASS.  */
+@@ -315,17 +315,17 @@ examine_argument (ffi_type *type, enum x
+   size_t n;
+   int i, ngpr, nsse;
+ 
+   n = classify_argument (type, classes, 0);
+   if (n == 0)
+     return 0;
+ 
+   ngpr = nsse = 0;
+-  for (i = 0; i < n; ++i)
++  for (i = 0; (size_t) i < n; ++i)
+     switch (classes[i])
+       {
+       case X86_64_INTEGER_CLASS:
+       case X86_64_INTEGERSI_CLASS:
+ 	ngpr++;
+ 	break;
+       case X86_64_SSE_CLASS:
+       case X86_64_SSESF_CLASS:
+@@ -486,17 +486,17 @@ ffi_call (ffi_cif *cif, void (*fn)(void)
+ 	  argp += size;
+ 	}
+       else
+ 	{
+ 	  /* The argument is passed entirely in registers.  */
+ 	  char *a = (char *) avalue[i];
+ 	  int j;
+ 
+-	  for (j = 0; j < n; j++, a += 8, size -= 8)
++	  for (j = 0; (size_t) j < n; j++, a += 8, size -= 8)
+ 	    {
+ 	      switch (classes[j])
+ 		{
+ 		case X86_64_INTEGER_CLASS:
+ 		case X86_64_INTEGERSI_CLASS:
+ 		  /* Sign-extend integer arguments passed in general
+ 		     purpose registers, to cope with the fact that
+ 		     LLVM incorrectly assumes that this will be done
+@@ -661,17 +661,17 @@ ffi_closure_unix64_inner(ffi_closure *cl
+ 	}
+       /* Otherwise, allocate space to make them consecutive.  */
+       else
+ 	{
+ 	  char *a = alloca (16);
+ 	  int j;
+ 
+ 	  avalue[i] = a;
+-	  for (j = 0; j < n; j++, a += 8)
++	  for (j = 0; (size_t) j < n; j++, a += 8)
+ 	    {
+ 	      if (SSE_CLASS_P (classes[j]))
+ 		memcpy (a, &reg_args->sse[ssecount++], 8);
+ 	      else
+ 		memcpy (a, &reg_args->gpr[gprcount++], 8);
+ 	    }
+ 	}
+     }