PERFORCE change 77745 for review

Robert Watson rwatson at FreeBSD.org
Mon May 30 22:15:20 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=77745

Change 77745 by rwatson at rwatson_paprika on 2005/05/30 22:15:07

	Converge on BSD style(9).

Affected files ...

.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#3 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#3 (text+ko) ====

@@ -34,238 +34,216 @@
 #include <libbsm.h>
 
 /*
- * Parse the contents of the audit_class file to return
- * struct au_class_ent entries
+ * Parse the contents of the audit_class file to return struct au_class_ent
+ * entries.
  */
-static FILE *fp = NULL;
-static char linestr[AU_LINE_MAX];
-static char *delim = ":";
+static FILE	*fp = NULL;
+static char	linestr[AU_LINE_MAX];
+static char	*delim = ":";
 
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t	mutex = PTHREAD_MUTEX_INITIALIZER;
 
-
 /*
  * XXX The reentrant versions of the following functions is TBD
  * XXX struct au_class_ent *getclassent_r(au_class_ent_t *class_int);
  * XXX struct au_class_ent *getclassnam_r(au_class_ent_t *class_int, const char *name);
  */
 
-
-
 /*
- * Allocate a au_class_ent structure
+ * Allocate a au_class_ent structure.
  */
-static struct au_class_ent *get_class_area()
+static struct au_class_ent *
+get_class_area(void)
 {
 	struct au_class_ent *c;
 
-	c = (struct au_class_ent *) malloc (sizeof(struct au_class_ent));
-	if(c == NULL) {
-		return NULL;
-	}
-	c->ac_name = (char *)malloc(AU_CLASS_NAME_MAX * sizeof(char));
-	if(c->ac_name == NULL) {
+	c = malloc(sizeof(struct au_class_ent));
+	if (c == NULL)
+		return (NULL);
+	c->ac_name = malloc(AU_CLASS_NAME_MAX * sizeof(char));
+	if (c->ac_name == NULL) {
 		free(c);
-		return NULL;
+		return (NULL);
 	}
-	c->ac_desc = (char *)malloc(AU_CLASS_DESC_MAX * sizeof(char));
-	if(c->ac_desc == NULL) {
+	c->ac_desc = malloc(AU_CLASS_DESC_MAX * sizeof(char));
+	if (c->ac_desc == NULL) {
 		free(c->ac_name);
 		free(c);
-		return NULL;
+		return (NULL);
 	}
 
-	return c;
+	return (c);
 }
 
 
 /*
- * Free the au_class_ent structure
+ * Free the au_class_ent structure.
  */
-void free_au_class_ent(struct au_class_ent *c)
+void
+free_au_class_ent(struct au_class_ent *c)
 {
-    if (c)
-    {
-	if (c->ac_name)
-	    free(c->ac_name);
-	if (c->ac_desc)
-	    free(c->ac_desc);
-	free(c);
-    }
+
+	if (c) {
+		if (c->ac_name)
+			free(c->ac_name);
+		if (c->ac_desc)
+			free(c->ac_desc);
+		free(c);
+	}
 }
 
 /*
- * Parse a single line from the audit_class file passed in str
- * to the struct au_class_ent elements; store the result in c
+ * Parse a single line from the audit_class file passed in str to the struct
+ * au_class_ent elements; store the result in c.
  */
-static struct au_class_ent *classfromstr(char *str, char *delim, struct au_class_ent *c)
+static struct au_class_ent *
+classfromstr(char *str, char *delim, struct au_class_ent *c)
 {
 	char *classname, *classdesc, *classflag;
 	char *last;
 
-	/* each line contains flag:name:desc */
+	/* Each line contains flag:name:desc. */
 	classflag = strtok_r(str, delim, &last);
 	classname = strtok_r(NULL, delim, &last);
 	classdesc = strtok_r(NULL, delim, &last);
 
-	if((classflag == NULL)
-		|| (classname == NULL)
-		|| (classdesc == NULL)) {
-
-		return NULL;
-	}
+	if ((classflag == NULL) || (classname == NULL) || (classdesc == NULL))
+		return (NULL);
 
 	/*
-	 * Check for very large classnames
+	 * Check for very large classnames.
 	 */
-	if(strlen(classname) >= AU_CLASS_NAME_MAX) {
-		return NULL;
-	}
+	if (strlen(classname) >= AU_CLASS_NAME_MAX)
+		return (NULL);
 
 	strcpy(c->ac_name, classname);
 
 	/*
-	 * Check for very large class description
+	 * Check for very large class description.
 	 */
-	if(strlen(classdesc) >= AU_CLASS_DESC_MAX) {
-		return NULL;
-	}
+	if (strlen(classdesc) >= AU_CLASS_DESC_MAX)
+		return (NULL);
 	strcpy(c->ac_desc, classdesc);
-
 	c->ac_class = strtoul(classflag, (char **) NULL, 0);
 
-	return c;
+	return (c);
 }
 
 /*
- * Return the next au_class_ent structure from the file
- * setauclass should be called before invoking this function
- * for the first time
+ * Return the next au_class_ent structure from the file setauclass should be
+ * called before invoking this function for the first time.
  */
-struct au_class_ent *getauclassent()
+struct au_class_ent *
+getauclassent(void)
 {
 	struct au_class_ent *c;
 	char *tokptr, *nl;
 
 	pthread_mutex_lock(&mutex);
 
-	if((fp == NULL)
-		&& ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) {
-
+	if ((fp == NULL) && ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) {
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
 
-	if(fgets(linestr, AU_LINE_MAX, fp) == NULL) {
-
+	if (fgets(linestr, AU_LINE_MAX, fp) == NULL) {
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
-	/* Remove trailing new line character */
-	if((nl = strrchr(linestr, '\n')) != NULL) {
+	/* Remove trailing new line character. */
+	if ((nl = strrchr(linestr, '\n')) != NULL)
 		*nl = '\0';
-	}
 
 	tokptr = linestr;
 
 	c = get_class_area(); /* allocate */
-	if(c == NULL) {
-
+	if (c == NULL) {
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
 
-	/* parse tokptr to au_class_ent components */
-	if(classfromstr(tokptr, delim, c) == NULL) {
-
+	/* Parse tokptr to au_class_ent components. */
+	if (classfromstr(tokptr, delim, c) == NULL) {
 		free_au_class_ent(c);
-
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
 
 	pthread_mutex_unlock(&mutex);
-	return c;
+	return (c);
 }
 
 /*
- * Return the next au_class_entry having the given class name
+ * Return the next au_class_entry having the given class name.
  */
-struct au_class_ent *getauclassnam(const char *name)
+struct au_class_ent *
+getauclassnam(const char *name)
 {
 	struct au_class_ent *c;
 	char *nl;
 
-	if(name == NULL) {
-		return NULL;
-	}
+	if (name == NULL)
+		return (NULL);
 
-	/* Rewind to beginning of file */
+	/* Rewind to beginning of file. */
 	setauclass();
 
 	pthread_mutex_lock(&mutex);
 
-	if((fp == NULL)
-		&& ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) {
-
+	if ((fp == NULL) && ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) {
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
 
 	c = get_class_area(); /* allocate */
-	if(c == NULL) {
-
+	if (c == NULL) {
 		pthread_mutex_unlock(&mutex);
-		return NULL;
+		return (NULL);
 	}
+
 	while(fgets(linestr, AU_LINE_MAX, fp) != NULL) {
 		/* Remove trailing new line character */
-		if((nl = strrchr(linestr, '\n')) != NULL) {
+		if ((nl = strrchr(linestr, '\n')) != NULL)
 			*nl = '\0';
-		}
 
 		/* parse tokptr to au_class_ent components */
-		if(classfromstr(linestr, delim, c) != NULL) {
-			if(!strcmp(name, c->ac_name)) {
-
+		if (classfromstr(linestr, delim, c) != NULL) {
+			if (!strcmp(name, c->ac_name)) {
 				pthread_mutex_unlock(&mutex);
-				return c;
+				return (c);
 			}
 		}
 	}
 
 	free_au_class_ent(c);
-
 	pthread_mutex_unlock(&mutex);
-	return NULL;
+	return (NULL);
 
 }
 
 /*
- * Rewind to the beginning of the enumeration
+ * Rewind to the beginning of the enumeration.
  */
-void setauclass()
+void
+setauclass(void)
 {
+
 	pthread_mutex_lock(&mutex);
-
-	if(fp != NULL) {
+	if (fp != NULL)
 		fseek(fp, 0, SEEK_SET);
-	}
-
 	pthread_mutex_unlock(&mutex);
 }
 
 /*
- * audit_class processing is complete; close any open files
+ * audit_class processing is complete; close any open files.
  */
-void endauclass()
+void endauclass(void)
 {
+
 	pthread_mutex_lock(&mutex);
-
-	if(fp != NULL) {
+	if (fp != NULL) {
 		fclose(fp);
 		fp = NULL;
 	}
-
 	pthread_mutex_unlock(&mutex);
 }
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list