lkml.org 
[lkml]   [2016]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 0074/1285] Replace numeric parameter like 0444 with macro
Date
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@intel.com>
Signed-off-by: Baole Ni <baolex.ni@intel.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
\
 
 \ /
  Last update: 2016-08-02 21:21    [W:0.025 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site