From 307c53eb25d6654f1558677e717ccde60ec31554 Mon Sep 17 00:00:00 2001 From: NuriAmari Date: Tue, 1 Jun 2021 13:56:19 +0000 Subject: [PATCH] Bug 1711878 - Remove unused JSContext arguments from PrintErrorImpl and PrintSingleError. r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D115754 --- js/public/ErrorReport.h | 5 ++--- js/src/jsapi-tests/testPrintError.cpp | 8 ++++---- js/src/jsexn.cpp | 2 +- js/src/shell/js.cpp | 4 ++-- js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp | 2 +- js/src/vm/ErrorReporting.cpp | 2 +- js/src/vm/JSContext.cpp | 22 ++++++++++------------ js/src/vm/SelfHosting.cpp | 2 +- 8 files changed, 22 insertions(+), 25 deletions(-) diff --git a/js/public/ErrorReport.h b/js/public/ErrorReport.h index 9caf769149c0..6dd16aec7baa 100644 --- a/js/public/ErrorReport.h +++ b/js/public/ErrorReport.h @@ -355,11 +355,10 @@ struct MOZ_STACK_CLASS JS_PUBLIC_API ErrorReportBuilder { // Writes a full report to a file descriptor. Does nothing for JSErrorReports // which are warnings, unless reportWarnings is set. -extern JS_PUBLIC_API void PrintError(JSContext* cx, FILE* file, - JSErrorReport* report, +extern JS_PUBLIC_API void PrintError(FILE* file, JSErrorReport* report, bool reportWarnings); -extern JS_PUBLIC_API void PrintError(JSContext* cx, FILE* file, +extern JS_PUBLIC_API void PrintError(FILE* file, const JS::ErrorReportBuilder& builder, bool reportWarnings); diff --git a/js/src/jsapi-tests/testPrintError.cpp b/js/src/jsapi-tests/testPrintError.cpp index 5f2f6cd5aab5..5195d359f42f 100644 --- a/js/src/jsapi-tests/testPrintError.cpp +++ b/js/src/jsapi-tests/testPrintError.cpp @@ -52,7 +52,7 @@ BEGIN_TEST(testPrintError_Works) { JS::ErrorReportBuilder builder(cx); CHECK(builder.init(cx, exnStack, JS::ErrorReportBuilder::NoSideEffects)); - JS::PrintError(cx, buf.stream(), builder, false); + JS::PrintError(buf.stream(), builder, false); CHECK(buf.contains("testPrintError_Works.js:3:1 uncaught exception: null\n")); @@ -71,7 +71,7 @@ static bool warningSuccess; static void warningReporter(JSContext* cx, JSErrorReport* report) { AutoStreamBuffer buf; - JS::PrintError(cx, buf.stream(), report, false); + JS::PrintError(buf.stream(), report, false); warningSuccess = buf.contains(""); } END_TEST(testPrintError_SkipWarning) @@ -89,7 +89,7 @@ static bool warningSuccess; static void warningReporter(JSContext* cx, JSErrorReport* report) { AutoStreamBuffer buf; - JS::PrintError(cx, buf.stream(), report, true); + JS::PrintError(buf.stream(), report, true); warningSuccess = buf.contains("warning: warning message\n"); } END_TEST(testPrintError_PrintWarning) @@ -111,7 +111,7 @@ BEGIN_TEST(testPrintError_UTF16CodePoints) { JS::ErrorReportBuilder builder(cx); CHECK(builder.init(cx, exnStack, JS::ErrorReportBuilder::NoSideEffects)); - JS::PrintError(cx, buf.stream(), builder, false); + JS::PrintError(buf.stream(), builder, false); CHECK( buf.contains("testPrintError_UTF16CodePoints.js:3:4 SyntaxError: illegal " diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index bd9e97c29352..382f6a005ddf 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -292,7 +292,7 @@ void js::ErrorToException(JSContext* cx, JSErrorReport* reportp, // cannot construct the Error constructor without self-hosted code. Just // print the error to stderr to help debugging. if (cx->realm()->isSelfHostingRealm()) { - JS::PrintError(cx, stderr, reportp, true); + JS::PrintError(stderr, reportp, true); return; } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 0058565aaac9..99cb021ec2ea 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -10192,7 +10192,7 @@ js::shell::AutoReportException::~AutoReportException() { MOZ_ASSERT(!report.report()->isWarning()); FILE* fp = ErrorFilePointer(); - JS::PrintError(cx, fp, report, reportWarnings); + JS::PrintError(fp, report, reportWarnings); JS_ClearPendingException(cx); if (!PrintStackTrace(cx, exnStack.stack())) { @@ -10232,7 +10232,7 @@ void js::shell::WarningReporter(JSContext* cx, JSErrorReport* report) { } // Print the warning. - JS::PrintError(cx, fp, report, reportWarnings); + JS::PrintError(fp, report, reportWarnings); } static bool global_enumerate(JSContext* cx, JS::HandleObject obj, diff --git a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp index 5567697a8535..1fa36a0a7d9e 100644 --- a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp +++ b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp @@ -44,7 +44,7 @@ static void CrashOnPendingException() { fprintf(stderr, "out of memory initializing JS::ErrorReportBuilder\n"); fflush(stderr); } else { - JS::PrintError(gCx, stderr, report, js::shell::reportWarnings); + JS::PrintError(stderr, report, js::shell::reportWarnings); if (!js::shell::PrintStackTrace(gCx, exnStack.stack())) { fputs("(Unable to print stack trace)\n", stderr); } diff --git a/js/src/vm/ErrorReporting.cpp b/js/src/vm/ErrorReporting.cpp index d9d64a0fab48..86ed700b5325 100644 --- a/js/src/vm/ErrorReporting.cpp +++ b/js/src/vm/ErrorReporting.cpp @@ -589,5 +589,5 @@ void js::MaybePrintAndClearPendingException(JSContext* cx) { } MOZ_ASSERT(!report.report()->isWarning()); - JS::PrintError(cx, stderr, report, true); + JS::PrintError(stderr, report, true); } diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index 2a2c04920fb8..70a06453b918 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -417,9 +417,8 @@ static void PrintErrorLine(FILE* file, const char* prefix, JSErrorNotes::Note* note) {} template -static void PrintSingleError(JSContext* cx, FILE* file, - JS::ConstUTF8CharsZ toStringResult, T* report, - PrintErrorKind kind) { +static void PrintSingleError(FILE* file, JS::ConstUTF8CharsZ toStringResult, + T* report, PrintErrorKind kind) { UniqueChars prefix; if (report->filename) { prefix = JS_smprintf("%s:", report->filename); @@ -472,8 +471,7 @@ static void PrintSingleError(JSContext* cx, FILE* file, fflush(file); } -static void PrintErrorImpl(JSContext* cx, FILE* file, - JS::ConstUTF8CharsZ toStringResult, +static void PrintErrorImpl(FILE* file, JS::ConstUTF8CharsZ toStringResult, JSErrorReport* report, bool reportWarnings) { MOZ_ASSERT(report); @@ -486,25 +484,25 @@ static void PrintErrorImpl(JSContext* cx, FILE* file, if (report->isWarning()) { kind = PrintErrorKind::Warning; } - PrintSingleError(cx, file, toStringResult, report, kind); + PrintSingleError(file, toStringResult, report, kind); if (report->notes) { for (auto&& note : *report->notes) { - PrintSingleError(cx, file, JS::ConstUTF8CharsZ(), note.get(), + PrintSingleError(file, JS::ConstUTF8CharsZ(), note.get(), PrintErrorKind::Note); } } } -JS_PUBLIC_API void JS::PrintError(JSContext* cx, FILE* file, - JSErrorReport* report, bool reportWarnings) { - PrintErrorImpl(cx, file, JS::ConstUTF8CharsZ(), report, reportWarnings); +JS_PUBLIC_API void JS::PrintError(FILE* file, JSErrorReport* report, + bool reportWarnings) { + PrintErrorImpl(file, JS::ConstUTF8CharsZ(), report, reportWarnings); } -JS_PUBLIC_API void JS::PrintError(JSContext* cx, FILE* file, +JS_PUBLIC_API void JS::PrintError(FILE* file, const JS::ErrorReportBuilder& builder, bool reportWarnings) { - PrintErrorImpl(cx, file, builder.toStringResult(), builder.report(), + PrintErrorImpl(file, builder.toStringResult(), builder.report(), reportWarnings); } diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index fbb5fa5abf5b..e61a4a73d861 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -118,7 +118,7 @@ using mozilla::Maybe; static void selfHosting_WarningReporter(JSContext* cx, JSErrorReport* report) { MOZ_ASSERT(report->isWarning()); - JS::PrintError(cx, stderr, report, true); + JS::PrintError(stderr, report, true); } static bool intrinsic_ToObject(JSContext* cx, unsigned argc, Value* vp) {