config.c: use error_errno()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed May 8, 2016 at 16:47 UTC f0658ec9ea996f993e3665786b3f5ac0b92179e2
1 file changed +9 -13
config.c
+9 -13
@@ -2016,7 +2016,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2016 lock = xcalloc(1, sizeof(struct lock_file));
2017 fd = hold_lock_file_for_update(lock, config_filename, 0);
2018 if (fd < 0) {
2019 - error("could not lock config file %s: %s", config_filename, strerror(errno));
2019 + error_errno("could not lock config file %s", config_filename);
2020 free(store.key);
2021 ret = CONFIG_NO_LOCK;
2022 goto out_free;
@@ -2030,8 +2030,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2030 free(store.key);
2031
2032 if ( ENOENT != errno ) {
2033 - error("opening %s: %s", config_filename,
2034 - strerror(errno));
2033 + error_errno("opening %s", config_filename);
2034 ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
2035 goto out_free;
2036 }
@@ -2115,8 +2114,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2114 if (contents == MAP_FAILED) {
2115 if (errno == ENODEV && S_ISDIR(st.st_mode))
2116 errno = EISDIR;
2118 - error("unable to mmap '%s': %s",
2119 - config_filename, strerror(errno));
2117 + error_errno("unable to mmap '%s'", config_filename);
2118 ret = CONFIG_INVALID_FILE;
2119 contents = NULL;
2120 goto out_free;
@@ -2125,8 +2123,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2123 in_fd = -1;
2124
2125 if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
2128 - error("chmod on %s failed: %s",
2129 - get_lock_file_path(lock), strerror(errno));
2126 + error_errno("chmod on %s failed", get_lock_file_path(lock));
2127 ret = CONFIG_NO_WRITE;
2128 goto out_free;
2129 }
@@ -2182,8 +2179,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2179 }
2180
2181 if (commit_lock_file(lock) < 0) {
2185 - error("could not write config file %s: %s", config_filename,
2186 - strerror(errno));
2182 + error_errno("could not write config file %s", config_filename);
2183 ret = CONFIG_NO_WRITE;
2184 lock = NULL;
2185 goto out_free;
@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,
2326 fstat(fileno(config_file), &st);
2327
2328 if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
2333 - ret = error("chmod on %s failed: %s",
2334 - get_lock_file_path(lock), strerror(errno));
2329 + ret = error_errno("chmod on %s failed",
2330 + get_lock_file_path(lock));
2331 goto out;
2332 }
2333
@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,
2381 fclose(config_file);
2382 unlock_and_out:
2383 if (commit_lock_file(lock) < 0)
2388 - ret = error("could not write config file %s: %s",
2389 - config_filename, strerror(errno));
2384 + ret = error_errno("could not write config file %s",
2385 + config_filename);
2386 out:
2387 free(filename_buf);
2388 return ret;