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

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