Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Oct 2019 02:33:57 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r353976 - stable/12/stand/common
Message-ID:  <201910240233.x9O2XvF8087485@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Oct 24 02:33:57 2019
New Revision: 353976
URL: https://svnweb.freebsd.org/changeset/base/353976

Log:
  MFC r344892: stand/common/module: Apply style(9)

Modified:
  stable/12/stand/common/module.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/common/module.c
==============================================================================
--- stable/12/stand/common/module.c	Thu Oct 24 02:33:12 2019	(r353975)
+++ stable/12/stand/common/module.c	Thu Oct 24 02:33:57 2019	(r353976)
@@ -102,63 +102,63 @@ COMMAND_SET(load, "load", "load a kernel or module", c
 static int
 command_load(int argc, char *argv[])
 {
-    struct preloaded_file *fp;
-    char	*typestr;
-    char	*prefix;
-    char	*skip;
-    int		dflag, dofile, dokld, ch, error;
+	struct preloaded_file *fp;
+	char	*typestr;
+	char	*prefix;
+	char	*skip;
+	int		dflag, dofile, dokld, ch, error;
 
-    dflag = dokld = dofile = 0;
-    optind = 1;
-    optreset = 1;
-    typestr = NULL;
-    if (argc == 1) {
-	command_errmsg = "no filename specified";
-	return (CMD_CRIT);
-    }
-    prefix = skip = NULL;
-    while ((ch = getopt(argc, argv, "dkp:s:t:")) != -1) {
-	switch(ch) {
-	case 'd':
-	    dflag++;
-	    break;
-	case 'k':
-	    dokld = 1;
-	    break;
-	case 'p':
-	    prefix = optarg;
-	    break;
-	case 's':
-	    skip = optarg;
-	    break;
-	case 't':
-	    typestr = optarg;
-	    dofile = 1;
-	    break;
-	case '?':
-	default:
-	    /* getopt has already reported an error */
-	    return (CMD_OK);
+	dflag = dokld = dofile = 0;
+	optind = 1;
+	optreset = 1;
+	typestr = NULL;
+	if (argc == 1) {
+		command_errmsg = "no filename specified";
+		return (CMD_CRIT);
 	}
-    }
-    argv += (optind - 1);
-    argc -= (optind - 1);
-
-    /*
-     * Request to load a raw file?
-     */
-    if (dofile) {
-	if ((argc != 2) || (typestr == NULL) || (*typestr == 0)) {
-	    command_errmsg = "invalid load type";
-	    return (CMD_CRIT);
+	prefix = skip = NULL;
+	while ((ch = getopt(argc, argv, "dkp:s:t:")) != -1) {
+		switch(ch) {
+		case 'd':
+			dflag++;
+			break;
+		case 'k':
+			dokld = 1;
+			break;
+		case 'p':
+			prefix = optarg;
+			break;
+		case 's':
+			skip = optarg;
+			break;
+		case 't':
+			typestr = optarg;
+			dofile = 1;
+			break;
+		case '?':
+		default:
+			/* getopt has already reported an error */
+			return (CMD_OK);
+		}
 	}
+	argv += (optind - 1);
+	argc -= (optind - 1);
 
+	/*
+	 * Request to load a raw file?
+	 */
+	if (dofile) {
+		if ((argc != 2) || (typestr == NULL) || (*typestr == 0)) {
+			command_errmsg = "invalid load type";
+			return (CMD_CRIT);
+		}
+
 #ifdef LOADER_VERIEXEC
-	if (strncmp(typestr, "manifest", 8) == 0) {
-	    if (dflag > 0)
-		ve_debug_set(dflag);
-	    return (load_manifest(argv[1], prefix, skip, NULL));
-	}
+		if (strncmp(typestr, "manifest", 8) == 0) {
+			if (dflag > 0)
+				ve_debug_set(dflag);
+			return (load_manifest(argv[1], prefix, skip, NULL));
+		}
 #ifdef LOADER_VERIEXEC_PASS_MANIFEST
 		if (strncmp(typestr, "pass_manifest", 13) == 0) {
 			if (dflag > 0)
@@ -168,46 +168,46 @@ command_load(int argc, char *argv[])
 #endif
 #endif
 
-	fp = file_findfile(argv[1], typestr);
-	if (fp) {
-		snprintf(command_errbuf, sizeof(command_errbuf),
-		    "warning: file '%s' already loaded", argv[1]);
-		return (CMD_WARN);
-	}
+		fp = file_findfile(argv[1], typestr);
+		if (fp) {
+			snprintf(command_errbuf, sizeof(command_errbuf),
+			  "warning: file '%s' already loaded", argv[1]);
+			return (CMD_WARN);
+		}
 
-	if (file_loadraw(argv[1], typestr, 1) != NULL)
-		return (CMD_OK);
+		if (file_loadraw(argv[1], typestr, 1) != NULL)
+			return (CMD_OK);
 
-	/* Failing to load mfs_root is never going to end well! */
-	if (strcmp("mfs_root", typestr) == 0)
-		return (CMD_FATAL);
+		/* Failing to load mfs_root is never going to end well! */
+		if (strcmp("mfs_root", typestr) == 0)
+			return (CMD_FATAL);
 
-	return (CMD_ERROR);
-    }
-    /*
-     * Do we have explicit KLD load ?
-     */
-    if (dokld || file_havepath(argv[1])) {
-	error = mod_loadkld(argv[1], argc - 2, argv + 2);
-	if (error == EEXIST) {
-	    snprintf(command_errbuf, sizeof(command_errbuf),
-		"warning: KLD '%s' already loaded", argv[1]);
-	    return (CMD_WARN);
+		return (CMD_ERROR);
 	}
+	/*
+	 * Do we have explicit KLD load ?
+	 */
+	if (dokld || file_havepath(argv[1])) {
+		error = mod_loadkld(argv[1], argc - 2, argv + 2);
+		if (error == EEXIST) {
+			snprintf(command_errbuf, sizeof(command_errbuf),
+			  "warning: KLD '%s' already loaded", argv[1]);
+			return (CMD_WARN);
+		}
 	
-	return (error == 0 ? CMD_OK : CMD_CRIT);
-    }
-    /*
-     * Looks like a request for a module.
-     */
-    error = mod_load(argv[1], NULL, argc - 2, argv + 2);
-    if (error == EEXIST) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "warning: module '%s' already loaded", argv[1]);
-	return (CMD_WARN);
-    }
+		return (error == 0 ? CMD_OK : CMD_CRIT);
+	}
+	/*
+	 * Looks like a request for a module.
+	 */
+	error = mod_load(argv[1], NULL, argc - 2, argv + 2);
+	if (error == EEXIST) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "warning: module '%s' already loaded", argv[1]);
+		return (CMD_WARN);
+	}
 
-    return (error == 0 ? CMD_OK : CMD_CRIT);
+	return (error == 0 ? CMD_OK : CMD_CRIT);
 }
 
 #ifdef LOADER_GELI_SUPPORT
@@ -216,53 +216,53 @@ COMMAND_SET(load_geli, "load_geli", "load a geli key",
 static int
 command_load_geli(int argc, char *argv[])
 {
-    char	typestr[80];
-    char	*cp;
-    int		ch, num;
+	char	typestr[80];
+	char	*cp;
+	int		ch, num;
 
-    if (argc < 3) {
-	    command_errmsg = "usage is [-n key#] <prov> <file>";
-	    return(CMD_ERROR);
-    }
+	if (argc < 3) {
+		command_errmsg = "usage is [-n key#] <prov> <file>";
+		return(CMD_ERROR);
+	}
 
-    num = 0;
-    optind = 1;
-    optreset = 1;
-    while ((ch = getopt(argc, argv, "n:")) != -1) {
-	switch(ch) {
-	case 'n':
-	    num = strtol(optarg, &cp, 0);
-	    if (cp == optarg) {
-		    snprintf(command_errbuf, sizeof(command_errbuf),
-			"bad key index '%s'", optarg);
-		    return(CMD_ERROR);
-	    }
-	    break;
-	case '?':
-	default:
-	    /* getopt has already reported an error */
-	    return(CMD_OK);
+	num = 0;
+	optind = 1;
+	optreset = 1;
+	while ((ch = getopt(argc, argv, "n:")) != -1) {
+		switch(ch) {
+		case 'n':
+			num = strtol(optarg, &cp, 0);
+			if (cp == optarg) {
+				snprintf(command_errbuf, sizeof(command_errbuf),
+				  "bad key index '%s'", optarg);
+				return(CMD_ERROR);
+			}
+			break;
+		case '?':
+		default:
+			/* getopt has already reported an error */
+			return(CMD_OK);
+		}
 	}
-    }
-    argv += (optind - 1);
-    argc -= (optind - 1);
-    sprintf(typestr, "%s:geli_keyfile%d", argv[1], num);
-    return (file_loadraw(argv[2], typestr, 1) ? CMD_OK : CMD_ERROR);
+	argv += (optind - 1);
+	argc -= (optind - 1);
+	sprintf(typestr, "%s:geli_keyfile%d", argv[1], num);
+	return (file_loadraw(argv[2], typestr, 1) ? CMD_OK : CMD_ERROR);
 }
 #endif
 
 void
 unload(void)
 {
-    struct preloaded_file *fp;
+	struct preloaded_file *fp;
 
-    while (preloaded_files != NULL) {
-	fp = preloaded_files;
-	preloaded_files = preloaded_files->f_next;
-	file_discard(fp);
-    }
-    loadaddr = 0;
-    unsetenv("kernelname");
+	while (preloaded_files != NULL) {
+		fp = preloaded_files;
+		preloaded_files = preloaded_files->f_next;
+		file_discard(fp);
+	}
+	loadaddr = 0;
+	unsetenv("kernelname");
 }
 
 COMMAND_SET(unload, "unload", "unload all modules", command_unload);
@@ -270,8 +270,8 @@ COMMAND_SET(unload, "unload", "unload all modules", co
 static int
 command_unload(int argc, char *argv[])
 {
-    unload();
-    return(CMD_OK);
+	unload();
+	return(CMD_OK);
 }
 
 COMMAND_SET(lsmod, "lsmod", "list loaded modules", command_lsmod);
@@ -279,66 +279,66 @@ COMMAND_SET(lsmod, "lsmod", "list loaded modules", com
 static int
 command_lsmod(int argc, char *argv[])
 {
-    struct preloaded_file	*fp;
-    struct kernel_module	*mp;
-    struct file_metadata	*md;
-    char			lbuf[80];
-    int				ch, verbose, ret = 0;
+	struct preloaded_file	*fp;
+	struct kernel_module	*mp;
+	struct file_metadata	*md;
+	char			lbuf[80];
+	int				ch, verbose, ret = 0;
 
-    verbose = 0;
-    optind = 1;
-    optreset = 1;
-    while ((ch = getopt(argc, argv, "v")) != -1) {
-	switch(ch) {
-	case 'v':
-	    verbose = 1;
-	    break;
-	case '?':
-	default:
-	    /* getopt has already reported an error */
-	    return(CMD_OK);
+	verbose = 0;
+	optind = 1;
+	optreset = 1;
+	while ((ch = getopt(argc, argv, "v")) != -1) {
+		switch(ch) {
+		case 'v':
+			verbose = 1;
+			break;
+		case '?':
+		default:
+			/* getopt has already reported an error */
+			return(CMD_OK);
+		}
 	}
-    }
 
-    pager_open();
-    for (fp = preloaded_files; fp; fp = fp->f_next) {
-	snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr);
-	pager_output(lbuf);
-	pager_output(fp->f_name);
-	snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type,
-	    (long)fp->f_size);
-	if (pager_output(lbuf))
-	    break;
-	if (fp->f_args != NULL) {
-	    pager_output("    args: ");
-	    pager_output(fp->f_args);
-	    if (pager_output("\n"))
-		    break;
-	}
-	if (fp->f_modules) {
-	    pager_output("  modules: ");
-	    for (mp = fp->f_modules; mp; mp = mp->m_next) {
-		snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name,
-		    mp->m_version);
+	pager_open();
+	for (fp = preloaded_files; fp; fp = fp->f_next) {
+		snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr);
 		pager_output(lbuf);
-	    }
-	    if (pager_output("\n"))
-		    break;
-	    	}
-	if (verbose) {
-	    /* XXX could add some formatting smarts here to display some better */
-	    for (md = fp->f_metadata; md != NULL; md = md->md_next) {
-		snprintf(lbuf, sizeof(lbuf), "      0x%04x, 0x%lx\n",
-		    md->md_type, (long) md->md_size);
+		pager_output(fp->f_name);
+		snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type,
+		  (long)fp->f_size);
 		if (pager_output(lbuf))
 			break;
-	    }
+		if (fp->f_args != NULL) {
+			pager_output("    args: ");
+			pager_output(fp->f_args);
+			if (pager_output("\n"))
+				break;
+		}
+		if (fp->f_modules) {
+			pager_output("  modules: ");
+			for (mp = fp->f_modules; mp; mp = mp->m_next) {
+				snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name,
+				  mp->m_version);
+				pager_output(lbuf);
+			}
+			if (pager_output("\n"))
+				break;
+		}
+		if (verbose) {
+			/* XXX could add some formatting smarts here to display some better */
+			for (md = fp->f_metadata; md != NULL; md = md->md_next) {
+				snprintf(lbuf, sizeof(lbuf), "      0x%04x, 0x%lx\n",
+				  md->md_type, (long) md->md_size);
+				if (pager_output(lbuf))
+					break;
+			}
+		}
+		if (ret)
+			break;
 	}
-	if (ret)
-	    break;
-    }
-    pager_close();
-    return(CMD_OK);
+	pager_close();
+	return(CMD_OK);
 }
 
 /*
@@ -347,86 +347,86 @@ command_lsmod(int argc, char *argv[])
 int
 file_load(char *filename, vm_offset_t dest, struct preloaded_file **result)
 {
-    static int last_file_format = 0;
-    struct preloaded_file *fp;
-    int error;
-    int i;
+	static int last_file_format = 0;
+	struct preloaded_file *fp;
+	int error;
+	int i;
 
-    if (archsw.arch_loadaddr != NULL)
-	dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest);
+	if (archsw.arch_loadaddr != NULL)
+		dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest);
 
-    error = EFTYPE;
-    for (i = last_file_format, fp = NULL;
-	file_formats[i] && fp == NULL; i++) {
-	error = (file_formats[i]->l_load)(filename, dest, &fp);
-	if (error == 0) {
-	    fp->f_loader = last_file_format = i; /* remember the loader */
-	    *result = fp;
-	    break;
-	} else if (last_file_format == i && i != 0) {
-	    /* Restart from the beginning */
-	    i = -1;
-	    last_file_format = 0;
-	    fp = NULL;
-	    continue;
+	error = EFTYPE;
+	for (i = last_file_format, fp = NULL;
+	     file_formats[i] && fp == NULL; i++) {
+		error = (file_formats[i]->l_load)(filename, dest, &fp);
+		if (error == 0) {
+			fp->f_loader = last_file_format = i; /* remember the loader */
+			*result = fp;
+			break;
+		} else if (last_file_format == i && i != 0) {
+			/* Restart from the beginning */
+			i = -1;
+			last_file_format = 0;
+			fp = NULL;
+			continue;
+		}
+		if (error == EFTYPE)
+			continue;		/* Unknown to this handler? */
+		if (error) {
+			snprintf(command_errbuf, sizeof(command_errbuf),
+			  "can't load file '%s': %s", filename, strerror(error));
+			break;
+		}
 	}
-	if (error == EFTYPE)
-	    continue;		/* Unknown to this handler? */
-	if (error) {
-	    snprintf(command_errbuf, sizeof(command_errbuf),
-		"can't load file '%s': %s", filename, strerror(error));
-	    break;
-	}
-    }
-    return (error);
+	return (error);
 }
 
 static int
 file_load_dependencies(struct preloaded_file *base_file)
 {
-    struct file_metadata *md;
-    struct preloaded_file *fp;
-    struct mod_depend *verinfo;
-    struct kernel_module *mp;
-    char *dmodname;
-    int error;
+	struct file_metadata *md;
+	struct preloaded_file *fp;
+	struct mod_depend *verinfo;
+	struct kernel_module *mp;
+	char *dmodname;
+	int error;
 
-    md = file_findmetadata(base_file, MODINFOMD_DEPLIST);
-    if (md == NULL)
-	return (0);
-    error = 0;
-    do {
-	verinfo = (struct mod_depend*)md->md_data;
-	dmodname = (char *)(verinfo + 1);
-	if (file_findmodule(NULL, dmodname, verinfo) == NULL) {
-	    printf("loading required module '%s'\n", dmodname);
-	    error = mod_load(dmodname, verinfo, 0, NULL);
-	    if (error)
-		break;
-	    /*
-	     * If module loaded via kld name which isn't listed
-	     * in the linker.hints file, we should check if it have
-	     * required version.
-	     */
-	    mp = file_findmodule(NULL, dmodname, verinfo);
-	    if (mp == NULL) {
-		snprintf(command_errbuf, sizeof(command_errbuf),
-		    "module '%s' exists but with wrong version", dmodname);
-		error = ENOENT;
-		break;
-	    }
+	md = file_findmetadata(base_file, MODINFOMD_DEPLIST);
+	if (md == NULL)
+		return (0);
+	error = 0;
+	do {
+		verinfo = (struct mod_depend*)md->md_data;
+		dmodname = (char *)(verinfo + 1);
+		if (file_findmodule(NULL, dmodname, verinfo) == NULL) {
+			printf("loading required module '%s'\n", dmodname);
+			error = mod_load(dmodname, verinfo, 0, NULL);
+			if (error)
+				break;
+			/*
+			 * If module loaded via kld name which isn't listed
+			 * in the linker.hints file, we should check if it have
+			 * required version.
+			 */
+			mp = file_findmodule(NULL, dmodname, verinfo);
+			if (mp == NULL) {
+				snprintf(command_errbuf, sizeof(command_errbuf),
+				  "module '%s' exists but with wrong version", dmodname);
+				error = ENOENT;
+				break;
+			}
+		}
+		md = metadata_next(md, MODINFOMD_DEPLIST);
+	} while (md);
+	if (!error)
+		return (0);
+	/* Load failed; discard everything */
+	while (base_file != NULL) {
+		fp = base_file;
+		base_file = base_file->f_next;
+		file_discard(fp);
 	}
-	md = metadata_next(md, MODINFOMD_DEPLIST);
-    } while (md);
-    if (!error)
-	return (0);
-    /* Load failed; discard everything */
-    while (base_file != NULL) {
-        fp = base_file;
-        base_file = base_file->f_next;
-        file_discard(fp);
-    }
-    return (error);
+	return (error);
 }
 
 /*
@@ -436,82 +436,82 @@ file_load_dependencies(struct preloaded_file *base_fil
 struct preloaded_file *
 file_loadraw(const char *fname, char *type, int insert)
 {
-    struct preloaded_file	*fp;
-    char			*name;
-    int				fd, got;
-    vm_offset_t			laddr;
+	struct preloaded_file	*fp;
+	char			*name;
+	int				fd, got;
+	vm_offset_t			laddr;
 
-    /* We can't load first */
-    if ((file_findfile(NULL, NULL)) == NULL) {
-	command_errmsg = "can't load file before kernel";
-	return(NULL);
-    }
+	/* We can't load first */
+	if ((file_findfile(NULL, NULL)) == NULL) {
+		command_errmsg = "can't load file before kernel";
+		return(NULL);
+	}
 
-    /* locate the file on the load path */
-    name = file_search(fname, NULL);
-    if (name == NULL) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "can't find '%s'", fname);
-	return(NULL);
-    }
+	/* locate the file on the load path */
+	name = file_search(fname, NULL);
+	if (name == NULL) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "can't find '%s'", fname);
+		return(NULL);
+	}
 
-    if ((fd = open(name, O_RDONLY)) < 0) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "can't open '%s': %s", name, strerror(errno));
-	free(name);
-	return(NULL);
-    }
+	if ((fd = open(name, O_RDONLY)) < 0) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "can't open '%s': %s", name, strerror(errno));
+		free(name);
+		return(NULL);
+	}
 
 #ifdef LOADER_VERIEXEC
-    if (verify_file(fd, name, 0, VE_MUST) < 0) {
-	sprintf(command_errbuf, "can't verify '%s'", name);
-	free(name);
-	close(fd);
-	return(NULL);
-    }
+	if (verify_file(fd, name, 0, VE_MUST) < 0) {
+		sprintf(command_errbuf, "can't verify '%s'", name);
+		free(name);
+		close(fd);
+		return(NULL);
+	}
 #endif
 
-    if (archsw.arch_loadaddr != NULL)
-	loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr);
+	if (archsw.arch_loadaddr != NULL)
+		loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr);
 
-    printf("%s ", name);
+	printf("%s ", name);
 
-    laddr = loadaddr;
-    for (;;) {
-	/* read in 4k chunks; size is not really important */
-	got = archsw.arch_readin(fd, laddr, 4096);
-	if (got == 0)				/* end of file */
-	    break;
-	if (got < 0) {				/* error */
-	    snprintf(command_errbuf, sizeof(command_errbuf),
-		"error reading '%s': %s", name, strerror(errno));
-	    free(name);
-	    close(fd);
-	    return(NULL);
+	laddr = loadaddr;
+	for (;;) {
+		/* read in 4k chunks; size is not really important */
+		got = archsw.arch_readin(fd, laddr, 4096);
+		if (got == 0)				/* end of file */
+			break;
+		if (got < 0) {				/* error */
+			snprintf(command_errbuf, sizeof(command_errbuf),
+			  "error reading '%s': %s", name, strerror(errno));
+			free(name);
+			close(fd);
+			return(NULL);
+		}
+		laddr += got;
 	}
-	laddr += got;
-    }
 
-    printf("size=%#jx\n", (uintmax_t)(laddr - loadaddr));
+	printf("size=%#jx\n", (uintmax_t)(laddr - loadaddr));
 
-    /* Looks OK so far; create & populate control structure */
-    fp = file_alloc();
-    fp->f_name = strdup(name);
-    fp->f_type = strdup(type);
-    fp->f_args = NULL;
-    fp->f_metadata = NULL;
-    fp->f_loader = -1;
-    fp->f_addr = loadaddr;
-    fp->f_size = laddr - loadaddr;
+	/* Looks OK so far; create & populate control structure */
+	fp = file_alloc();
+	fp->f_name = strdup(name);
+	fp->f_type = strdup(type);
+	fp->f_args = NULL;
+	fp->f_metadata = NULL;
+	fp->f_loader = -1;
+	fp->f_addr = loadaddr;
+	fp->f_size = laddr - loadaddr;
 
-    /* recognise space consumption */
-    loadaddr = laddr;
+	/* recognise space consumption */
+	loadaddr = laddr;
 
-    /* Add to the list of loaded files */
-    if (insert != 0)
-    	file_insert_tail(fp);
-    close(fd);
-    return(fp);
+	/* Add to the list of loaded files */
+	if (insert != 0)
+		file_insert_tail(fp);
+	close(fd);
+	return(fp);
 }
 
 /*
@@ -522,35 +522,35 @@ file_loadraw(const char *fname, char *type, int insert
 int
 mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[])
 {
-    struct kernel_module	*mp;
-    int				err;
-    char			*filename;
+	struct kernel_module	*mp;
+	int				err;
+	char			*filename;
 
-    if (file_havepath(modname)) {
-	printf("Warning: mod_load() called instead of mod_loadkld() for module '%s'\n", modname);
-	return (mod_loadkld(modname, argc, argv));
-    }
-    /* see if module is already loaded */
-    mp = file_findmodule(NULL, modname, verinfo);
-    if (mp) {
+	if (file_havepath(modname)) {
+		printf("Warning: mod_load() called instead of mod_loadkld() for module '%s'\n", modname);
+		return (mod_loadkld(modname, argc, argv));
+	}
+	/* see if module is already loaded */
+	mp = file_findmodule(NULL, modname, verinfo);
+	if (mp) {
 #ifdef moduleargs
-	if (mp->m_args)
-	    free(mp->m_args);
-	mp->m_args = unargv(argc, argv);
+		if (mp->m_args)
+			free(mp->m_args);
+		mp->m_args = unargv(argc, argv);
 #endif
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "warning: module '%s' already loaded", mp->m_name);
-	return (0);
-    }
-    /* locate file with the module on the search path */
-    filename = mod_searchmodule(modname, verinfo);
-    if (filename == NULL) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "can't find '%s'", modname);
-	return (ENOENT);
-    }
-    err = mod_loadkld(filename, argc, argv);
-    return (err);
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "warning: module '%s' already loaded", mp->m_name);
+		return (0);
+	}
+	/* locate file with the module on the search path */
+	filename = mod_searchmodule(modname, verinfo);
+	if (filename == NULL) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "can't find '%s'", modname);
+		return (ENOENT);
+	}
+	err = mod_loadkld(filename, argc, argv);
+	return (err);
 }
 
 /*
@@ -560,57 +560,57 @@ mod_load(char *modname, struct mod_depend *verinfo, in
 int
 mod_loadkld(const char *kldname, int argc, char *argv[])
 {
-    struct preloaded_file	*fp, *last_file;
-    int				err;
-    char			*filename;
+	struct preloaded_file	*fp, *last_file;
+	int				err;
+	char			*filename;
 
-    /*
-     * Get fully qualified KLD name
-     */
-    filename = file_search(kldname, kld_ext_list);
-    if (filename == NULL) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "can't find '%s'", kldname);
-	return (ENOENT);
-    }
-    /*
-     * Check if KLD already loaded
-     */
-    fp = file_findfile(filename, NULL);
-    if (fp) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "warning: KLD '%s' already loaded", filename);
-	free(filename);
-	return (0);
-    }
-    for (last_file = preloaded_files;
-	 last_file != NULL && last_file->f_next != NULL;
-	 last_file = last_file->f_next)
-	;
+	/*
+	 * Get fully qualified KLD name
+	 */
+	filename = file_search(kldname, kld_ext_list);
+	if (filename == NULL) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "can't find '%s'", kldname);
+		return (ENOENT);
+	}
+	/*
+	 * Check if KLD already loaded
+	 */
+	fp = file_findfile(filename, NULL);
+	if (fp) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "warning: KLD '%s' already loaded", filename);
+		free(filename);
+		return (0);
+	}
+	for (last_file = preloaded_files;
+	     last_file != NULL && last_file->f_next != NULL;
+	     last_file = last_file->f_next)
+		;
 
-    do {
-	err = file_load(filename, loadaddr, &fp);
-	if (err)
-	    break;
-	fp->f_args = unargv(argc, argv);
-	loadaddr = fp->f_addr + fp->f_size;
-	file_insert_tail(fp);		/* Add to the list of loaded files */
-	if (file_load_dependencies(fp) != 0) {
-	    err = ENOENT;
-	    last_file->f_next = NULL;
-	    loadaddr = last_file->f_addr + last_file->f_size;
-	    fp = NULL;
-	    break;
+	do {
+		err = file_load(filename, loadaddr, &fp);
+		if (err)
+			break;
+		fp->f_args = unargv(argc, argv);
+		loadaddr = fp->f_addr + fp->f_size;
+		file_insert_tail(fp);		/* Add to the list of loaded files */
+		if (file_load_dependencies(fp) != 0) {
+			err = ENOENT;
+			last_file->f_next = NULL;
+			loadaddr = last_file->f_addr + last_file->f_size;
+			fp = NULL;
+			break;
+		}
+	} while(0);
+	if (err == EFTYPE) {
+		snprintf(command_errbuf, sizeof(command_errbuf),
+		  "don't know how to load module '%s'", filename);
 	}
-    } while(0);
-    if (err == EFTYPE) {
-	snprintf(command_errbuf, sizeof(command_errbuf),
-	    "don't know how to load module '%s'", filename);
-    }
-    if (err && fp)
-	file_discard(fp);
-    free(filename);
-    return (err);
+	if (err && fp)
+		file_discard(fp);
+	free(filename);
+	return (err);
 }
 
 /*
@@ -620,14 +620,14 @@ mod_loadkld(const char *kldname, int argc, char *argv[
 struct preloaded_file *
 file_findfile(const char *name, const char *type)
 {
-    struct preloaded_file *fp;
+	struct preloaded_file *fp;
 
-    for (fp = preloaded_files; fp != NULL; fp = fp->f_next) {
-	if (((name == NULL) || !strcmp(name, fp->f_name)) &&
-	    ((type == NULL) || !strcmp(type, fp->f_type)))
-	    break;
-    }
-    return (fp);
+	for (fp = preloaded_files; fp != NULL; fp = fp->f_next) {
+		if (((name == NULL) || !strcmp(name, fp->f_name)) &&
+		  ((type == NULL) || !strcmp(type, fp->f_type)))
+			break;
+	}
+	return (fp);
 }
 
 /*
@@ -638,35 +638,35 @@ struct kernel_module *
 file_findmodule(struct preloaded_file *fp, char *modname,
 	struct mod_depend *verinfo)
 {
-    struct kernel_module *mp, *best;
-    int bestver, mver;
+	struct kernel_module *mp, *best;
+	int bestver, mver;
 
-    if (fp == NULL) {
-	for (fp = preloaded_files; fp; fp = fp->f_next) {
-	    mp = file_findmodule(fp, modname, verinfo);
-	    if (mp)
-		return (mp);
+	if (fp == NULL) {
+		for (fp = preloaded_files; fp; fp = fp->f_next) {
+			mp = file_findmodule(fp, modname, verinfo);
+			if (mp)
+				return (mp);
+		}
+		return (NULL);
 	}
-	return (NULL);
-    }
-    best = NULL;
-    bestver = 0;
-    for (mp = fp->f_modules; mp; mp = mp->m_next) {
-        if (strcmp(modname, mp->m_name) == 0) {
-	    if (verinfo == NULL)
-		return (mp);
-	    mver = mp->m_version;
-	    if (mver == verinfo->md_ver_preferred)
-		return (mp);
-	    if (mver >= verinfo->md_ver_minimum &&
-		mver <= verinfo->md_ver_maximum &&
-		mver > bestver) {
-		best = mp;
-		bestver = mver;
-	    }
+	best = NULL;
+	bestver = 0;
+	for (mp = fp->f_modules; mp; mp = mp->m_next) {
+		if (strcmp(modname, mp->m_name) == 0) {
+			if (verinfo == NULL)
+				return (mp);
+			mver = mp->m_version;
+			if (mver == verinfo->md_ver_preferred)
+				return (mp);
+			if (mver >= verinfo->md_ver_minimum &&
+			  mver <= verinfo->md_ver_maximum &&
+			  mver > bestver) {
+				best = mp;
+				bestver = mver;
+			}
+		}
 	}
-    }
-    return (best);
+	return (best);
 }
 /*
  * Make a copy of (size) bytes of data from (p), and associate them as
@@ -675,14 +675,14 @@ file_findmodule(struct preloaded_file *fp, char *modna
 void
 file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p)
 {
-    struct file_metadata	*md;
+	struct file_metadata	*md;
 
-    md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size);
-    md->md_size = size;
-    md->md_type = type;
-    bcopy(p, md->md_data, size);
-    md->md_next = fp->f_metadata;
-    fp->f_metadata = md;
+	md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size);
+	md->md_size = size;
+	md->md_type = type;
+	bcopy(p, md->md_data, size);
+	md->md_next = fp->f_metadata;
+	fp->f_metadata = md;
 }
 
 /*
@@ -691,12 +691,12 @@ file_addmetadata(struct preloaded_file *fp, int type, 
 struct file_metadata *
 file_findmetadata(struct preloaded_file *fp, int type)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910240233.x9O2XvF8087485>