From 0e8bc45783a6f5e310f3f7829bedb328507cca2e Mon Sep 17 00:00:00 2001
From: Yuchen Zeng <zyc@google.com>
Date: Thu, 23 Mar 2017 14:44:14 -0700
Subject: [PATCH] Update with the new error interface

---
 .../ext/resolver/dns/c_ares/dns_resolver_ares.c   |  5 +++--
 .../dns/c_ares/grpc_ares_ev_driver_posix.c        |  4 ++--
 .../ext/resolver/dns/c_ares/grpc_ares_wrapper.c   | 15 ++++++++-------
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c b/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
index d8369817b1..f27da231f5 100644
--- a/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
+++ b/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
@@ -124,8 +124,9 @@ static void dns_ares_shutdown_locked(grpc_exec_ctx *exec_ctx,
   }
   if (r->next_completion != NULL) {
     *r->target_result = NULL;
-    grpc_closure_sched(exec_ctx, r->next_completion,
-                       GRPC_ERROR_CREATE("Resolver Shutdown"));
+    grpc_closure_sched(
+        exec_ctx, r->next_completion,
+        GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
     r->next_completion = NULL;
   }
 }
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
index fb32b850ce..fab4f0c977 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
@@ -115,7 +115,7 @@ static void fd_node_destroy(grpc_exec_ctx *exec_ctx, fd_node *fdn) {
   gpr_mu_destroy(&fdn->mu);
   grpc_pollset_set_del_fd(exec_ctx, fdn->ev_driver->pollset_set, fdn->grpc_fd);
   grpc_fd_shutdown(exec_ctx, fdn->grpc_fd,
-                   GRPC_ERROR_CREATE("fd node destroyed"));
+                   GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd node destroyed"));
   grpc_fd_orphan(exec_ctx, fdn->grpc_fd, NULL, NULL, "c-ares query finished");
   gpr_free(fdn);
 }
@@ -129,7 +129,7 @@ grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
     char *err_msg;
     gpr_asprintf(&err_msg, "Failed to init ares channel. C-ares error: %s",
                  ares_strerror(status));
-    grpc_error *err = GRPC_ERROR_CREATE(err_msg);
+    grpc_error *err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_msg);
     gpr_free(err_msg);
     gpr_free(*ev_driver);
     return err;
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
index 6c2d662138..3eee8e3513 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
@@ -180,7 +180,7 @@ static void on_done_cb(void *arg, int status, int timeouts,
     char *error_msg;
     gpr_asprintf(&error_msg, "C-ares status is not ARES_SUCCESS: %s",
                  ares_strerror(status));
-    grpc_error *error = GRPC_ERROR_CREATE(error_msg);
+    grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
     gpr_free(error_msg);
     if (r->error == GRPC_ERROR_NONE) {
       r->error = error;
@@ -208,15 +208,16 @@ void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name,
   char *port;
   gpr_split_host_port(name, &host, &port);
   if (host == NULL) {
-    grpc_error *err =
-        grpc_error_set_str(GRPC_ERROR_CREATE("unparseable host:port"),
-                           GRPC_ERROR_STR_TARGET_ADDRESS, name);
+    grpc_error *err = grpc_error_set_str(
+        GRPC_ERROR_CREATE_FROM_STATIC_STRING("unparseable host:port"),
+        GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
     grpc_closure_sched(exec_ctx, on_done, err);
     goto error_cleanup;
   } else if (port == NULL) {
     if (default_port == NULL) {
-      grpc_error *err = grpc_error_set_str(GRPC_ERROR_CREATE("no port in name"),
-                                           GRPC_ERROR_STR_TARGET_ADDRESS, name);
+      grpc_error *err = grpc_error_set_str(
+          GRPC_ERROR_CREATE_FROM_STATIC_STRING("no port in name"),
+          GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
       grpc_closure_sched(exec_ctx, on_done, err);
       goto error_cleanup;
     }
@@ -272,7 +273,7 @@ grpc_error *grpc_ares_init(void) {
     char *error_msg;
     gpr_asprintf(&error_msg, "ares_library_init failed: %s",
                  ares_strerror(status));
-    grpc_error *error = GRPC_ERROR_CREATE(error_msg);
+    grpc_error *error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
     gpr_free(error_msg);
     return error;
   }
-- 
GitLab