summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorSean Farley <scf@FreeBSD.org>2008-11-11 00:32:55 +0000
committerSean Farley <scf@FreeBSD.org>2008-11-11 00:32:55 +0000
commit83c1d785dfb8bceaad5d4f1b9ce2f7cd4cb802a0 (patch)
tree350312f0e64d51399ee7c9831e89cd9f606e73f2 /libutil
parent8ca37caf8521740d66c31267b139610af0413b66 (diff)
downloadpw-darwin-83c1d785dfb8bceaad5d4f1b9ce2f7cd4cb802a0.tar.gz
pw-darwin-83c1d785dfb8bceaad5d4f1b9ce2f7cd4cb802a0.tar.zst
pw-darwin-83c1d785dfb8bceaad5d4f1b9ce2f7cd4cb802a0.zip
style(9) fixes.
MFC after: 1 week
Diffstat (limited to 'libutil')
-rw-r--r--libutil/gr_util.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/libutil/gr_util.c b/libutil/gr_util.c
index 89f5fa3..fc5e442 100644
--- a/libutil/gr_util.c
+++ b/libutil/gr_util.c
@@ -28,29 +28,27 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+
#include <grp.h>
#include <inttypes.h>
+#include <libutil.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <libutil.h>
-
-
static const char GroupLineFormat[] = "%s:%s:%ju:";
-
/*
* Compares two struct group's.
*/
int
gr_equal(const struct group *gr1, const struct group *gr2)
{
- bool found;
- bool equal;
int gr1Ndx;
int gr2Ndx;
+ bool equal;
+ bool found;
/* Check that the non-member information is the same. */
equal = strcmp(gr1->gr_name, gr2->gr_name) == 0 &&
@@ -81,7 +79,6 @@ gr_equal(const struct group *gr1, const struct group *gr2)
return (equal);
}
-
/*
* Make a group line out of a struct group.
*/
@@ -89,8 +86,8 @@ char *
gr_make(const struct group *gr)
{
char *line;
- int ndx;
size_t lineSize;
+ int ndx;
/* Calculate the length of the group line. */
lineSize = snprintf(NULL, 0, GroupLineFormat, gr->gr_name,
@@ -114,17 +111,16 @@ gr_make(const struct group *gr)
return (line);
}
-
/*
* Duplicate a struct group.
*/
struct group *
gr_dup(const struct group *gr)
{
- int ndx;
- int numMem;
size_t len;
struct group *ngr;
+ int ndx;
+ int numMem;
/* Calculate size of group. */
len = sizeof(*gr) +
@@ -134,7 +130,7 @@ gr_dup(const struct group *gr)
if (gr->gr_mem != NULL) {
for (; gr->gr_mem[numMem] != NULL; numMem++)
len += strlen(gr->gr_mem[numMem]) + 1;
- len += (numMem + 1) * sizeof(*(gr->gr_mem));
+ len += (numMem + 1) * sizeof(*gr->gr_mem);
}
/* Create new group and copy old group into it. */
@@ -152,7 +148,7 @@ gr_dup(const struct group *gr)
}
if (gr->gr_mem != NULL) {
ngr->gr_mem = (char **)((char *)ngr + len);
- len += (numMem + 1) * sizeof(*(ngr->gr_mem));
+ len += (numMem + 1) * sizeof(*ngr->gr_mem);
for (ndx = 0; gr->gr_mem[ndx] != NULL; ndx++) {
ngr->gr_mem[ndx] = (char *)ngr + len;
len += sprintf(ngr->gr_mem[ndx], "%s",
@@ -164,7 +160,6 @@ gr_dup(const struct group *gr)
return (ngr);
}
-
/*
* Scan a line and place it into a group structure.
*/
@@ -180,14 +175,14 @@ __gr_scan(char *line, struct group *gr)
return (false);
*loc = '\0';
gr->gr_passwd = loc + 1;
- if (*(gr->gr_passwd) == ':')
- *(gr->gr_passwd) = '\0';
+ if (*gr->gr_passwd == ':')
+ *gr->gr_passwd = '\0';
else {
if ((loc = strchr(loc + 1, ':')) == NULL)
return (false);
*loc = '\0';
}
- if (sscanf(loc + 1, "%u", &(gr->gr_gid)) != 1)
+ if (sscanf(loc + 1, "%u", &gr->gr_gid) != 1)
return (false);
/* Assign member information to structure. */
@@ -199,7 +194,7 @@ __gr_scan(char *line, struct group *gr)
ndx = 0;
do {
if ((gr->gr_mem = reallocf(gr->gr_mem,
- sizeof(*(gr->gr_mem)) * (ndx + 1))) == NULL)
+ sizeof(*gr->gr_mem) * (ndx + 1))) == NULL)
return (false);
gr->gr_mem[ndx] = strsep(&line, ",");
} while (gr->gr_mem[ndx++] != NULL);
@@ -208,16 +203,15 @@ __gr_scan(char *line, struct group *gr)
return (true);
}
-
/*
* Create a struct group from a line.
*/
struct group *
gr_scan(const char *line)
{
+ struct group gr;
char *lineCopy;
struct group *newGr;
- struct group gr;
if ((lineCopy = strdup(line)) == NULL)
return (NULL);