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>] [day] [month] [year] [list]
Date:	Tue,  2 Aug 2016 18:38:43 +0800
From:	Baole Ni <baolex.ni@...el.com>
To:	gregkh@...uxfoundation.org, tj@...nel.org, lenb@...nel.org,
	x86@...nel.org, hpa@...or.com
Cc:	linux-kernel@...r.kernel.org, chuansheng.liu@...el.com,
	baolex.ni@...el.com
Subject: [PATCH 0074/1285] Replace numeric parameter like 0444 with macro

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission.
As we know, these numeric value for access permission have had the corresponding macro,
and that using macro can improve the robustness and readability of the code,
thus, I suggest replacing the numeric parameter with the macro.

Signed-off-by: Chuansheng Liu <chuansheng.liu@...el.com>
Signed-off-by: Baole Ni <baolex.ni@...el.com>
---
 drivers/base/cpu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 691eeea..1496146 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -156,7 +156,7 @@ static ssize_t show_crash_notes(struct device *dev, struct device_attribute *att
 	rc = sprintf(buf, "%Lx\n", addr);
 	return rc;
 }
-static DEVICE_ATTR(crash_notes, 0400, show_crash_notes, NULL);
+static DEVICE_ATTR(crash_notes, S_IRUSR, show_crash_notes, NULL);
 
 static ssize_t show_crash_notes_size(struct device *dev,
 				     struct device_attribute *attr,
@@ -167,7 +167,7 @@ static ssize_t show_crash_notes_size(struct device *dev,
 	rc = sprintf(buf, "%zu\n", sizeof(note_buf_t));
 	return rc;
 }
-static DEVICE_ATTR(crash_notes_size, 0400, show_crash_notes_size, NULL);
+static DEVICE_ATTR(crash_notes_size, S_IRUSR, show_crash_notes_size, NULL);
 
 static struct attribute *crash_note_cpu_attrs[] = {
 	&dev_attr_crash_notes.attr,
@@ -231,7 +231,7 @@ static ssize_t print_cpus_kernel_max(struct device *dev,
 	int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1);
 	return n;
 }
-static DEVICE_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
+static DEVICE_ATTR(kernel_max, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_kernel_max, NULL);
 
 /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
 unsigned int total_cpus;
@@ -264,7 +264,7 @@ static ssize_t print_cpus_offline(struct device *dev,
 	n += snprintf(&buf[n], len - n, "\n");
 	return n;
 }
-static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
+static DEVICE_ATTR(offline, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_offline, NULL);
 
 static ssize_t print_cpus_isolated(struct device *dev,
 				  struct device_attribute *attr, char *buf)
@@ -275,7 +275,7 @@ static ssize_t print_cpus_isolated(struct device *dev,
 
 	return n;
 }
-static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
+static DEVICE_ATTR(isolated, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_isolated, NULL);
 
 #ifdef CONFIG_NO_HZ_FULL
 static ssize_t print_cpus_nohz_full(struct device *dev,
@@ -287,7 +287,7 @@ static ssize_t print_cpus_nohz_full(struct device *dev,
 
 	return n;
 }
-static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL);
+static DEVICE_ATTR(nohz_full, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_nohz_full, NULL);
 #endif
 
 static void cpu_device_release(struct device *dev)
@@ -443,7 +443,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata,
 EXPORT_SYMBOL_GPL(cpu_device_create);
 
 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE
-static DEVICE_ATTR(modalias, 0444, print_cpu_modalias, NULL);
+static DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, print_cpu_modalias, NULL);
 #endif
 
 static struct attribute *cpu_root_attrs[] = {
-- 
2.9.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ