[Groonga-commit] groonga/groonga at b432b09 [master] Don't set error

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jun 5 16:29:27 JST 2017


Kouhei Sutou	2017-06-05 16:29:27 +0900 (Mon, 05 Jun 2017)

  New Revision: b432b0900ff6c5d15ba79f781f4228219931be20
  https://github.com/groonga/groonga/commit/b432b0900ff6c5d15ba79f781f4228219931be20

  Message:
    Don't set error
    
    Because comment says the following:
    
    Note that grn_dat_remove_file() does not change `ctx->rc'.

  Modified files:
    lib/dat.cpp

  Modified: lib/dat.cpp (+15 -10)
===================================================================
--- lib/dat.cpp    2017-06-05 16:24:02 +0900 (f4b1289)
+++ lib/dat.cpp    2017-06-05 16:29:27 +0900 (dbb20a7)
@@ -71,17 +71,22 @@ bool
 grn_dat_remove_file(grn_ctx *ctx, const char *path)
 {
   struct stat stat;
-  bool succeeded = false;
-  if (!::stat(path, &stat)) {
-    if (grn_unlink(path) != 0) {
-      ERRNO_ERR("failed to remove path: <%s>", path);
-    } else {
-      GRN_LOG(ctx, GRN_LOG_INFO,
-              "removed path on grn_dat_remove_file(): <%s>", path);
-      succeeded = true;
-    }
+
+  if (::stat(path, &stat) == -1) {
+    return false;
   }
-  return succeeded;
+
+  if (grn_unlink(path) == -1) {
+    const char *system_message = grn_strerror(errno);
+    GRN_LOG(ctx, GRN_LOG_WARNING,
+            "[dat][remove-file] failed to remove path: %s: <%s>",
+            system_message, path);
+    return false;
+  }
+
+  GRN_LOG(ctx, GRN_LOG_INFO,
+          "[dat][remove-file] removed: <%s>", path);
+  return true;
 }
 
 grn_rc
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index