Fix warning messages generated by GCC 4.6
cover Fix warning messages generated by GCC 4.6
Here is a set of patches that get me up and running without any errors, nor warnings from GCC(or atleast most of them). Seems with the latest 4.6 there's more enforcement envolved with these i.e. one machine with GCC 4.4 compiles fine, and on the other hand the later GCC I get errors(-Werror) and stoppage etc...
In any case if you like what you see let me know, if not let me know so that I can make the appropriate change's to fix this and make things good excetra..
Justin P. Mattock
--
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.
PATCH 1/3 checkpolicy Fix error: variable 'newattr' set but not used(and others as well)
The below patch fixes some warning messages Im receiving with GCC:(in this case some are erros due to -Werror) policy_define.c: In function 'define_type':
policy_define.c:1216:6: error: variable 'newattr' set but not used
cc1: all warnings being treated as errors
--- checkpolicy/policy_define.c | 3 --- checkpolicy/test/dismod.c | 2 -- 2 files changed, 0 insertions(+), 5 deletions(-)
checkpolicy/policy_define.c +0 -3
@@ -1213,7 +1213,6 @@ int define_type(int alias) {char *id;type_datum_t *datum, *attr; -int newattr =0 ;if (pass ==2 ) {/*
@@ -1266,8 +1265,6 @@ int define_type(int alias)/* treat it as a fatal error */ yyerror2 ("attribute %s is not declared" , id);return -1 ; - }else { - newattr =0 ; }if (attr->flavor !=TYPE_ATTRIB ) {
checkpolicy/test/dismod.c +0 -2
@@ -474,11 +474,9 @@ void display_role_allow(role_allow_rule_t * ra, policydb_t * p, FILE * fp)int role_display_callback (hashtab_key_t key,hashtab_datum_t datum,void *data) { -char *id;role_datum_t *role;FILE *fp; - id = key; role = (role_datum_t *) datum; fp = (FILE *) data;
Signature · 7 lines
1.7.1.rc1.21.gf3bd6 -- 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.
PATCH 1/3 libsemanage Fix warning: parameter 'key' set but not used(and others)
In reply to Justin P. Mattocklibsemanage produced no errors with the warnings, Im just noticing big hunks of sections with warning messages:
database_llist.c: In function 'dbase_llist_add':
database_llist.c:150:28: warning: parameter 'key' set but not used database_llist.c: In function 'dbase_llist_count':
database_llist.c:221:50: warning: parameter 'handle' set but not used database_llist.c: In function 'dbase_llist_del':
database_llist.c:278:41: warning: parameter 'handle' set but not used (and so on...)
so add the GCC attribute to quiet these warnings since most go to NULL;
--- libsemanage/src/database_llist.c | 7 ++++--- libsemanage/src/database_policydb.c | 18 ++++++++++++------ libsemanage/src/debug.c | 2 +- libsemanage/src/direct_api.c | 3 ++- 4 files changed, 19 insertions(+), 11 deletions(-)
libsemanage/src/database_llist.c +4 -3
@@ -147,7 +147,8 @@ int dbase_llist_exists(semanage_handle_t * handle,int dbase_llist_add (semanage_handle_t * handle,dbase_llist_t * dbase, -const record_key_t * key,const record_t * data) +const record_key_t * key __attribute__ ((unused)), +const record_t * data) {if (dbase_llist_cache_prepend (handle, dbase, data) <0 )
@@ -218,7 +219,7 @@ int dbase_llist_modify(semanage_handle_t * handle,return STATUS_ERR ; } -hidden int dbase_llist_count(semanage_handle_t * handle, +hidden int dbase_llist_count(semanage_handle_t * handle __attribute__ ((unused)),dbase_llist_t * dbase,unsigned int *response) {
@@ -275,7 +276,7 @@ int dbase_llist_iterate(semanage_handle_t * handle,return STATUS_ERR ; } -int dbase_llist_del (semanage_handle_t * handle, +int dbase_llist_del (semanage_handle_t * handle __attribute__ ((unused)),dbase_llist_t * dbase,const record_key_t * key) {
libsemanage/src/database_policydb.c +12 -6
@@ -177,7 +177,8 @@ static int dbase_policydb_cache(semanage_handle_t * handle,return STATUS_ERR ; } -static int dbase_policydb_flush (semanage_handle_t * handle, +static int dbase_policydb_flush (semanage_handle_t * handle + __attribute__ ((unused)),dbase_policydb_t * dbase) {
@@ -309,9 +310,12 @@ static int dbase_policydb_modify(semanage_handle_t * handle,return STATUS_ERR ; } -static int dbase_policydb_del (semanage_handle_t * handle, -dbase_policydb_t * dbase, -const record_key_t * key) +static int dbase_policydb_del (semanage_handle_t * handle + __attribute__ ((unused)), +dbase_policydb_t * dbase + __attribute__ ((unused)), +const record_key_t * key + __attribute__ ((unused))) {/* Stub */
@@ -321,8 +325,10 @@ static int dbase_policydb_del(semanage_handle_t * handle,return STATUS_ERR ; } -static int dbase_policydb_clear (semanage_handle_t * handle, -dbase_policydb_t * dbase) +static int dbase_policydb_clear (semanage_handle_t * handle + __attribute__ ((unused)), +dbase_policydb_t * dbase + __attribute__ ((unused))) {/* Stub */
libsemanage/src/debug.c +1 -1
@@ -51,7 +51,7 @@ hidden_def(semanage_msg_get_fname)#ifdef __GNUC__ __attribute__ ((format (printf,3 ,4 ))) #endif -void hidden semanage_msg_default_handler(void *varg, +void hidden semanage_msg_default_handler(void *varg __attribute__ ((unused)),semanage_handle_t * handle,const char *fmt, ...) {
libsemanage/src/direct_api.c +2 -1
@@ -243,7 +243,8 @@ int semanage_direct_connect(semanage_handle_t * sh)return STATUS_ERR ; } -static void semanage_direct_destroy (semanage_handle_t * sh) +static void semanage_direct_destroy (semanage_handle_t * sh + __attribute__ ((unused))) {/* do nothing */ sh =NULL ;
Signature · 7 lines
1.7.1.rc1.21.gf3bd6 -- 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.
PATCH 2/3 libsepol
In reply to Justin P. MattockGoing through these warning messages Im getting:
(example 1 of many)booleans.c: In function 'sepol_bool_count':
booleans.c:106:39: error: parameter 'handle' set but not used
cc1: all warnings being treated as errors
seems most of these go to NULL; Which tells me that these are here for future use and/or need to be there for some other reason. The biggest problem I have is Im getting errors out of these as opposed to just a warning(-Werror) so marking the variable with a GCC __attribute__ ((unused)) gets things going.
--- libsepol/src/booleans.c | 2 +- libsepol/src/debug.c | 2 +- libsepol/src/interfaces.c | 4 ++-- libsepol/src/nodes.c | 2 +- libsepol/src/policydb.c | 4 +--- libsepol/src/ports.c | 2 +- libsepol/src/roles.c | 2 +- libsepol/src/services.c | 2 -- libsepol/src/users.c | 4 ++-- 9 files changed, 10 insertions(+), 14 deletions(-)
libsepol/src/booleans.c +1 -1
@@ -103,7 +103,7 @@ int sepol_bool_set(sepol_handle_t * handle,return STATUS_ERR ; } -int sepol_bool_count (sepol_handle_t * handle, +int sepol_bool_count (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,unsigned int *response) {
libsepol/src/debug.c +1 -1
@@ -41,7 +41,7 @@ hidden_def(sepol_msg_get_fname)#ifdef __GNUC__ __attribute__ ((format (printf,3 ,4 ))) #endif -void hidden sepol_msg_default_handler(void *varg, +void hidden sepol_msg_default_handler(void *varg __attribute__ ((unused)),sepol_handle_t * handle,const char *fmt, ...) {
libsepol/src/interfaces.c +2 -2
@@ -106,7 +106,7 @@ static int iface_to_record(sepol_handle_t * handle, }/* Check if an interface exists */ -int sepol_iface_exists (sepol_handle_t * handle, +int sepol_iface_exists (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,const sepol_iface_key_t * key,int *response) {
@@ -216,7 +216,7 @@ int sepol_iface_modify(sepol_handle_t * handle, }/* Return the number of interfaces */ -extern int sepol_iface_count (sepol_handle_t * handle, +extern int sepol_iface_count (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,unsigned int *response) {
libsepol/src/nodes.c +1 -1
@@ -144,7 +144,7 @@ static int node_to_record(sepol_handle_t * handle, }/* Return the number of nodes */ -extern int sepol_node_count (sepol_handle_t * handle, +extern int sepol_node_count (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,unsigned int *response) {
libsepol/src/policydb.c +1 -3
@@ -3234,7 +3234,7 @@ int policydb_read(policydb_t * p, struct policy_file *fp, unsigned verbose) {unsigned int i, j, r_policyvers; -uint32_t buf[5 ], config; +uint32_t buf[5 ];size_t len, nprim, nel;char *policydb_str;struct policydb_compat_info *info;
@@ -3242,8 +3242,6 @@ int policydb_read(policydb_t * p, struct policy_file *fp, unsigned verbose)ebitmap_node_t *tnode;int rc; - config =0 ; -/* Read the magic number and string length. */ rc =next_entry (buf, fp,sizeof (uint32_t ) *2 );if (rc <0 )
libsepol/src/ports.c +1 -1
@@ -140,7 +140,7 @@ static int port_to_record(sepol_handle_t * handle, }/* Return the number of ports */ -extern int sepol_port_count (sepol_handle_t * handle, +extern int sepol_port_count (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,unsigned int *response) {
libsepol/src/roles.c +1 -1
@@ -8,7 +8,7 @@#include "handle.h" /* Check if a role exists */ -int sepol_role_exists (sepol_handle_t * handle, +int sepol_role_exists (sepol_handle_t * handle __attribute__ ((unused)),sepol_policydb_t * p,const char *role,int *response) {
libsepol/src/services.c +0 -2
@@ -1003,7 +1003,6 @@ int hidden sepol_load_policy(void *data, size_t len)policydb_t oldpolicydb, newpolicydb;sidtab_t oldsidtab, newsidtab;convert_context_args_t args; -uint32_t seqno;int rc =0 ;struct policy_file file, *fp;
@@ -1050,7 +1049,6 @@ int hidden sepol_load_policy(void *data, size_t len)/* Install the new policydb and SID table. */ memcpy (policydb, &newpolicydb,sizeof *policydb);sepol_sidtab_set (sidtab, &newsidtab); - seqno = ++latest_granting;/* Free the old policydb and SID table. */ policydb_destroy (&oldpolicydb);
libsepol/src/users.c +2 -2
@@ -284,7 +284,7 @@ int sepol_user_modify(sepol_handle_t * handle,return STATUS_ERR ; } -int sepol_user_exists (sepol_handle_t * handle, +int sepol_user_exists (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,const sepol_user_key_t * key,int *response) {
@@ -301,7 +301,7 @@ int sepol_user_exists(sepol_handle_t * handle,return STATUS_SUCCESS ; } -int sepol_user_count (sepol_handle_t * handle, +int sepol_user_count (sepol_handle_t * handle __attribute__ ((unused)),const sepol_policydb_t * p,unsigned int *response) {
Signature · 7 lines
1.7.1.rc1.21.gf3bd6 -- 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.
Re: [PATCH 2/3]libsepol
libsepol/src/services.c int hidden sepol_load_policy(void *data, size_t len) · line 1054
Quoted 10 lines · Justin P. Mattock
libsepol/src/services.c +0
-1@@ -1050,7 +1049,6 @@ int hidden sepol_load_policy(void *data, size_t len)/* Install the new policydb and SID table. */ memcpy (policydb, &newpolicydb,sizeof *policydb);sepol_sidtab_set (sidtab, &newsidtab); - seqno = ++latest_granting;/* Free the old policydb and SID table. */ policydb_destroy (&oldpolicydb);
Is latest_granting used for anything else? If it's not being used then it should be removed too. If it is being used then failing to increment it breaks something.
Signature · 8 lines
[email protected] http://etbe.coker.com.au/ My Main Blog http://doc.coker.com.au/ My Documents Blog -- 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.
Re: [PATCH 2/3]libsepol
Quoted 9 lines · Russell Coker
Quoted 8 lines · Justin P. Mattock
libsepol/src/services.c +0
-1@@ -1050,7 +1049,6 @@ int hidden sepol_load_policy(void *data, size_t len)/* Install the new policydb and SID table. */ memcpy (policydb,&newpolicydb,sizeof *policydb);sepol_sidtab_set (sidtab,&newsidtab); - seqno = ++latest_granting;
Quoted 7 lines
libsepol/src/services.c int hidden sepol_load_policy(void *data, size_t len) · line 1054
Quoted 2 lines
libsepol/src/services.c +0
-0/* Free the old policydb and SID table. */ policydb_destroy (&oldpolicydb);Is
latest_grantingused for anything else? If it's not being used then it should be removed too. If it is being used then failing to increment it breaks something.
doing a grep for all packages shows me this:(no grep in the kernel or elsewhere
selinux/libsepol/src/services.c:112:static uint32_t latest_granting = 0;selinux/libsepol/src/services.c:335: avd->seqno = latest_granting;selinux/libsepol/src/services.c:1053: seqno = ++latest_granting;
Justin P. Mattock
--
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.
Quoted 10 lines · Justin P. Mattock
Here is a set of patches that get me up and running without any errors, nor warnings from GCC(or atleast most of them). Seems with the latest 4.6 there's more enforcement envolved with these i.e. one machine with GCC 4.4 compiles fine, and on the other hand the later GCC I get errors(-Werror) and stoppage etc...
Quoted 5 lines
In any case if you like what you see let me know, if not let me know so that I can make the appropriate change's to fix this and make things good excetra..
Justin P. Mattock
This whole set looks good to me. Merged as of checkpolicy 2.0.23, libsepol 2.0.42, and libsemanage 2.0.46.
--
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.