shithub: orca

Download patch

ref: ba5a58bb88154985f4ebe6c09e2c779ec93bf2cb
parent: 2a1ad3f2ba59b3a6866338d5015bd94248ca3204
author: cancel <cancel@cancel.fm>
date: Mon Jan 27 05:16:43 EST 2020

Cleanup

--- a/sysmisc.c
+++ b/sysmisc.c
@@ -288,15 +288,11 @@
     err = Conf_save_start_no_home;
     goto cleanup;
   }
-  if (!dir) {
-    err = Conf_save_start_alloc_failed;
-    goto cleanup;
-  }
+  if (!dir)
+    goto allocfail;
   osoputoso(&p->canonpath, dir);
-  if (!p->canonpath) {
-    err = Conf_save_start_alloc_failed;
-    goto cleanup;
-  }
+  if (!p->canonpath)
+    goto allocfail;
   size_t namelen = strlen(conf_file_name);
   if (namelen == 0) {
     err = Conf_save_start_bad_conf_name;
@@ -303,20 +299,14 @@
     goto cleanup;
   }
   conf_impl_catconfpath(&p->canonpath, conf_file_name, namelen);
-  if (!p->canonpath) {
-    err = Conf_save_start_alloc_failed;
-    goto cleanup;
-  }
+  if (!p->canonpath)
+    goto allocfail;
   osoputoso(&p->temppath, p->canonpath);
-  if (!p->temppath) {
-    err = Conf_save_start_alloc_failed;
-    goto cleanup;
-  }
+  if (!p->temppath)
+    goto allocfail;
   osocat(&p->temppath, ".tmp");
-  if (!p->temppath) {
-    err = Conf_save_start_alloc_failed;
-    goto cleanup;
-  }
+  if (!p->temppath)
+    goto allocfail;
   // Remove old temp file if it exists. If it exists and we can't remove it,
   // error.
   if (unlink(osoc(p->temppath)) == -1 && errno != ENOENT) {
@@ -350,6 +340,8 @@
   osofree(dir);
   return Conf_save_start_ok;
 
+allocfail:
+  err = Conf_save_start_alloc_failed;
 cleanup:
   osofree(dir);
   conf_save_cancel(p);