Thread (49 messages) flat view 49 messages, 1 author, 2016-06-15
DORMANTno replies

Revision v16 of 10 in this series.

Revisions (10)
  1. v11 [diff vs current]
  2. v13 [diff vs current]
  3. v14 [diff vs current]
  4. v15 [diff vs current]
  5. v16 current
  6. v17 [diff vs current]
  7. v18 [diff vs current]
  8. v19 [diff vs current]
  9. v20 [diff vs current]
  10. v21 [diff vs current]

[PATCH v16 11/48] refs.c: make remove_empty_directories alwasy set errno to something sane

From: Ronnie Sahlberg <hidden>
Date: 2016-06-15 23:01:36
Subsystem: the rest · Maintainer: Linus Torvalds

Making errno when returning from remove_empty_directories() more
obviously meaningful, which should provide some peace of mind for
people auditing lock_ref_sha1_basic.

Signed-off-by: Ronnie Sahlberg <redacted>
---
 refs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index 3631a3b..dd28214 100644
--- a/refs.c
+++ b/refs.c
@@ -1932,14 +1932,16 @@ static int remove_empty_directories(const char *file)
 	 * only empty directories), remove them.
 	 */
 	struct strbuf path;
-	int result;
+	int result, save_errno;
 
 	strbuf_init(&path, 20);
 	strbuf_addstr(&path, file);
 
 	result = remove_dir_recursively(&path, REMOVE_DIR_EMPTY_ONLY);
+	save_errno = errno;
 
 	strbuf_release(&path);
+	errno = save_errno;
 
 	return result;
 }
@@ -2028,6 +2030,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
 	return logs_found;
 }
 
+/* This function should make sure errno is meaningful on error */
 static struct ref_lock *lock_ref_sha1_basic(const char *refname,
 					    const unsigned char *old_sha1,
 					    int flags, int *type_p)
-- 
2.0.0.599.g83ced0e
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help