lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.0905072243570.28378@gandalf.stny.rr.com>
Date:	Thu, 7 May 2009 22:44:28 -0400 (EDT)
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Li Zefan <lizf@...fujitsu.com>
cc:	Ingo Molnar <mingo@...e.hu>,
	Frederic Weisbecker <fweisbec@...il.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] tracing/events: simplify system_enable_read()


On Fri, 8 May 2009, Li Zefan wrote:

> A smarter way to figure out the output of an enable file.

I wouldn't say "smarter way", but I will not argue a "cleaner way".

-- Steve

> 
> [ Impact: clean up ]
> 
> Signed-off-by: Li Zefan <lizf@...fujitsu.com>
> ---
>  kernel/trace/trace_events.c |   40 ++++++----------------------------------
>  1 files changed, 6 insertions(+), 34 deletions(-)
> 
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 45f1099..df394bc 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -414,10 +414,11 @@ static ssize_t
>  system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
>  		   loff_t *ppos)
>  {
> +	const char set_to_char[4] = { '?', '0', '1', 'X' };
>  	const char *system = filp->private_data;
>  	struct ftrace_event_call *call;
>  	char buf[2];
> -	int set = -1;
> +	int set = 0;
>  	int ret;
>  
>  	mutex_lock(&event_mutex);
> @@ -433,47 +434,18 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
>  		 * or if all events or cleared, or if we have
>  		 * a mixture.
>  		 */
> -		if (call->enabled) {
> -			switch (set) {
> -			case -1:
> -				set = 1;
> -				break;
> -			case 0:
> -				set = 2;
> -				break;
> -			}
> -		} else {
> -			switch (set) {
> -			case -1:
> -				set = 0;
> -				break;
> -			case 1:
> -				set = 2;
> -				break;
> -			}
> -		}
> +		set |= (1 << !!call->enabled);
> +
>  		/*
>  		 * If we have a mixture, no need to look further.
>  		 */
> -		if (set == 2)
> +		if (set == 3)
>  			break;
>  	}
>  	mutex_unlock(&event_mutex);
>  
> +	buf[0] = set_to_char[set];
>  	buf[1] = '\n';
> -	switch (set) {
> -	case 0:
> -		buf[0] = '0';
> -		break;
> -	case 1:
> -		buf[0] = '1';
> -		break;
> -	case 2:
> -		buf[0] = 'X';
> -		break;
> -	default:
> -		buf[0] = '?';
> -	}
>  
>  	ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
>  
> -- 
> 1.5.4.rc3
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ