Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Nov 2006 20:19:47 -0200
From:      Diego Giagio <dgiagio@gmail.com>
To:        trustedbsd-audit@FreeBSD.org
Subject:   OpenBSM compiler warnings patch
Message-ID:  <4560D883.7040409@gmail.com>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------030308060902000608060002
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I've created a patch that removes all the compiler warnings I was 
getting, mostly signed/unsigned stuff.

bsm_io.c: I've sticked with the following rules to resolve the conflicts:

- Buffers are u_char*
- Strings are char* (or const char*)
- Casts are used when pointing strings inside buffers.

bsm_notify.c: notify_check function on my Mac OS X 10.4.8 expects an int 
on the second parameter, not an unsigned int.

bsm_token.c: au_to_newgroups expect a gid_t* on the second parameter, 
not an int*. In fact a gid_t may expand to an int or even an unsigned int.

Instructions:
$ cd openbsm
$ patch -p1 < warnings.patch

Please review.
Thanks.

DG

--------------030308060902000608060002
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="warnings.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="warnings.patch"

diff -u -r openbsm/libbsm/bsm_io.c openbsm-dgiagio/libbsm/bsm_io.c
--- openbsm/libbsm/bsm_io.c	2006-11-18 07:44:23.000000000 -0200
+++ openbsm-dgiagio/libbsm/bsm_io.c	2006-11-19 19:18:38.000000000 -0200
@@ -201,7 +201,7 @@
  * Prints the given data bytes as a string.
  */
 static void
-print_string(FILE *fp, u_char *str, size_t len)
+print_string(FILE *fp, const char *str, size_t len)
 {
 	int i;
 
@@ -217,7 +217,7 @@
  * Prints the beggining of attribute.
  */
 static void
-open_attr(FILE *fp, u_char *str)
+open_attr(FILE *fp, const char *str)
 {
 
 	fprintf(fp,"%s=\"", str);
@@ -833,7 +833,7 @@
  * milliseconds of time    4 bytes/8 bytes (32-bit/64-bit value)
  */
 static int
-fetch_header32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_header32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -922,7 +922,7 @@
  * nanoseconds of time     4 bytes/8 bytes  (32/64-bits)
  */
 static int
-fetch_header32_ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_header32_ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1029,7 +1029,7 @@
  * version #              
  */
 static int
-fetch_header64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_header64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1114,7 +1114,7 @@
  * accuracy of the BSM spec.
  */
 static int
-fetch_header64_ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_header64_ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1217,7 +1217,7 @@
  * record size                          4 bytes
  */
 static int
-fetch_trailer_tok(tokenstr_t *tok, char *buf, int len)
+fetch_trailer_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1251,7 +1251,7 @@
  * text                    N bytes + 1 terminating NULL byte
  */
 static int
-fetch_arg32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_arg32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1267,8 +1267,8 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.arg32.text, tok->tt.arg32.len, tok->len,
-	    err);
+	SET_PTR((char*)buf, len, tok->tt.arg32.text, tok->tt.arg32.len,
+	    tok->len, err);
 	if (err)
 		return (-1);
 
@@ -1302,7 +1302,7 @@
 }
 
 static int
-fetch_arg64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_arg64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1318,8 +1318,8 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.arg64.text, tok->tt.arg64.len, tok->len,
-	    err);
+	SET_PTR((char*)buf, len, tok->tt.arg64.text, tok->tt.arg64.len,
+	    tok->len, err);
 	if (err)
 		return (-1);
 
@@ -1360,7 +1360,7 @@
  * data items              (depends on basic unit)
  */
 static int
-fetch_arb_tok(tokenstr_t *tok, char *buf, int len)
+fetch_arb_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 	int datasize;
@@ -1589,7 +1589,7 @@
  * device                  4 bytes/8 bytes (32-bit/64-bit)
  */
 static int
-fetch_attr32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_attr32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1671,7 +1671,7 @@
  * device                  4 bytes/8 bytes (32-bit/64-bit)
  */
 static int
-fetch_attr64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_attr64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1749,7 +1749,7 @@
  * return value            4 bytes
  */
 static int
-fetch_exit_tok(tokenstr_t *tok, char *buf, int len)
+fetch_exit_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1791,11 +1791,11 @@
  * text                    count null-terminated string(s)
  */
 static int
-fetch_execarg_tok(tokenstr_t *tok, char *buf, int len)
+fetch_execarg_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 	int i;
-	char *bptr;
+	u_char *bptr;
 
 	READ_TOKEN_U_INT32(buf, len, tok->tt.execarg.count, tok->len, err);
 	if (err)
@@ -1804,7 +1804,7 @@
 	for (i = 0; i < tok->tt.execarg.count; i++) {
 		bptr = buf + tok->len;
 		if (i < AUDIT_MAX_ARGS)
-			tok->tt.execarg.text[i] = bptr;
+			tok->tt.execarg.text[i] = (char*)bptr;
 
 		/* Look for a null terminated string. */
 		while (bptr && (*bptr != '\0')) {
@@ -1850,11 +1850,11 @@
  * text                    count null-terminated string(s)
  */
 static int
-fetch_execenv_tok(tokenstr_t *tok, char *buf, int len)
+fetch_execenv_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 	int i;
-	char *bptr;
+	u_char *bptr;
 
 	READ_TOKEN_U_INT32(buf, len, tok->tt.execenv.count, tok->len, err);
 	if (err)
@@ -1863,7 +1863,7 @@
 	for (i = 0; i < tok->tt.execenv.count; i++) {
 		bptr = buf + tok->len;
 		if (i < AUDIT_MAX_ENV)
-			tok->tt.execenv.text[i] = bptr;
+			tok->tt.execenv.text[i] = (char*)bptr;
 
 		/* Look for a null terminated string. */
 		while (bptr && (*bptr != '\0')) {
@@ -1911,7 +1911,7 @@
  * file pathname            N bytes + 1 terminating NULL byte
  */
 static int
-fetch_file_tok(tokenstr_t *tok, char *buf, int len)
+fetch_file_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -1927,7 +1927,8 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.file.name, tok->tt.file.len, tok->len, err);
+	SET_PTR((char*)buf, len, tok->tt.file.name, tok->tt.file.len, tok->len,
+	    err);
 	if (err)
 		return (-1);
 
@@ -1965,7 +1966,7 @@
  * group list              count * 4 bytes
  */
 static int
-fetch_newgroups_tok(tokenstr_t *tok, char *buf, int len)
+fetch_newgroups_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int i;
 	int err = 0;
@@ -2008,7 +2009,7 @@
  * Internet addr 4 bytes
  */
 static int
-fetch_inaddr_tok(tokenstr_t *tok, char *buf, int len)
+fetch_inaddr_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2041,7 +2042,7 @@
  * address 16 bytes
  */
 static int
-fetch_inaddr_ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_inaddr_ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2086,7 +2087,7 @@
  * ip header     20 bytes
  */
 static int
-fetch_ip_tok(tokenstr_t *tok, char *buf, int len)
+fetch_ip_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2208,7 +2209,7 @@
  * Object ID            4 bytes
  */
 static int
-fetch_ipc_tok(tokenstr_t *tok, char *buf, int len)
+fetch_ipc_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2255,7 +2256,7 @@
  * key                          4 bytes
  */
 static int
-fetch_ipcperm_tok(tokenstr_t *tok, char *buf, int len)
+fetch_ipcperm_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2341,7 +2342,7 @@
  * port Ip address  2 bytes
  */
 static int
-fetch_iport_tok(tokenstr_t *tok, char *buf, int len)
+fetch_iport_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2373,7 +2374,7 @@
  * data                         size bytes
  */
 static int
-fetch_opaque_tok(tokenstr_t *tok, char *buf, int len)
+fetch_opaque_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2381,8 +2382,8 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.opaque.data, tok->tt.opaque.size, tok->len,
-	    err);
+	SET_PTR((char*)buf, len, tok->tt.opaque.data, tok->tt.opaque.size,
+	    tok->len, err);
 	if (err)
 		return (-1);
 
@@ -2396,13 +2397,15 @@
 
 	print_tok_type(fp, tok->id, "opaque", raw, xml);
 	if (xml) {
-		print_mem(fp, tok->tt.opaque.data, tok->tt.opaque.size);
+		print_mem(fp, (u_char*)tok->tt.opaque.data,
+		    tok->tt.opaque.size);
 		close_tag(fp, tok->id);
 	} else {
 		print_delim(fp, del);
 		print_2_bytes(fp, tok->tt.opaque.size, "%u");
 		print_delim(fp, del);
-		print_mem(fp, tok->tt.opaque.data, tok->tt.opaque.size);
+		print_mem(fp, (u_char*)tok->tt.opaque.data,
+		    tok->tt.opaque.size);
 	}
 }
 
@@ -2411,7 +2414,7 @@
  * data                         size bytes
  */
 static int
-fetch_path_tok(tokenstr_t *tok, char *buf, int len)
+fetch_path_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2419,7 +2422,8 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.path.path, tok->tt.path.len, tok->len, err);
+	SET_PTR((char*)buf, len, tok->tt.path.path, tok->tt.path.len, tok->len,
+	    err);
 	if (err)
 		return (-1);
 
@@ -2455,7 +2459,7 @@
  *   machine id         4 bytes
  */
 static int
-fetch_process32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_process32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2568,7 +2572,7 @@
  *   machine id         4 bytes
  */
 static int
-fetch_process64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_process64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2681,7 +2685,7 @@
  *   machine address      16 bytes                     
  */
 static int
-fetch_process32ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_process32ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2811,7 +2815,7 @@
  *   machine address      16 bytes                     
  */
 static int
-fetch_process64ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_process64ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2930,7 +2934,7 @@
  * return value         4 bytes
  */
 static int
-fetch_return32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_return32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -2968,7 +2972,7 @@
 }
 
 static int
-fetch_return64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_return64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3009,7 +3013,7 @@
  * seq                          4 bytes
  */
 static int
-fetch_seq_tok(tokenstr_t *tok, char *buf, int len)
+fetch_seq_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3043,7 +3047,7 @@
  * socket address          4 bytes
  */
 static int
-fetch_sock_inet32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_sock_inet32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3097,7 +3101,7 @@
  * path                    104 bytes
  */
 static int
-fetch_sock_unix_tok(tokenstr_t *tok, char *buf, int len)
+fetch_sock_unix_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3147,7 +3151,7 @@
  * remote address          4 bytes
  */
 static int
-fetch_socket_tok(tokenstr_t *tok, char *buf, int len)
+fetch_socket_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3228,7 +3232,7 @@
  *   machine id         4 bytes
  */
 static int
-fetch_subject32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_subject32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3340,7 +3344,7 @@
  *   machine id         4 bytes
  */
 static int
-fetch_subject64_tok(tokenstr_t *tok, char *buf, int len)
+fetch_subject64_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3453,7 +3457,7 @@
  *   machine id         16 bytes
  */
 static int
-fetch_subject32ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_subject32ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3582,7 +3586,7 @@
  *   machine id         16 bytes
  */
 static int
-fetch_subject64ex_tok(tokenstr_t *tok, char *buf, int len)
+fetch_subject64ex_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3701,7 +3705,7 @@
  * data                         size bytes
  */
 static int
-fetch_text_tok(tokenstr_t *tok, char *buf, int len)
+fetch_text_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3709,7 +3713,7 @@
 	if (err)
 		return (-1);
 
-	SET_PTR(buf, len, tok->tt.text.text, tok->tt.text.len, tok->len,
+	SET_PTR((char*)buf, len, tok->tt.text.text, tok->tt.text.len, tok->len,
 	    err);
 	if (err)
 		return (-1);
@@ -3742,7 +3746,7 @@
  * remote Internet address 4 bytes
  */
 static int
-fetch_socketex32_tok(tokenstr_t *tok, char *buf, int len)
+fetch_socketex32_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 
@@ -3822,7 +3826,7 @@
 }
 
 static int
-fetch_invalid_tok(tokenstr_t *tok, char *buf, int len)
+fetch_invalid_tok(tokenstr_t *tok, u_char *buf, int len)
 {
 	int err = 0;
 	int recoversize;
@@ -3833,7 +3837,8 @@
 
 	tok->tt.invalid.length = recoversize;
 
-	SET_PTR(buf, len, tok->tt.invalid.data, recoversize, tok->len, err);
+	SET_PTR((char*)buf, len, tok->tt.invalid.data, recoversize, tok->len,
+	    err);
 	if (err)
 		return (-1);
 
@@ -3848,7 +3853,8 @@
 	if (!xml) {
 		print_tok_type(fp, tok->id, "unknown", raw, 0);
 		print_delim(fp, del);
-		print_mem(fp, tok->tt.invalid.data, tok->tt.invalid.length);
+		print_mem(fp, (u_char*)tok->tt.invalid.data,
+		    tok->tt.invalid.length);
 	}
 }
 
diff -u -r openbsm/libbsm/bsm_notify.c openbsm-dgiagio/libbsm/bsm_notify.c
--- openbsm/libbsm/bsm_notify.c	2006-06-16 17:32:11.000000000 -0300
+++ openbsm-dgiagio/libbsm/bsm_notify.c	2006-11-19 19:20:07.000000000 -0200
@@ -66,7 +66,8 @@
 au_notify_initialize(void)
 {
 #if AUDIT_NOTIFICATION_ENABLED
-	uint32_t status, ignore_first;
+	uint32_t status;
+	int ignore_first;
 
 	status = notify_register_check(__BSM_INTERNAL_NOTIFY_KEY, &token);
 	if (status != NOTIFY_STATUS_OK)
@@ -108,7 +109,7 @@
 au_get_state(void)
 {
 #if AUDIT_NOTIFICATION_ENABLED
-	uint32_t did_notify;
+	int did_notify;
 #endif
 	int status;
 
diff -u -r openbsm/libbsm/bsm_token.c openbsm-dgiagio/libbsm/bsm_token.c
--- openbsm/libbsm/bsm_token.c	2006-11-18 09:18:44.000000000 -0200
+++ openbsm-dgiagio/libbsm/bsm_token.c	2006-11-19 19:19:50.000000000 -0200
@@ -345,7 +345,7 @@
 au_to_groups(int *groups)
 {
 
-	return (au_to_newgroups(AUDIT_MAX_GROUPS, groups));
+	return (au_to_newgroups(AUDIT_MAX_GROUPS, (gid_t*)groups));
 }
 
 /*

--------------030308060902000608060002--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4560D883.7040409>