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

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