Blame SOURCES/autofs-5.1.1-factor-out-free-multi-map-context.patch

306fa1
autofs-5.1.1 - factor out free multi map context
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Seperate out the free context function for the multi map module.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 modules/lookup_multi.c |   38 +++++++++++++++++++++++++++++---------
306fa1
 1 file changed, 29 insertions(+), 9 deletions(-)
306fa1
306fa1
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
306fa1
index 0ee20f5..36ace11 100644
306fa1
--- a/modules/lookup_multi.c
306fa1
+++ b/modules/lookup_multi.c
306fa1
@@ -40,6 +40,32 @@ struct lookup_context {
306fa1
 
306fa1
 int lookup_version = AUTOFS_LOOKUP_VERSION;	/* Required by protocol */
306fa1
 
306fa1
+static int free_multi_context(struct lookup_context *ctxt)
306fa1
+{
306fa1
+	int rv;
306fa1
+
306fa1
+	if (!ctxt)
306fa1
+		return 0;
306fa1
+
306fa1
+	rv = 0;
306fa1
+	if (ctxt->m) {
306fa1
+		int i;
306fa1
+
306fa1
+		for (i = 0; i < ctxt->n; i++) {
306fa1
+			if (ctxt->m[i].mod)
306fa1
+				rv = rv || close_lookup(ctxt->m[i].mod);
306fa1
+			if (ctxt->m[i].argv)
306fa1
+				free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
306fa1
+		}
306fa1
+		free(ctxt->m);
306fa1
+	}
306fa1
+
306fa1
+	if (ctxt->argl)
306fa1
+		free(ctxt->argl);
306fa1
+
306fa1
+	return rv;
306fa1
+}
306fa1
+
306fa1
 static struct lookup_mod *nss_open_lookup(const char *format, int argc, const char **argv)
306fa1
 {
306fa1
 	struct list_head nsslist;
306fa1
@@ -306,16 +332,10 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
306fa1
 int lookup_done(void *context)
306fa1
 {
306fa1
 	struct lookup_context *ctxt = (struct lookup_context *) context;
306fa1
-	int i, rv = 0;
306fa1
+	int rv;
306fa1
 
306fa1
-	for (i = 0; i < ctxt->n; i++) {
306fa1
-		if (ctxt->m[i].mod)
306fa1
-			rv = rv || close_lookup(ctxt->m[i].mod);
306fa1
-		if (ctxt->m[i].argv)
306fa1
-			free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
306fa1
-	}
306fa1
-	free(ctxt->argl);
306fa1
-	free(ctxt->m);
306fa1
+	rv = free_multi_context(ctxt);
306fa1
 	free(ctxt);
306fa1
+
306fa1
 	return rv;
306fa1
 }