git » libjio » commit 0cf5dbd

Improve error handling in free_tid()

author Alberto Bertogli
2009-02-22 06:20:25 UTC
committer Alberto Bertogli
2009-02-22 06:24:44 UTC
parent 38e3f986fc53eaae2c9b5b617c52965d30c7e35e

Improve error handling in free_tid()

This patch improves free_tid()'s error handling by detecting when access()
fails with anything else but EACCES (which is expected) and leaving the
max untouched.

get_jtfile() can't fail, so it's not a problem either.

While at it, remove some unused assignments.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

trans.c +5 -4

diff --git a/trans.c b/trans.c
index 1effe16..df340d6 100644
--- a/trans.c
+++ b/trans.c
@@ -68,12 +68,13 @@ static void free_tid(struct jfs *fs, unsigned int tid)
 	if (tid == curid) {
 		/* look up the new max. */
 		for (i = curid - 1; i > 0; i--) {
-			/* this can fail if we're low on mem, but we don't
-			 * care checking here because the problem will come
-			 * out later and we can fail more properly */
 			get_jtfile(fs, i, name);
 			if (access(name, R_OK | W_OK) == 0) {
-				curid = i;
+				break;
+			} else if (errno != EACCES) {
+				/* Real error, stop looking for a new max. It
+				 * doesn't hurt us because it's ok if the max
+				 * is higher than it could be */
 				break;
 			}
 		}