[apparmor] [patch 5/5] parser - drop bogus ret variables

Tyler Hicks tyhicks at canonical.com
Fri Sep 6 19:09:54 UTC 2013


On 2013-09-05 01:18:58, Steve Beattie wrote:
> Nothing ever sets ret after its initialization, as each of the
> functions return on failures directly, so drop the useless variable.
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

This looks fine, but it conflicts heavily with one of jj's C++ patches
that I'm fixing up. His patch essentially makes this same change, along
with a whole lot of other changes so it would be easier on me if we
didn't merge this patch and eventually merged his patch instead.

Here's a little snippet:

---
 static int process_variables_in_entries(struct cod_entry *entry_list)
 {
-       int ret = TRUE, rc;
+       int error = 0;
        struct cod_entry *entry;
 
        list_for_each(entry_list, entry) {
-               rc = expand_entry_variables(&entry->name, entry,
-                                           clone_and_chain_cod);
-               if (!rc)
-                       return FALSE;
+               error = expand_entry_variables(&entry->name, entry,
+                                              clone_and_chain_cod);
+               if (error)
+                       return error;
        }
 
-       return ret;
+       return 0;
 }
---

Steve, does that sound alright?

Tyler

> ---
>  parser/parser_variable.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> Index: b/parser/parser_variable.c
> ===================================================================
> --- a/parser/parser_variable.c
> +++ b/parser/parser_variable.c
> @@ -229,7 +229,7 @@ int clone_and_chain_dbus(void *v)
>  
>  static int process_variables_in_entries(struct cod_entry *entry_list)
>  {
> -	int ret = TRUE, rc;
> +	int rc;
>  	struct cod_entry *entry;
>  
>  	list_for_each(entry_list, entry) {
> @@ -239,13 +239,13 @@ static int process_variables_in_entries(
>  			return FALSE;
>  	}
>  
> -	return ret;
> +	return TRUE;
>  }
>  
>  /* does not currently support expansion of vars in options */
>  static int process_variables_in_mnt_entries(struct mnt_entry *entry_list)
>  {
> -	int ret = TRUE, rc;
> +	int rc;
>  	struct mnt_entry *entry;
>  
>  	list_for_each(entry_list, entry) {
> @@ -264,12 +264,12 @@ static int process_variables_in_mnt_entr
>  
>  	}
>  
> -	return ret;
> +	return TRUE;
>  }
>  
>  static int process_dbus_variables(struct dbus_entry *entry_list)
>  {
> -	int ret = TRUE, rc;
> +	int rc;
>  	struct dbus_entry *entry;
>  
>  	list_for_each(entry_list, entry) {
> @@ -300,7 +300,7 @@ static int process_dbus_variables(struct
>  
>  	}
>  
> -	return ret;
> +	return TRUE;
>  }
>  
>  int process_variables(struct codomain *cod)
> 
> 
> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20130906/6a508cd6/attachment.pgp>


More information about the AppArmor mailing list