# New Ticket Created by Andrew Whitworth
# Please include the string: [perl #56968]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=56968 >
I found this today while looking for error-reporting functions. The
function src/warnings.c:Parrot_warn_s is almost completely unused
except in 1 test in t/src/warnings.t. The attached patch removes this
function and the associated test because it's dead code with no
apparent purpose.
On a side note, if people don't want to delete this function for
whatever reason, the function prototype should be changed from
NULLOK_INTERP to PARROT_INTERP, since the first line of the function
tests for the existance of interp and returns an error if it's null.
Better to find a null interp error at compile time then at runtime.
--Andrew Whitworth
Index: src/warnings.c
===
--- src/warnings.c (revision 29495)
+++ src/warnings.c (working copy)
@@ -117,39 +117,6 @@
/*
-=item C
-
-The Parrot C warning/error reporter.
-
-Returns 2 on error, 1 on success.
-
-C can be a C format with arguments.
-
-=cut
-
-*/
-
-PARROT_API
-INTVAL
-Parrot_warn_s(NULLOK_INTERP, INTVAL warnclass,
- ARGIN(STRING *message), ...)
-{
-if (!interp || !PARROT_WARNINGS_test(interp, warnclass))
-return 2;
-else {
-STRING *targ;
-va_list args;
-
-va_start(args, message);
-targ = Parrot_vsprintf_s(interp, message, args);
-va_end(args);
-
-return print_warning(interp, targ);
-}
-}
-
-/*
-
=back
=head1 SEE ALSO
Index: include/parrot/string_funcs.h
===
--- include/parrot/string_funcs.h (revision 29495)
+++ include/parrot/string_funcs.h (working copy)
@@ -86,6 +86,14 @@
PARROT_API
PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+PMC* Parrot_string_split(PARROT_INTERP,
+ARGIN_NULLOK(STRING *delim),
+ARGIN_NULLOK(STRING *str))
+__attribute__nonnull__(1);
+
+PARROT_API
+PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
STRING* Parrot_string_trans_charset(PARROT_INTERP,
ARGMOD_NULLOK(STRING *src),
@@ -425,14 +433,6 @@
PARROT_API
PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-PMC* Parrot_string_split(PARROT_INTERP,
-ARGIN_NULLOK(STRING *delim),
-ARGIN_NULLOK(STRING *str))
-__attribute__nonnull__(1);
-
-PARROT_API
-PARROT_WARN_UNUSED_RESULT
INTVAL string_str_index(PARROT_INTERP,
ARGIN(const STRING *s),
ARGIN(const STRING *s2),
Index: include/parrot/warnings.h
===
--- include/parrot/warnings.h (revision 29495)
+++ include/parrot/warnings.h (working copy)
@@ -65,14 +65,6 @@
__attribute__nonnull__(3);
PARROT_API
-INTVAL Parrot_warn_s(
-NULLOK_INTERP,
-INTVAL warnclass,
-ARGIN(STRING *message),
-...)
-__attribute__nonnull__(3);
-
-PARROT_API
void print_pbc_location(PARROT_INTERP)
__attribute__nonnull__(1);
Index: t/src/warnings.t
===
--- t/src/warnings.t (revision 29495)
+++ t/src/warnings.t (working copy)
@@ -115,84 +115,6 @@
2
OUTPUT
-c_output_is( <<'CODE', <<'OUTPUT', "Parrot_warn_s" );
-
-#include
-#include
-
-int
-main(int argc, char* argv[])
-{
-Interp *interp;
-int error_val;
-STRING *S;
-
-interp = Parrot_new(NULL);
-if (!interp) {
-return 1;
-}
-PARROT_WARNINGS_on(interp, PARROT_WARNINGS_ALL_FLAG);
-
-S = Parrot_sprintf_c(interp, "eek");
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_ALL_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-/* warnings are on, this should return an error */
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_NONE_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_UNDEF_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_IO_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_PLATFORM_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-error_val = Parrot_warn_s(interp, PARROT_WARNINGS_DYNEXT_FLAG, S);
-PIO_eprintf(interp, "%d\n", error_val);
-
-#ifndef __cplusplus
-error_val = Parrot_warn_s(interp, 0, "eek"); /* should return error */
-#else
-/* Fake the result to avoid rewrite the test */
-error_val = 2;
-#endif
-PIO_eprintf(interp, "%d\n", error_val);
-
-#ifndef __cplusplus
-error_val = Parrot_warn_s(NULL, 0, "eek"); /* should return error */
-#else
-/* Fake the result to avoid rewrite the test */
-error_val = 2;
-#endif
-PIO_eprintf(interp, "%d\n", error_val);
-
-Parrot_exit(interp, 0);
-return 0;
-}
-CODE
-eek
-(null)
-1
-2
-eek
-(null)
-1
-eek