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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190731050549.GA20809@kroah.com>
Date:   Wed, 31 Jul 2019 07:05:49 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Kalesh Singh <kaleshsingh@...gle.com>
Cc:     rjw@...ysocki.net, trong@...gle.com, trong@...roid.com,
        sspatil@...gle.com, hridya@...gle.com,
        linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH] PM/sleep: Expose suspend stats in sysfs

On Tue, Jul 30, 2019 at 03:52:28PM -0700, Kalesh Singh wrote:
> +#define suspend_attr(_name)						\
> +static ssize_t _name##_show(struct kobject *kobj,			\
> +		struct kobj_attribute *attr, char *buf)			\
> +{									\
> +	int index;							\
> +	enum suspend_stat_step step;					\
> +	char *last_failed_stat = NULL;					\
> +									\
> +	if (strcmp(attr->attr.name, "last_failed_dev") == 0) {		\
> +		index = suspend_stats._name + REC_FAILED_NUM - 1;	\
> +		index %= REC_FAILED_NUM;				\
> +		last_failed_stat = suspend_stats.failed_devs[index];	\
> +		return sprintf(buf, "%s\n", last_failed_stat);		\
> +	} else if (strcmp(attr->attr.name, "last_failed_step") == 0) {	\
> +		index = suspend_stats._name + REC_FAILED_NUM - 1;	\
> +		index %= REC_FAILED_NUM;				\
> +		step = suspend_stats.failed_steps[index];		\
> +		last_failed_stat = suspend_step_name(step);		\
> +		return sprintf(buf, "%s\n", last_failed_stat);		\
> +	} else if (strcmp(attr->attr.name, "last_failed_errno") == 0) {	\
> +		index = suspend_stats._name + REC_FAILED_NUM - 1;	\
> +		index %= REC_FAILED_NUM;				\
> +		return sprintf(buf, "%d\n", suspend_stats.errno[index]);\
> +	}								\

For these 3 "special" ones, just have your own show function, no need to
cram it into this macro, making a bunch of unused code be generated all
the time.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ