[fmac-discuss] [patch] Lint cleanup

Stephen Smalley sds at tycho.nsa.gov
Mon Jun 9 11:03:37 PDT 2008


On Mon, 2008-06-09 at 10:42 -0700, John Weeks wrote:
> Cleanup of pending lint errors.

Acked-by:  Stephen Smalley <sds at tycho.nsa.gov>

> -John
> 
> diff --git a/usr/src/common/fmac/ss/avtab.c b/usr/src/common/fmac/ss/avtab.c
> --- a/usr/src/common/fmac/ss/avtab.c
> +++ b/usr/src/common/fmac/ss/avtab.c
> @@ -34,6 +34,8 @@
>   /*
>    * Implementation of the access vector table type.
>    */
> +
> +#include <sys/note.h>
> 
>   #if defined(_KERNEL)
>   #include <sys/inttypes.h>
> @@ -230,7 +232,6 @@ avtab_hash_eval(avtab_t *h, char *tag)
>   		max_chain_len);
>   }
> 
> -/*ARGSUSED*/
>   int
>   avtab_read(avtab_t *a, void *fp, uint32_t config)
>   {
> @@ -241,6 +242,7 @@ avtab_read(avtab_t *a, void *fp, uint32_
>   	uint32_t nel;
>   	size_t items, items2;
> 
> +	_NOTE(ARGUNUSED(config));
> 
>   	items = next_entry(&nel, sizeof (uint32_t), 1, fp);
>   	if (items != 1) {
> diff --git a/usr/src/common/fmac/ss/mls.c b/usr/src/common/fmac/ss/mls.c
> --- a/usr/src/common/fmac/ss/mls.c
> +++ b/usr/src/common/fmac/ss/mls.c
> @@ -49,6 +49,7 @@
>   #endif /* defined(_KERNEL) */
> 
>   #include <sys/types.h>
> +#include <sys/note.h>
>   #include "ss_impl.h"
>   #include "mls.h"
>   #include "policydb.h"
> @@ -118,7 +119,6 @@ int
>   int
>   mls_compute_context_len(context_struct_t *context)
>   {
> -	int categories;
>   	int i;
>   	int l;
>   	int len;
> @@ -176,7 +176,7 @@ mls_compute_context_len(context_struct_t
>    *
>    * Format: sensitivity[:category,...][-sensitivity[:category,...]]
>    */
> -int
> +void
>   mls_sid_to_context(context_struct_t *context, char *scontextp)
>   {
>   	int categories;
> @@ -235,8 +235,6 @@ mls_sid_to_context(context_struct_t *con
>   			break;
>   		}
>   	}
> -
> -	return (0);
>   }
> 
>   /*
> @@ -404,8 +402,9 @@ mls_context_to_sid(char oldc, char **sco
> 
>   	if (l == 0) {
>   		context->range.level[1].sens = context->range.level[0].sens;
> -		ebitmap_cpy(&context->range.level[1].cat,
> -		    &context->range.level[0].cat);
> +		if (!ebitmap_cpy(&context->range.level[1].cat,
> +		    &context->range.level[0].cat))
> +			return (ENOMEM);
>   	}
>   	*scontext = ++p;
>   	return (0);
> @@ -474,11 +473,12 @@ mls_convert_context(policydb_t *oldp, po
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   int
>   mls_compute_sid(context_struct_t *scontext, context_struct_t *tcontext,
>       security_class_t tclass, uint32_t specified, context_struct_t *newcontext)
>   {
> +	_NOTE(ARGUNUSED(tclass));
> +
>   	switch (specified) {
>   	case AVTAB_TRANSITION:
>   	case AVTAB_CHANGE:
> @@ -747,11 +747,12 @@ cat_index(hashtab_key_t key, hashtab_dat
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   int
>   sens_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
>   	level_datum_t *levdatum;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
> @@ -764,17 +765,17 @@ sens_destroy(hashtab_key_t key, hashtab_
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   int
>   cat_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
> +	_NOTE(ARGUNUSED(p));
> +
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
>   	SS_FREE(datum, sizeof (cat_datum_t));
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   int
>   sens_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -782,6 +783,8 @@ sens_read(policydb_t *p, hashtab_t h, vo
>   	level_datum_t	*levdatum;
>   	uint32_t	buf[2], len;
>   	int		items;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	levdatum = SS_ALLOC_NOSLEEP(sizeof (level_datum_t));
>   	if (!levdatum)
> @@ -813,12 +816,11 @@ sens_read(policydb_t *p, hashtab_t h, vo
>   	return (0);
> 
>   bad:
> -	sens_destroy(key, levdatum, NULL);
> +	(void) sens_destroy(key, levdatum, NULL);
>   	return (-1);
>   }
> 
> 
> -/*ARGSUSED*/
>   int
>   cat_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -826,6 +828,8 @@ cat_read(policydb_t *p, hashtab_t h, voi
>   	cat_datum_t	*catdatum;
>   	uint32_t	buf[3], len;
>   	int		items;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	catdatum = SS_ALLOC_NOSLEEP(sizeof (cat_datum_t));
>   	if (!catdatum)
> @@ -854,6 +858,6 @@ cat_read(policydb_t *p, hashtab_t h, voi
>   	return (0);
> 
>   bad:
> -	cat_destroy(key, catdatum, NULL);
> +	(void) cat_destroy(key, catdatum, NULL);
>   	return (-1);
>   }
> diff --git a/usr/src/common/fmac/ss/mls.h b/usr/src/common/fmac/ss/mls.h
> --- a/usr/src/common/fmac/ss/mls.h
> +++ b/usr/src/common/fmac/ss/mls.h
> @@ -50,7 +50,7 @@ void mls_compute_av(context_struct_t *sc
> 
>   int mls_compute_context_len(context_struct_t * context);
> 
> -int mls_sid_to_context(context_struct_t *context, char *scontext);
> +void mls_sid_to_context(context_struct_t *context, char *scontext);
> 
>   int mls_context_isvalid(policydb_t *p, context_struct_t * c);
> 
> diff --git a/usr/src/common/fmac/ss/policydb.c b/usr/src/common/fmac/ss/policydb.c
> --- a/usr/src/common/fmac/ss/policydb.c
> +++ b/usr/src/common/fmac/ss/policydb.c
> @@ -36,7 +36,7 @@
>    */
> 
>   #include <sys/types.h>
> -
> +#include <sys/note.h>
> 
>   #if defined(_KERNEL)
>   #include <sys/inttypes.h>
> @@ -302,22 +302,23 @@ policydb_index_others(policydb_t *p)
>    * free any memory allocated for each kind of
>    * symbol data in the policy database.
>    */
> -
> -/*ARGSUSED*/
>   static int
>   perm_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
> +	_NOTE(ARGUNUSED(p));
> +
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
>   	SS_FREE(datum, sizeof (perm_datum_t));
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   common_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
>   	common_datum_t *comdatum;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
> @@ -328,13 +329,14 @@ common_destroy(hashtab_key_t key, hashta
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   class_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
>   	class_datum_t *cladatum;
>   	constraint_node_t *constraint, *ctemp;
>   	constraint_expr_t *e, *etmp;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
> @@ -360,11 +362,12 @@ class_destroy(hashtab_key_t key, hashtab
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   role_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
>   	role_datum_t *role;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
> @@ -375,21 +378,23 @@ role_destroy(hashtab_key_t key, hashtab_
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   type_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
> +	_NOTE(ARGUNUSED(p));
> +
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
>   	SS_FREE(datum, sizeof (type_datum_t));
>   	return (0);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   user_destroy(hashtab_key_t key, hashtab_datum_t datum, void *p)
>   {
>   	user_datum_t *usrdatum;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	if (key)
>   		SS_FREE(key, strlen(key) + 1);
> @@ -589,8 +594,6 @@ context_read_and_validate(context_struct
>    * read the symbol data from a policy database
>    * binary representation file.
>    */
> -
> -/*ARGSUSED*/
>   static int
>   perm_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -598,6 +601,8 @@ perm_read(policydb_t *p, hashtab_t h, vo
>   	perm_datum_t	*perdatum;
>   	uint32_t	buf[2], len;
>   	int		items, items2;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	perdatum = SS_ALLOC_SLEEP(sizeof (perm_datum_t));
>   	if (!perdatum)
> @@ -839,7 +844,6 @@ bad:
>   	return (-1);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   role_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -847,6 +851,8 @@ role_read(policydb_t *p, hashtab_t h, vo
>   	role_datum_t *role;
>   	uint32_t buf[2], len;
>   	int items;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	role = SS_ALLOC_SLEEP(sizeof (role_datum_t));
>   	if (!role)
> @@ -895,7 +901,6 @@ bad:
>   	return (-1);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   type_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -903,6 +908,8 @@ type_read(policydb_t *p, hashtab_t h, vo
>   	type_datum_t *typdatum;
>   	uint32_t buf[3], len;
>   	int items;
> +
> +	_NOTE(ARGUNUSED(p));
> 
>   	typdatum = SS_ALLOC_SLEEP(sizeof (type_datum_t));
>   	if (!typdatum)
> @@ -935,7 +942,6 @@ bad:
>   	return (-1);
>   }
> 
> -/*ARGSUSED*/
>   static int
>   user_read(policydb_t *p, hashtab_t h, void *fp)
>   {
> @@ -944,6 +950,7 @@ user_read(policydb_t *p, hashtab_t h, vo
>   	uint32_t buf[2], len;
>   	int items;
> 
> +	_NOTE(ARGUNUSED(p));
> 
>   	usrdatum = SS_ALLOC_SLEEP(sizeof (user_datum_t));
>   	if (!usrdatum)
> diff --git a/usr/src/common/fmac/ss/services.c b/usr/src/common/fmac/ss/services.c
> --- a/usr/src/common/fmac/ss/services.c
> +++ b/usr/src/common/fmac/ss/services.c
> @@ -39,6 +39,7 @@
> 
>   #include <sys/types.h>
>   #include <sys/socket.h>
> +#include <sys/note.h>
>   #include <sys/fmac/avc_ss.h>
> 
>   #if defined(_KERNEL)
> @@ -243,6 +244,8 @@ context_struct_compute_av(context_struct
>   	avtab_key_t avkey;
>   	avtab_datum_t *avdatum;
>   	class_datum_t *tclass_datum;
> +
> +	_NOTE(ARGUNUSED(requested));
> 
>   	if (!tclass || tclass > policydb.p_classes.nprim) {
>   		(void) printf("security_compute_av:  unrecognized class %d\n",
> @@ -935,7 +938,6 @@ typedef struct {
>    * context is valid under the new policy.
>    */
> 
> -/*ARGSUSED*/
>   static int
>   convert_context(security_id_t key, context_struct_t *c, void *p)
>   {
> @@ -947,6 +949,8 @@ convert_context(security_id_t key, conte
>   	security_context_t s;
>   	uint32_t len;
>   	int rc = EINVAL;
> +
> +	_NOTE(ARGUNUSED(key));
> 
>   	args = (convert_context_args_t *) p;
> 
> @@ -1157,14 +1161,14 @@ out:
>    * Return the SID of the port specified by
>    * `domain', `type', `protocol', and `port'.
>    */
> -
> -/*ARGSUSED*/
>   int
>   security_port_sid(uint16_t domain, uint16_t type, uint8_t protocol,
>       uint16_t port, security_id_t *out_sid)
>   {
>   	ocontext_t *c;
>   	int rc = 0;
> +
> +	_NOTE(ARGUNUSED(domain, type));
> 
>   	POLICY_RDLOCK;
> 
> diff --git a/usr/src/common/fmac/ss/symtab.c b/usr/src/common/fmac/ss/symtab.c
> --- a/usr/src/common/fmac/ss/symtab.c
> +++ b/usr/src/common/fmac/ss/symtab.c
> @@ -30,6 +30,8 @@
>    * Implementation of the symbol table type.
>    */
> 
> +#include <sys/note.h>
> +
>   #if defined(_KERNEL)
>   #include <sys/systm.h>
>   #else
> @@ -54,11 +56,12 @@ symhash(hashtab_t h, hashtab_key_t key)
>   	return (val & (h->size - 1));
>   }
> 
> -/*ARGSUSED*/
>   static int
>   symcmp(hashtab_t h, hashtab_key_t key1, hashtab_key_t key2)
>   {
>   	char *keyp1, *keyp2;
> +
> +	_NOTE(ARGUNUSED(h));
> 
>   	keyp1 = (char *) key1;
>   	keyp2 = (char *) key2;
> diff --git a/usr/src/uts/common/fmac/avc.c b/usr/src/uts/common/fmac/avc.c
> --- a/usr/src/uts/common/fmac/avc.c
> +++ b/usr/src/uts/common/fmac/avc.c
> @@ -49,6 +49,7 @@
>   #include <sys/ddi.h>
>   #include <sys/sunddi.h>
>   #include <sys/systm.h>
> +#include <sys/note.h>
>   #include <sys/fmac/fmac.h>
>   #include <sys/fmac/avc.h>
>   #include <sys/fmac/avc_ss.h>
> @@ -519,6 +520,9 @@ avc_audit(
>   	uint32_t denied,		/* IN */
>   	avc_audit_data_t *a)		/* IN */
>   {
> +
> +	_NOTE(ARGUNUSED(ae));
> +
>   	if (a && a->type == AVC_AUDIT_DATA_DONTAUDIT)
>   		return;
> 
> @@ -564,13 +568,12 @@ avc_add_callback(int (*callback)(uint32_
> 
>   	c = (avc_callback_node_t *) kmem_alloc(sizeof (avc_callback_node_t),
>   	    KM_SLEEP);
> -	if (!c)
> -		return (ENOMEM);
> 
>   	c->callback = callback;
>   	c->events = events;
>   	c->ssid = ssid;
>   	c->tsid = tsid;
> +	c->tclass = tclass;
>   	c->perms = perms;
>   	c->next = avc_callbacks;
>   	avc_callbacks = c;
> _______________________________________________
> fmac-discuss mailing list
> fmac-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/fmac-discuss
-- 
Stephen Smalley
National Security Agency




More information about the fmac-discuss mailing list