summaryrefslogtreecommitdiffstats
path: root/freebsd/lib/libc/rpc/getnetconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/lib/libc/rpc/getnetconfig.c')
-rw-r--r--freebsd/lib/libc/rpc/getnetconfig.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/freebsd/lib/libc/rpc/getnetconfig.c b/freebsd/lib/libc/rpc/getnetconfig.c
index f6279e04..bc3bc7ef 100644
--- a/freebsd/lib/libc/rpc/getnetconfig.c
+++ b/freebsd/lib/libc/rpc/getnetconfig.c
@@ -149,7 +149,7 @@ nc_key_init(void)
#define MAXNETCONFIGLINE 1000
static int *
-__nc_error()
+__nc_error(void)
{
static int nc_error = 0;
int *nc_addr;
@@ -166,8 +166,7 @@ __nc_error()
if ((nc_addr = (int *)thr_getspecific(nc_key)) == NULL) {
nc_addr = (int *)malloc(sizeof (int));
if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
- if (nc_addr)
- free(nc_addr);
+ free(nc_addr);
return (&nc_error);
}
*nc_addr = 0;
@@ -196,7 +195,7 @@ __nc_error()
* the netconfig database is not present).
*/
void *
-setnetconfig()
+setnetconfig(void)
{
struct netconfig_vars *nc_vars;
@@ -242,8 +241,7 @@ setnetconfig()
*/
struct netconfig *
-getnetconfig(handlep)
-void *handlep;
+getnetconfig(void *handlep)
{
struct netconfig_vars *ncp = (struct netconfig_vars *)handlep;
char *stringp; /* tmp string pointer */
@@ -380,8 +378,7 @@ void *handlep;
* previously).
*/
int
-endnetconfig(handlep)
-void *handlep;
+endnetconfig(void *handlep)
{
struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep;
@@ -410,7 +407,7 @@ void *handlep;
}
/*
- * Noone needs these entries anymore, then frees them.
+ * No one needs these entries anymore, then frees them.
* Make sure all info in netconfig_info structure has been reinitialized.
*/
q = ni.head;
@@ -421,7 +418,7 @@ void *handlep;
while (q != NULL) {
p = q->next;
- if (q->ncp->nc_lookups != NULL) free(q->ncp->nc_lookups);
+ free(q->ncp->nc_lookups);
free(q->ncp);
free(q->linep);
free(q);
@@ -446,8 +443,7 @@ void *handlep;
*/
struct netconfig *
-getnetconfigent(netid)
- const char *netid;
+getnetconfigent(const char *netid)
{
FILE *file; /* NETCONFIG db's file pointer */
char *linep; /* holds current netconfig line */
@@ -538,13 +534,11 @@ getnetconfigent(netid)
*/
void
-freenetconfigent(netconfigp)
- struct netconfig *netconfigp;
+freenetconfigent(struct netconfig *netconfigp)
{
if (netconfigp != NULL) {
free(netconfigp->nc_netid); /* holds all netconfigp's strings */
- if (netconfigp->nc_lookups != NULL)
- free(netconfigp->nc_lookups);
+ free(netconfigp->nc_lookups);
free(netconfigp);
}
return;
@@ -560,12 +554,13 @@ freenetconfigent(netconfigp)
* Note that we modify stringp (putting NULLs after tokens) and
* we set the ncp's string field pointers to point to these tokens within
* stringp.
+ *
+ * stringp - string to parse
+ * ncp - where to put results
*/
static int
-parse_ncp(stringp, ncp)
-char *stringp; /* string to parse */
-struct netconfig *ncp; /* where to put results */
+parse_ncp(char *stringp, struct netconfig *ncp)
{
char *tokenp; /* for processing tokens */
char *lasts;
@@ -633,8 +628,7 @@ struct netconfig *ncp; /* where to put results */
} else {
char *cp; /* tmp string */
- if (ncp->nc_lookups != NULL) /* from last visit */
- free(ncp->nc_lookups);
+ free(ncp->nc_lookups); /* from last visit */
ncp->nc_lookups = NULL;
ncp->nc_nlookups = 0;
while ((cp = tokenp) != NULL) {
@@ -657,7 +651,7 @@ struct netconfig *ncp; /* where to put results */
* Returns a string describing the reason for failure.
*/
char *
-nc_sperror()
+nc_sperror(void)
{
const char *message;
@@ -688,8 +682,7 @@ nc_sperror()
* Prints a message onto standard error describing the reason for failure.
*/
void
-nc_perror(s)
- const char *s;
+nc_perror(const char *s)
{
fprintf(stderr, "%s: %s\n", s, nc_sperror());
}
@@ -698,11 +691,10 @@ nc_perror(s)
* Duplicates the matched netconfig buffer.
*/
static struct netconfig *
-dup_ncp(ncp)
-struct netconfig *ncp;
+dup_ncp(struct netconfig *ncp)
{
struct netconfig *p;
- char *tmp;
+ char *tmp, *tmp2;
u_int i;
if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL)
@@ -711,6 +703,7 @@ struct netconfig *ncp;
free(tmp);
return(NULL);
}
+ tmp2 = tmp;
/*
* First we dup all the data from matched netconfig buffer. Then we
* adjust some of the member pointer to a pre-allocated buffer where
@@ -732,6 +725,7 @@ struct netconfig *ncp;
if (p->nc_lookups == NULL) {
free(p->nc_netid);
free(p);
+ free(tmp2);
return(NULL);
}
for (i=0; i < p->nc_nlookups; i++) {