summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2017-11-15 12:40:43 +0000
committerJunio C Hamano <gitster@pobox.com>2017-11-16 10:36:16 +0900
commitc5e3bc6ec46071397b40582157214d374d1b4fab (patch)
treea698b2329a07becd0211adb62f8cb76066c9947c /config.c
parente5435ff1fc64d93cce73ec4ee2571219384a92a9 (diff)
downloadgit-c5e3bc6ec46071397b40582157214d374d1b4fab.tar.gz
config: avoid "write_in_full(fd, buf, len) != len" patternsd/branch-copy
As explained in commit 06f46f237 (avoid "write_in_full(fd, buf, len) != len" pattern, 2017–09–13) the return value of write_in_full() is either -1 or the requested number of bytes. As such comparing the return value to an unsigned value such as strbuf.len will fail to catch errors. Change the code to use the preferred '< 0' check. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/config.c b/config.c
index d0d5aa1dc5..4457aec089 100644
--- a/config.c
+++ b/config.c
@@ -2700,7 +2700,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
* multiple [branch "$name"] sections.
*/
if (copystr.len > 0) {
- if (write_in_full(out_fd, copystr.buf, copystr.len) != copystr.len) {
+ if (write_in_full(out_fd, copystr.buf, copystr.len) < 0) {
ret = write_error(get_lock_file_path(lock));
goto out;
}
@@ -2763,7 +2763,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
* logic in the loop above.
*/
if (copystr.len > 0) {
- if (write_in_full(out_fd, copystr.buf, copystr.len) != copystr.len) {
+ if (write_in_full(out_fd, copystr.buf, copystr.len) < 0) {
ret = write_error(get_lock_file_path(lock));
goto out;
}