loader: cstyle cleanup of userboot/devicename.c

No functional changes intended.

MFC after:	1 week
This commit is contained in:
Toomas Soome 2021-08-11 10:07:28 +03:00
parent bed2ac27a1
commit 5d5a621664

View File

@ -38,7 +38,8 @@ __FBSDID("$FreeBSD$");
#include "libzfs.h"
#endif
static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path);
static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec,
const char **path);
/*
* Point (dev) at an allocated device specifier for the device matching the
@ -59,16 +60,16 @@ userboot_getdev(void **vdev, const char *devspec, const char **path)
(devspec[0] == '/') ||
(strchr(devspec, ':') == NULL)) {
if (((rv = userboot_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
(path != NULL))
rv = userboot_parsedev(dev, getenv("currdev"), NULL);
if (rv == 0 && path != NULL)
*path = devspec;
return(rv);
return (rv);
}
/*
* Try to parse the device name off the beginning of the devspec
*/
return(userboot_parsedev(dev, devspec, path));
return (userboot_parsedev(dev, devspec, path));
}
/*
@ -86,7 +87,8 @@ userboot_getdev(void **vdev, const char *devspec, const char **path)
*
*/
static int
userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path)
userboot_parsedev(struct disk_devdesc **dev, const char *devspec,
const char **path)
{
struct disk_devdesc *idev;
struct devsw *dv;
@ -96,22 +98,23 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p
/* minimum length check */
if (strlen(devspec) < 2)
return(EINVAL);
return (EINVAL);
/* look for a device that matches */
for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) {
if (strncmp(devspec, devsw[i]->dv_name,
strlen(devsw[i]->dv_name)) == 0) {
dv = devsw[i];
break;
}
}
if (dv == NULL)
return(ENOENT);
return (ENOENT);
idev = malloc(sizeof(struct disk_devdesc));
err = 0;
np = (devspec + strlen(dv->dv_name));
switch(dv->dv_type) {
switch (dv->dv_type) {
case DEVT_NONE: /* XXX what to do here? Do we care? */
break;
@ -126,7 +129,8 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p
unit = 0;
if (*np && (*np != ':')) {
unit = strtol(np, (char **)&cp, 0); /* get unit number if present */
/* get unit number if present */
unit = strtol(np, (char **)&cp, 0);
if (cp == np) {
err = EUNIT;
goto fail;
@ -164,11 +168,11 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p
} else {
*dev = idev;
}
return(0);
return (0);
fail:
fail:
free(idev);
return(err);
return (err);
}
@ -202,7 +206,7 @@ userboot_fmtdev(void *vdev)
#endif
break;
}
return(buf);
return (buf);
}
@ -216,8 +220,8 @@ userboot_setcurrdev(struct env_var *ev, int flags, const void *value)
int rv;
if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0)
return(rv);
return (rv);
free(ncurr);
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
return(0);
return (0);
}