[PATCH v2] audit: removing unused variable

Joe Perches joe at perches.com
Thu Oct 29 04:32:48 UTC 2015


On Thu, 2015-10-29 at 09:41 +0530, Saurabh Sengar wrote:
> variable rc is unnecessary hence removing it,
> also as the return type of function audit_log_common_recv_msg is no
> where used changing it to void.

Almost, but not quite.  Keep at it.

Ideally your first attempts at kernel patching
should be done in the drivers/staging/ directory
before attempting patches outside of that path.

> diff --git a/kernel/audit.c b/kernel/audit.c
[]
> @@ -684,25 +684,24 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
>  	return err;
>  }
>  
> -static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
> +static void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
>  {
> -	int rc = 0;
>  	uid_t uid = from_kuid(&init_user_ns, current_uid());
>  	pid_t pid = task_tgid_nr(current);
>  
>  	if (!audit_enabled && msg_type != AUDIT_USER_AVC) {
>  		*ab = NULL;
> -		return rc;
> +		return ;

There's an unnecessary space before the semicolon.
This should be
		return;

>  	}
>  
>  	*ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
>  	if (unlikely(!*ab))
> -		return rc;
> +		return ;

here too

>  	audit_log_format(*ab, "pid=%d uid=%u", pid, uid);
>  	audit_log_session_info(*ab);
>  	audit_log_task_context(*ab);
>  
> -	return rc;
> +	return ;

No return statement necessary here at all

>  }
>  
>  int is_audit_feature_set(int i)






More information about the Linux-audit mailing list