Skip to contentSkip to conversation

checkpolicy-5

PATCH In review Bastian Blank 2 participants 2 messages Nov 29, 2003 – Dec 1, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpolicy-5

hi folks

this patch fixes:
- size_t vs. int, unsigned int, __u32
- mark some attributes as unused

bastian

Signature · 2 lines
Where there's no emotion, there's no motive for violence.
		-- Spock, "Dagger of the Mind", stardate 2715.1
services.c +15 -14
@@ -170,7 +170,7 @@
 static int context_struct_compute_av(context_struct_t *scontext,
 				     context_struct_t *tcontext,
 				     security_class_t tclass,
-				     access_vector_t requested,
+				     access_vector_t requested __attribute__ ((unused)),
 				     struct av_decision *avd)
 {
 	constraint_node_t *constraint;
@@ -301,7 +301,7 @@
  */
 int context_struct_to_string(context_struct_t * context,
 			     security_context_t * scontext,
-			     __u32 *scontext_len)
+			     size_t *scontext_len)
 {
 	char *scontextp;
 
@@ -315,7 +315,7 @@
 	*scontext_len += mls_compute_context_len(context);
 
 	/* Allocate space for the context; caller must free this space. */
-	scontextp = (char *) kmalloc(*scontext_len+1,GFP_ATOMIC);
+	scontextp = kmalloc(*scontext_len+1,GFP_ATOMIC);
 	if (!scontextp) {
 		return -ENOMEM;
 	}
@@ -350,7 +350,7 @@
  */
 int security_sid_to_context(security_id_t sid,
 			    security_context_t * scontext,
-			    __u32 *scontext_len)
+			    size_t *scontext_len)
 {
 	context_struct_t *context;
 	int rc = 0;
@@ -387,7 +387,7 @@
  * has the string representation specified by `scontext'.
  */
 int security_context_to_sid(security_context_t scontext,
-			    __u32 scontext_len,
+			    size_t scontext_len,
 			    security_id_t * sid)
 {
 	security_context_t scontext2;
@@ -510,7 +510,7 @@
 		return -EACCES;
 	} else {
 		security_context_t s, t, n;
-		__u32 slen, tlen, nlen;
+		size_t slen, tlen, nlen;
 
 		context_struct_to_string(scontext, &s, &slen);
 		context_struct_to_string(tcontext, &t, &tlen);
@@ -800,7 +800,7 @@
 		return -EINVAL;
 	} else {
 		security_context_t s;
-		__u32 len;
+		size_t len;
 
 		context_struct_to_string(context, &s, &len);
 		printk("security:  context %s is invalid\n", s);
@@ -821,7 +821,7 @@
  * in the policy `p->newp'.  Verify that the
  * context is valid under the new policy.
  */
-static int convert_context(security_id_t key,
+static int convert_context(security_id_t key __attribute__ ((unused)),
 			   context_struct_t * c,
 			   void *p)
 {
@@ -831,7 +831,7 @@
 	type_datum_t *typdatum;
 	user_datum_t *usrdatum;
 	security_context_t s;
-	__u32 len;
+	size_t len;
 	int rc = -EINVAL;
        
 	args = (convert_context_args_t *) p;
@@ -1045,8 +1045,8 @@
  * Return the SID of the port specified by
  * `domain', `type', `protocol', and `port'.
  */
-int security_port_sid(__u16 domain,
-		      __u16 type,
+int security_port_sid(__u16 domain __attribute__ ((unused)),
+		      __u16 type __attribute__ ((unused)),
 		      __u8 protocol,
 		      __u16 port,
 		      security_id_t * out_sid)
@@ -1141,7 +1141,7 @@
  */
 int security_node_sid(__u16 domain,
 		      void *addrp,
-		      __u32 addrlen,
+		      size_t addrlen,
 		      security_id_t *out_sid)
 {
 	int rc = 0;
@@ -1201,7 +1201,8 @@
 	user_datum_t *user;
 	role_datum_t *role;
 	struct av_decision avd;
-	int rc = 0, i, j;
+	int rc = 0;
+	unsigned int i, j;
 
 	if (!ss_initialized) {
 		*nel = 0;
@@ -1293,7 +1294,7 @@
 		       security_class_t sclass,
 		       security_id_t *sid)
 {
-	int len;
+	size_t len;
 	genfs_t *genfs;
 	ocontext_t *c;
 	int rc = 0, cmp = 0;
checkpolicy.c +11 -9
@@ -57,7 +57,7 @@
 char *txtfile = "policy.conf";
 char *binfile = "policy";
 
-int avc_ss_reset(__u32 seqno)
+int avc_ss_reset(__u32 seqno __attribute__ ((unused)))
 {
 	return 0;
 }
@@ -69,10 +69,10 @@
 }
 
 static int print_sid(security_id_t sid,
-		     context_struct_t * context, void *data)
+		     context_struct_t * context __attribute__ ((unused)), void *data __attribute__ ((unused)))
 {
 	security_context_t scontext;
-	unsigned int scontext_len;
+	size_t scontext_len;
 	int rc;
 
 	rc = security_sid_to_context(sid, &scontext, &scontext_len);
@@ -105,7 +105,7 @@
 	return 0;
 }
 
-static int type_attr_remove(hashtab_key_t key, hashtab_datum_t datum, void *p)
+static int type_attr_remove(hashtab_key_t key __attribute__ ((unused)), hashtab_datum_t datum, void *p __attribute__ ((unused)))
 {
 	type_datum_t *typdatum;
 
@@ -244,12 +244,12 @@
 
 extern char *av_to_string(__u32 tclass, access_vector_t av);
 
-void check_assertion_helper(int stype, int ttype, ebitmap_t *tclasses, 
+void check_assertion_helper(unsigned int stype, unsigned int ttype, ebitmap_t *tclasses, 
 			    access_vector_t *avp, unsigned long line) 
 {
 	avtab_key_t avkey;
 	avtab_datum_t *avdatump;
-	int k;
+	unsigned int k;
 	
 
 	for (k = ebitmap_startbit(tclasses); k < ebitmap_length(tclasses); k++) {
@@ -275,7 +275,7 @@
 void check_assertions(void) 
 {
 	te_assert_t *a, *tmp;
-	int i, j;
+	unsigned int i, j;
 
 	a = te_assertions;
 	while (a) {
@@ -309,11 +309,13 @@
 	struct av_decision avd;
 	class_datum_t *cladatum;
 	char ans[80 + 1], *file = txtfile, *outfile = NULL, *path, *fstype;
-	unsigned int scontext_len, pathlen, i;
+	size_t scontext_len, pathlen;
+	unsigned int i;
 	unsigned int protocol, port, addr;
 	unsigned int binary = 0, debug = 0;
 	struct val_to_name v;
-	int ret, ch, nel, fd;
+	int ret, ch, fd;
+	unsigned int nel;
 	struct stat sb;
 	void *map;
 	FILE *outfp = NULL;
security.h +3 -3
@@ -80,7 +80,7 @@
 int security_sid_to_context(
 	security_id_t  sid,			/* IN */
 	security_context_t *scontext,		/* OUT */
-	__u32   *scontext_len);			/* OUT */
+	size_t  *scontext_len);			/* OUT */
 
 /*
  * Return a SID associated with the security context that
@@ -88,7 +88,7 @@
  */
 int security_context_to_sid(
 	security_context_t scontext,		/* IN */
-	__u32   scontext_len,			/* IN */
+	size_t  scontext_len,			/* IN */
 	security_id_t *out_sid);		/* OUT */
 
 /*
@@ -147,7 +147,7 @@
 int security_node_sid(
 	__u16 domain,
 	void *addr,
-	__u32 addrlen,
+	size_t addrlen,
 	security_id_t *out_sid);
 
 /*
hashtab.c +7 -5
@@ -17,7 +17,7 @@
 			 unsigned int size)
 {
 	hashtab_t p;
-	int i;
+	unsigned int i;
 
 
 	p = (hashtab_t) kmalloc(sizeof(hashtab_val_t),GFP_KERNEL);
@@ -187,7 +187,7 @@
 
 void hashtab_destroy(hashtab_t h)
 {
-	int i;
+	unsigned int i;
 	hashtab_ptr_t cur, temp;
 
 
@@ -217,7 +217,7 @@
 			      void *args),
 		void *args)
 {
-	int i, ret;
+	unsigned int i, ret;
 	hashtab_ptr_t cur;
 
 
@@ -246,7 +246,8 @@
 						  void *args),
 				 void *args)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 	hashtab_ptr_t last, cur, temp;
 
 
@@ -283,7 +284,8 @@
 
 void hashtab_hash_eval(hashtab_t h, char *tag)
 {
-	int i, chain_len, slots_used, max_chain_len;
+	unsigned int i;
+	int chain_len, slots_used, max_chain_len;
 	hashtab_ptr_t cur;
 
 
context.h +6 -6
@@ -80,18 +80,18 @@
 
 #else
 
-static inline void mls_context_init(context_struct_t *c)
+static inline void mls_context_init(context_struct_t *c __attribute__ ((unused)))
 { }
 
-static inline int mls_context_cpy(context_struct_t * dst, 
-				  context_struct_t * src)
+static inline int mls_context_cpy(context_struct_t * dst __attribute__ ((unused)), 
+				  context_struct_t * src __attribute__ ((unused)))
 { return 0; }
 
-static inline int mls_context_cmp(context_struct_t * c1,
-                                  context_struct_t * c2)
+static inline int mls_context_cmp(context_struct_t * c1 __attribute__ ((unused)),
+                                  context_struct_t * c2 __attribute__ ((unused)))
 { return 1; }
 
-static inline void mls_context_destroy(context_struct_t * c)
+static inline void mls_context_destroy(context_struct_t * c __attribute__ ((unused)))
 { }
 
 #endif
write.c +21 -21

114 lines not on this page · raw message

===================================================================

avtab.c +3 -2
@@ -186,9 +186,10 @@
 }
 
 
-int avtab_read(avtab_t * a, void * fp, __u32 config)
+int avtab_read(avtab_t * a, void * fp, __u32 config __attribute__ ((unused)))
 {
-	int i, rc;
+	unsigned int i;
+	int rc;
 	avtab_key_t avkey;
 	avtab_datum_t avdatum;
 	__u32 *buf;
#1 lore raw
Quoted 5 lines · Bastian Blank

hi folks

this patch fixes:
- size_t vs. int, unsigned int, __u32
- mark some attributes as unused

Thanks, merged.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.