[apparmor] [PATCH] libapparmor: Fix -Wunused-but-set-variable GCC warning

Seth Arnold seth.arnold at canonical.com
Fri Jan 29 22:51:53 UTC 2016


On Fri, Jan 29, 2016 at 03:18:37PM -0600, Tyler Hicks wrote:
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>

While I don't see anything wrong with this patch I can't actually figure
out how this function works anyway. I don't see anything that would ever
update the ret_record structure after it's been initialized, and I can't
find the aalogparse_parse() function at all. (It feels a bit like it'd be
a magically constructed macro but I can't even find the macros that would
construct it.)

So while this patch may silence a valid warning, I'm not sure how this
works anyway.

Did I miss something?

Thanks

> ---
>  libraries/libapparmor/src/grammar.y | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libraries/libapparmor/src/grammar.y b/libraries/libapparmor/src/grammar.y
> index 2a16d72..1dcc2f9 100644
> --- a/libraries/libapparmor/src/grammar.y
> +++ b/libraries/libapparmor/src/grammar.y
> @@ -425,7 +425,6 @@ _parse_yacc(char *str)
>  	/* yydebug = 1;  */
>  	YY_BUFFER_STATE lex_buf;
>  	yyscan_t scanner;
> -	int parser_return;
>  
>  	ret_record = NULL;
>  	ret_record = malloc(sizeof(aa_log_record));
> @@ -441,7 +440,8 @@ _parse_yacc(char *str)
>  
>  	aalogparse_lex_init(&scanner);
>  	lex_buf = aalogparse__scan_string(str, scanner);
> -	parser_return = aalogparse_parse(scanner);
> +	/* Ignore return value to return an AA_RECORD_INVALID event */
> +	(void)aalogparse_parse(scanner);
>  	aalogparse__delete_buffer(lex_buf, scanner);
>  	aalogparse_lex_destroy(scanner);
>  	return ret_record;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20160129/5acbabda/attachment.pgp>


More information about the AppArmor mailing list