# New Ticket Created by Nick Glencross
# Please include the string: [perl #37577]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37577 >
This patch fixes two classes of issue.
* Don't assign -1 to an unsigned variable; use ~0U instead as it
makes it clear that the value is intended to be out-of-band (g++
warned about this, and C compilers will increasingly)
* Change a K&R prototype in a config test
Regards,
Nick
Index: src/debug.c
===================================================================
--- src/debug.c (revision 9682)
+++ src/debug.c (working copy)
@@ -225,7 +225,7 @@
/* Nonempty and did not start with a letter */
if (c == 0)
- c = -1;
+ c = ~0U;
*cmdP = c;
Index: src/string_primitives.c
===================================================================
--- src/string_primitives.c (revision 9682)
+++ src/string_primitives.c (working copy)
@@ -351,7 +351,7 @@
Parrot_char_digit_value(Interp *interpreter, UINTVAL character)>
Returns the decimal digit value of the specified character if it is a decimal
-digit character. If not, then -1 is returned.
+digit character. If not, then ~0U is returned.
Note that as currently written, C<Parrot_char_digit_value()> can
correctly return the decimal digit value of characters for which
@@ -369,7 +369,7 @@
#else
if ((character >= 0x30) || (character <= 0x39))
return character - 0x30;
- return -1;
+ return ~0U;
#endif
}
Index: src/inter_create.c
===================================================================
--- src/inter_create.c (revision 9682)
+++ src/inter_create.c (working copy)
@@ -125,7 +125,7 @@
create_initial_context(interpreter);
interpreter->resume_flag = RESUME_INITIAL;
/* main is called as a Sub too - this will get depth 0 then */
- CONTEXT(interpreter->ctx)->recursion_depth = -1;
+ CONTEXT(interpreter->ctx)->recursion_depth = ~0U;
interpreter->recursion_limit = 1000;
/* Must initialize flags here so the GC_DEBUG stuff is available before
Index: src/pmc_freeze.c
===================================================================
--- src/pmc_freeze.c (revision 9682)
+++ src/pmc_freeze.c (working copy)
@@ -1051,7 +1051,7 @@
id += arena->total_objects;
}
internal_exception(1, "Couldn't find PMC in arenas");
- return -1;
+ return ~0U;
}
#else
@@ -1089,7 +1089,7 @@
}
internal_exception(1, "Couldn't find PMC in arenas");
- return -1;
+ return ~0U;
}
#endif
Index: config/auto/alignptrs/test_c.in
===================================================================
--- config/auto/alignptrs/test_c.in (revision 9682)
+++ config/auto/alignptrs/test_c.in (working copy)
@@ -10,7 +10,7 @@
#include <signal.h>
/* Try to catch bus errors */
#ifdef SIGBUS
-void bletch(s) int s; { exit(1); }
+void bletch(int s) { exit(1); }
#endif
int main(int argc, char **argv) {