* [PATCH] proc: constify status array
@ 2011-03-30 6:09 Mike Frysinger
2011-03-30 9:56 ` Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2011-03-30 6:09 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
No need for this local array to be writable, so mark it const.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
fs/proc/array.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 5e4f776..9b45ee8 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -131,7 +131,7 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
* you can test for combinations of others with
* simple bit tests.
*/
-static const char *task_state_array[] = {
+static const char * const task_state_array[] = {
"R (running)", /* 0 */
"S (sleeping)", /* 1 */
"D (disk sleep)", /* 2 */
@@ -147,7 +147,7 @@ static const char *task_state_array[] = {
static inline const char *get_task_state(struct task_struct *tsk)
{
unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
- const char **p = &task_state_array[0];
+ const char * const *p = &task_state_array[0];
BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
--
1.7.4.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] proc: constify status array
2011-03-30 6:09 [PATCH] proc: constify status array Mike Frysinger
@ 2011-03-30 9:56 ` Alexey Dobriyan
2011-03-30 10:03 ` Mike Frysinger
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2011-03-30 9:56 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Andrew Morton, linux-kernel
On Wed, Mar 30, 2011 at 9:09 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> -static const char *task_state_array[] = {
> +static const char * const task_state_array[] = {
Why this is needed for task_state_array, but not for, say, tgid_base_stuff?
00000000000000e0 d task_state_array
0000000000000a50 r tgid_base_stuff
This double const is ugly.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] proc: constify status array
2011-03-30 9:56 ` Alexey Dobriyan
@ 2011-03-30 10:03 ` Mike Frysinger
0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2011-03-30 10:03 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Andrew Morton, linux-kernel
On Wed, Mar 30, 2011 at 05:56, Alexey Dobriyan wrote:
> On Wed, Mar 30, 2011 at 9:09 AM, Mike Frysinger wrote:
>> -static const char *task_state_array[] = {
>> +static const char * const task_state_array[] = {
>
> Why this is needed for task_state_array, but not for, say, tgid_base_stuff?
tgid_base_stuff is already declared const. which your nm output clearly shows.
> This double const is ugly.
quite the opposite. not declaring const arrays const is ugly.
-mike
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-30 10:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 6:09 [PATCH] proc: constify status array Mike Frysinger
2011-03-30 9:56 ` Alexey Dobriyan
2011-03-30 10:03 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®