From c9d5afdc0f8c07fde3eb4c16c95f43e3b72b493a Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Feb 2017 00:58:51 +0200 Subject: [PATCH] 8198 acct: misleading-indentation Reviewed by: Marcel Telka Reviewed by: Robert Mustacchi Approved by: Hans Rosenfeld --- usr/src/cmd/acct/lib/devtolin.c | 111 +++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/usr/src/cmd/acct/lib/devtolin.c b/usr/src/cmd/acct/lib/devtolin.c index 16ee0cf0e0..7b970b0d2b 100644 --- a/usr/src/cmd/acct/lib/devtolin.c +++ b/usr/src/cmd/acct/lib/devtolin.c @@ -26,7 +26,6 @@ * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9 */ /* * convert device to linename (as in /dev/linename) @@ -53,75 +52,86 @@ char *strncpy(); dev_t lintodev(); static char dev_dir[] = "/dev"; -static char *def_srch_dirs[] = { "/dev/term", - "/dev/pts", - "/dev/xt", - NULL }; +static char *def_srch_dirs[] = { + "/dev/term", + "/dev/pts", + "/dev/xt", + NULL +}; char file_name[MAX_DEV_PATH]; /* name being returned */ static int srch_dir(); char * -devtolin(device) - dev_t device; +devtolin(dev_t device) { - register struct tlist *tp; + struct tlist *tp; char **srch_dirs; /* priority directories to search first */ int found = 0; int dirno = 0; for (tp = tl; tp < &tl[tsize1]; tp++) if (device == tp->tdev) - return(tp->tname); + return (tp->tname); srch_dirs = def_srch_dirs; - + while ((!found) && (srch_dirs[dirno] != NULL)) { - /* if /dev is one of the priority directories we should only - search its top level for now (set depth = MAX_SEARCH_DEPTH) */ + /* + * if /dev is one of the priority directories we should only + * search its top level for now (set depth = MAX_SEARCH_DEPTH) + */ found = srch_dir(device, srch_dirs[dirno], - ((strcmp(srch_dirs[dirno], dev_dir) == 0) ? - MAX_SRCH_DEPTH : 1), - NULL); + ((strcmp(srch_dirs[dirno], dev_dir) == 0) ? + MAX_SRCH_DEPTH : 1), NULL); dirno++; } - /* if not yet found search remaining /dev directory skipping the - priority directories */ + /* + * if not yet found search remaining /dev directory skipping the + * priority directories + */ if (!found) found = srch_dir(device, dev_dir, 0, srch_dirs); - /* if found then put it (without the "/dev/" prefix) in the tlist - structure and return the path name without the "/dev/" prefix */ - + /* + * if found then put it (without the "/dev/" prefix) in the tlist + * structure and return the path name without the "/dev/" prefix + */ + if (found) { if (tsize1 < TSIZE1) { tp->tdev = device; CPYN(tp->tname, file_name+5); tsize1++; } - return(file_name+5); - } else - /* if not found put "?" in the tlist structure for that device and - return "?" */ + return (file_name+5); + } else { + /* + * if not found put "?" in the tlist structure for that device + * and return "?" + */ if (tsize1 < TSIZE1) { tp->tdev = device; CPYN(tp->tname, "?"); tsize1++; } - return("?"); - + } + return ("?"); } +/* + * Arguments: + * device device we are looking for + * path current path + * depth current depth + * skip_dirs directories that don't need searched + */ static int -srch_dir(device, path, depth, skip_dirs) - dev_t device; /* device we are looking for */ - char *path; /* current path */ - int depth; /* current depth */ - char *skip_dirs[]; /* directories that don't need searched */ +srch_dir(dev_t device, char *path, int depth, char *skip_dirs[]) { DIR *fdev; struct dirent *d; @@ -136,13 +146,13 @@ srch_dir(device, path, depth, skip_dirs) if ((skip_dirs != NULL) && (depth != 0)) while (skip_dirs[dirno] != NULL) if (strcmp(skip_dirs[dirno++], path) == 0) - return(0); + return (0); /* open the directory */ if ((fdev = opendir(path)) == NULL) - return(0); + return (0); /* initialize file name using path name */ @@ -153,31 +163,40 @@ srch_dir(device, path, depth, skip_dirs) /* start searching this directory */ - while ((!found) && ((d = readdir(fdev)) != NULL)) + while ((!found) && ((d = readdir(fdev)) != NULL)) { if (d->d_ino != 0) { - /* if name would not be too long append it to - directory name, otherwise skip this entry */ + /* + * if name would not be too long append it to + * directory name, otherwise skip this entry + */ - if ((int) (path_len + strlen(d->d_name) + 2) > MAX_DEV_PATH) + if ((int)(path_len + strlen(d->d_name) + 2) > + MAX_DEV_PATH) continue; else strcpy(last_comp, d->d_name); - /* if this directory entry has the device number we need, - then the name is found. Otherwise if it's a directory - (not . or ..) and we haven't gone too deep, recurse. */ + /* + * if this directory entry has the device number we + * need, then the name is found. Otherwise if it's a + * directory (not . or ..) and we haven't gone too + * deep, recurse. + */ if (lintodev(file_name+5) == device) { found = 1; break; } else if ((depth < MAX_SRCH_DEPTH) && - (strcmp(d->d_name, ".") != 0) && - (strcmp(d->d_name, "..") != 0) && - (stat(file_name, &sb) != -1) && - ((sb.st_mode & S_IFMT) == S_IFDIR)) - found = srch_dir(device, file_name, depth+1, skip_dirs); + (strcmp(d->d_name, ".") != 0) && + (strcmp(d->d_name, "..") != 0) && + (stat(file_name, &sb) != -1) && + ((sb.st_mode & S_IFMT) == S_IFDIR)) { + found = srch_dir(device, file_name, depth+1, + skip_dirs); + } } + } closedir(fdev); - return(found); + return (found); } -- 2.11.4.GIT