From 5c18293aa2ce39b5dc857cf227e309d221fcb768 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Thu, 22 Mar 2018 13:00:33 -0400 Subject: [PATCH] jsauthority: JS::SetWarningReporter instead of JS_SetErrorReporter This commit changes the code to use JS::SetWarningReporter instead of JS_SetErrorReporter. The latter, as far as I can tell, is just a slightly renamed version of the former with the args moved around a little bit. Signed-off-by: Ray Strode https://bugs.freedesktop.org/show_bug.cgi?id=105865 --- src/polkitbackend/polkitbackendjsauthority.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp index 394e743..a3a21f1 100644 --- a/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp @@ -180,69 +180,68 @@ static const struct JSClassOps js_polkit_class_ops = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static JSClass js_polkit_class = { "Polkit", 0, &js_polkit_class_ops }; static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp); static JSBool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp); static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp); static JSFunctionSpec js_polkit_functions[] = { JS_FN("log", js_polkit_log, 0, 0), JS_FN("spawn", js_polkit_spawn, 0, 0), JS_FN("_userIsInNetGroup", js_polkit_user_is_in_netgroup, 0, 0), JS_FS_END }; /* ---------------------------------------------------------------------------------------------------- */ static void report_error (JSContext *cx, - const char *message, JSErrorReport *report) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (JS_GetContextPrivate (cx)); polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "%s:%u: %s", report->filename ? report->filename : "", (unsigned int) report->lineno, - message); + report->message().c_str()); } static void polkit_backend_js_authority_init (PolkitBackendJsAuthority *authority) { authority->priv = G_TYPE_INSTANCE_GET_PRIVATE (authority, POLKIT_BACKEND_TYPE_JS_AUTHORITY, PolkitBackendJsAuthorityPrivate); } static gint rules_file_name_cmp (const gchar *a, const gchar *b) { gint ret; const gchar *a_base; const gchar *b_base; a_base = strrchr (a, '/'); b_base = strrchr (b, '/'); g_assert (a_base != NULL); g_assert (b_base != NULL); a_base += 1; b_base += 1; ret = g_strcmp0 (a_base, b_base); if (ret == 0) { /* /etc wins over /usr */ @@ -441,61 +440,61 @@ setup_file_monitors (PolkitBackendJsAuthority *authority) "changed", G_CALLBACK (on_dir_monitor_changed), authority); g_ptr_array_add (p, monitor); } } g_ptr_array_add (p, NULL); authority->priv->dir_monitors = (GFileMonitor**) g_ptr_array_free (p, FALSE); } static void polkit_backend_js_authority_constructed (GObject *object) { PolkitBackendJsAuthority *authority = POLKIT_BACKEND_JS_AUTHORITY (object); gboolean entered_request = FALSE; authority->priv->cx = JS_NewContext (8L * 1024L * 1024L); if (authority->priv->cx == NULL) goto fail; if (!JS::InitSelfHostedCode (authority->priv->cx)) goto fail; /* TODO: JIT'ing doesn't work will with killing runaway scripts... I think * this is just a SpiderMonkey bug. So disable the JIT for now. */ JS::ContextOptionsRef (authority->priv->cx) .setIon (FALSE) .setBaseline (FALSE) .setAsmJS (FALSE); - JS_SetErrorReporter(authority->priv->cx, report_error); + JS::SetWarningReporter(authority->priv->cx, report_error); JS_SetContextPrivate (authority->priv->cx, authority); JS_BeginRequest(authority->priv->cx); entered_request = TRUE; { JS::CompartmentOptions compart_opts; compart_opts.behaviors().setVersion(JSVERSION_LATEST); authority->priv->js_global = JS_NewGlobalObject (authority->priv->cx, &js_global_class, NULL, compart_opts); if (authority->priv->js_global == NULL) goto fail; authority->priv->ac = new JSAutoCompartment(authority->priv->cx, authority->priv->js_global); if (authority->priv->ac == NULL) goto fail; JS_AddObjectRoot (authority->priv->cx, &authority->priv->js_global); if (!JS_InitStandardClasses (authority->priv->cx, authority->priv->js_global)) goto fail; authority->priv->js_polkit = JS_DefineObject (authority->priv->cx, authority->priv->js_global, "polkit", &js_polkit_class, NULL, JSPROP_ENUMERATE); if (authority->priv->js_polkit == NULL) -- 2.16.2