PERFORCE change 149213 for review

Stacey Son sson at FreeBSD.org
Thu Sep 4 17:34:23 UTC 2008


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

Change 149213 by sson at sson_amd64 on 2008/09/04 17:33:54

	Various gcc warning (-Wall -Wextra) fixes.

Affected files ...

.. //depot/projects/trustedbsd/openbsm/bin/auditfilterd/auditfilterd.c#12 edit
.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#22 edit
.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#55 edit
.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#15 edit
.. //depot/projects/trustedbsd/openbsm/modules/auditfilter_noop/auditfilter_noop.c#5 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/bin/auditfilterd/auditfilterd.c#12 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/bin/auditfilterd/auditfilterd.c#11 $
+ * $P4: //depot/projects/trustedbsd/openbsm/bin/auditfilterd/auditfilterd.c#12 $
  */
 
 /*
@@ -216,7 +216,7 @@
  * from a file stream.
  */
 static void
-mainloop_pipe(const char *conffile, const char *pipefile, int pipe_fd)
+mainloop_pipe(const char *conffile, const char *pipefile __unused, int pipe_fd)
 {
 	u_char record[MAX_AUDIT_RECORD_SIZE];
 	struct timespec ts;

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#22 (text+ko) ====

@@ -27,7 +27,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#21 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#22 $
  */
 
 #include <config/config.h>
@@ -367,7 +367,7 @@
 		pthread_mutex_unlock(&mutex);
 		return (-1);
 	}
-	if (strlen(dir) >= len) {
+	if (strlen(dir) >= (size_t)len) {
 		pthread_mutex_unlock(&mutex);
 		return (-3);
 	}
@@ -457,7 +457,7 @@
 		pthread_mutex_unlock(&mutex);
 		return (1);
 	}
-	if (strlen(str) >= len) {
+	if (strlen(str) >= (size_t)len) {
 		pthread_mutex_unlock(&mutex);
 		return (-3);
 	}
@@ -484,7 +484,7 @@
 		pthread_mutex_unlock(&mutex);
 		return (1);
 	}
-	if (strlen(str) >= len) {
+	if (strlen(str) >= (size_t)len) {
 		pthread_mutex_unlock(&mutex);
 		return (-3);
 	}

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#55 (text+ko) ====

@@ -32,7 +32,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#54 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#55 $
  */
 
 #include <sys/types.h>
@@ -77,48 +77,48 @@
 #include <bsm/audit_internal.h>
 
 #define	READ_TOKEN_BYTES(buf, len, dest, size, bytesread, err) do {	\
-	if (bytesread + size > len) {					\
-		err = 1;						\
+	if ((bytesread) + (size) > (u_int32_t)(len)) {			\
+		(err) = 1;						\
 	} else {							\
-		memcpy(dest, buf + bytesread, size);			\
+		memcpy((dest), (buf) + (bytesread), (size));		\
 		bytesread += size;					\
 	}								\
 } while (0)
 
 #define	READ_TOKEN_U_CHAR(buf, len, dest, bytesread, err) do {		\
-	if (bytesread + sizeof(u_char) <= len) {			\
-		dest = buf[bytesread];					\
-		bytesread += sizeof(u_char);				\
+	if ((bytesread) + sizeof(u_char) <= (u_int32_t)(len)) {		\
+		(dest) = buf[(bytesread)];				\
+		(bytesread) += sizeof(u_char);				\
 	} else								\
-		err = 1;						\
+		(err) = 1;						\
 } while (0)
 
 #define	READ_TOKEN_U_INT16(buf, len, dest, bytesread, err) do {		\
-	if (bytesread + sizeof(u_int16_t) <= len) {			\
-		dest = be16dec(buf + bytesread);			\
-		bytesread += sizeof(u_int16_t);				\
+	if ((bytesread) + sizeof(u_int16_t) <= (u_int32_t)(len)) {	\
+		(dest) = be16dec((buf) + (bytesread));			\
+		(bytesread) += sizeof(u_int16_t);			\
 	} else								\
-		err = 1;						\
+		(err) = 1;						\
 } while (0)
 
 #define	READ_TOKEN_U_INT32(buf, len, dest, bytesread, err) do {		\
-	if (bytesread + sizeof(u_int32_t) <= len) {			\
-		dest = be32dec(buf + bytesread);			\
-		bytesread += sizeof(u_int32_t);				\
+	if ((bytesread) + sizeof(u_int32_t) <= (u_int32_t)(len)) {	\
+		(dest) = be32dec((buf) + (bytesread));			\
+		(bytesread) += sizeof(u_int32_t);			\
 	} else								\
-		err = 1; 						\
+		(err) = 1; 						\
 } while (0)
 
 #define	READ_TOKEN_U_INT64(buf, len, dest, bytesread, err) do {		\
-	if (bytesread + sizeof(u_int64_t) <= len) {			\
-		dest = be64dec(buf + bytesread);			\
-		bytesread += sizeof(u_int64_t);				\
+	if ((bytesread) + sizeof(u_int64_t) <= (u_int32_t)(len)) {	\
+		dest = be64dec((buf) + (bytesread));			\
+		(bytesread) += sizeof(u_int64_t);			\
 	} else								\
-		err = 1; 						\
+		(err) = 1; 						\
 } while (0)
 
 #define	SET_PTR(buf, len, ptr, size, bytesread, err) do {		\
-	if ((bytesread) + (size) > (len))				\
+	if ((bytesread) + (size) > (u_int32_t)(len))			\
 		(err) = 1;						\
 	else {								\
 		(ptr) = (buf) + (bytesread);				\
@@ -188,7 +188,7 @@
 static void
 print_mem(FILE *fp, u_char *data, size_t len)
 {
-	int i;
+	u_int32_t i;
 
 	if (len > 0) {
 		fprintf(fp, "0x");
@@ -203,7 +203,7 @@
 static void
 print_string(FILE *fp, const char *str, size_t len)
 {
-	int i;
+	u_int32_t i;
 
 	if (len > 0) {
 		for (i = 0; i < len; i++) {
@@ -1799,7 +1799,7 @@
 fetch_execarg_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
-	int i;
+	u_int32_t i;
 	u_char *bptr;
 
 	READ_TOKEN_U_INT32(buf, len, tok->tt.execarg.count, tok->len, err);
@@ -1813,7 +1813,7 @@
 
 		/* Look for a null terminated string. */
 		while (bptr && (*bptr != '\0')) {
-			if (++tok->len >=len)
+			if (++tok->len >= (u_int32_t)len)
 				return (-1);
 			bptr = buf + tok->len;
 		}
@@ -1831,7 +1831,7 @@
 print_execarg_tok(FILE *fp, tokenstr_t *tok, char *del, char raw,
     __unused char sfrm, int xml)
 {
-	int i;
+	u_int32_t i;
 
 	print_tok_type(fp, tok->id, "exec arg", raw, xml);
 	for (i = 0; i < tok->tt.execarg.count; i++) {
@@ -1858,7 +1858,7 @@
 fetch_execenv_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
-	int i;
+	u_int32_t i;
 	u_char *bptr;
 
 	READ_TOKEN_U_INT32(buf, len, tok->tt.execenv.count, tok->len, err);
@@ -1872,7 +1872,7 @@
 
 		/* Look for a null terminated string. */
 		while (bptr && (*bptr != '\0')) {
-			if (++tok->len >=len)
+			if (++tok->len >= (u_int32_t)len)
 				return (-1);
 			bptr = buf + tok->len;
 		}
@@ -1890,7 +1890,7 @@
 print_execenv_tok(FILE *fp, tokenstr_t *tok, char *del, char raw,
     __unused char sfrm, int xml)
 {
-	int i;
+	u_int32_t i;
 
 	print_tok_type(fp, tok->id, "exec env", raw, xml);
 	for (i = 0; i< tok->tt.execenv.count; i++) {

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#15 (text+ko) ====

@@ -26,7 +26,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#14 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#15 $
  */
 
 /*
@@ -165,7 +165,7 @@
 #ifdef __APPLE__
 	return (!(au_get_state() == AUC_AUDITING));
 #else
-	unsigned long au_cond;
+	long au_cond;
 
 	if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) {
 		if (errno != ENOSYS) {

==== //depot/projects/trustedbsd/openbsm/modules/auditfilter_noop/auditfilter_noop.c#5 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/modules/auditfilter_noop/auditfilter_noop.c#4 $
+ * $P4: //depot/projects/trustedbsd/openbsm/modules/auditfilter_noop/auditfilter_noop.c#5 $
  */
 
 /*
@@ -39,35 +39,37 @@
 #include <bsm/audit_filter.h>
 
 int
-AUDIT_FILTER_ATTACH(void *instance, int argc, char *argv[])
+AUDIT_FILTER_ATTACH(void *instance __unused, int argc __unused, 
+    char *argv[] __unused)
 {
 
 	return (0);
 }
 
 int
-AUDIT_FILTER_REINIT(void *instance, int argc, char *argv[])
+AUDIT_FILTER_REINIT(void *instance __unused, int argc __unused, 
+    char *argv[] __unused)
 {
 
 	return (0);
 }
 
 void
-AUDIT_FILTER_RECORD(void *instance, struct timespec *ts, int token_count,
-    const tokenstr_t *tok[])
+AUDIT_FILTER_RECORD(void *instance __unused, struct timespec *ts __unused,
+    int token_count __unused, const tokenstr_t *tok[] __unused)
 {
 
 }
 
 void
-AUDIT_FILTER_RAWRECORD(void *instance, struct timespec *ts, u_char *data,
-    u_int len)
+AUDIT_FILTER_RAWRECORD(void *instance __unused, struct timespec *ts __unused,
+    u_char *data __unused, u_int len __unused)
 {
 
 }
 
 void
-AUDIT_FILTER_DETACH(void *instance)
+AUDIT_FILTER_DETACH(void *instance __unused)
 {
 
 }


More information about the p4-projects mailing list