Skip to content

Commit 15ad7cd

Browse files
hdellerLinus Torvalds
authored andcommitted
[PATCH] struct seq_operations and struct file_operations constification
- move some file_operations structs into the .rodata section - move static strings from policy_types[] array into the .rodata section - fix generic seq_operations usages, so that those structs may be defined as "const" as well [akpm@osdl.org: couple of fixes] Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 4a08a9f commit 15ad7cd

25 files changed

Lines changed: 40 additions & 40 deletions

‎fs/seq_file.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* ERR_PTR(error). In the end of sequence they return %NULL. ->show()
2727
* returns 0 in case of success and negative number in case of error.
2828
*/
29-
int seq_open(struct file *file, struct seq_operations *op)
29+
int seq_open(struct file *file, const struct seq_operations *op)
3030
{
3131
struct seq_file *p = file->private_data;
3232

@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open);
408408

409409
int single_release(struct inode *inode, struct file *file)
410410
{
411-
struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
411+
const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
412412
int res = seq_release(inode, file);
413413
kfree(op);
414414
return res;

‎include/linux/cpuset.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
4646
extern int cpuset_memory_pressure_enabled;
4747
extern void __cpuset_memory_pressure_bump(void);
4848

49-
extern struct file_operations proc_cpuset_operations;
49+
extern const struct file_operations proc_cpuset_operations;
5050
extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
5151

5252
extern void cpuset_lock(void);

‎include/linux/mmzone.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ struct zone {
278278
/*
279279
* rarely used fields:
280280
*/
281-
char *name;
281+
const char *name;
282282
} ____cacheline_internodealigned_in_smp;
283283

284284
/*

‎include/linux/relay.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
274274
/*
275275
* exported relay file operations, kernel/relay.c
276276
*/
277-
extern struct file_operations relay_file_operations;
277+
extern const struct file_operations relay_file_operations;
278278

279279
#endif /* _LINUX_RELAY_H */
280280

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ struct sched_info {
573573
#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
574574

575575
#ifdef CONFIG_SCHEDSTATS
576-
extern struct file_operations proc_schedstat_operations;
576+
extern const struct file_operations proc_schedstat_operations;
577577
#endif /* CONFIG_SCHEDSTATS */
578578

579579
#ifdef CONFIG_TASK_DELAY_ACCT

‎include/linux/seq_file.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct seq_file {
2020
loff_t index;
2121
loff_t version;
2222
struct mutex lock;
23-
struct seq_operations *op;
23+
const struct seq_operations *op;
2424
void *private;
2525
};
2626

@@ -31,7 +31,7 @@ struct seq_operations {
3131
int (*show) (struct seq_file *m, void *v);
3232
};
3333

34-
int seq_open(struct file *, struct seq_operations *);
34+
int seq_open(struct file *, const struct seq_operations *);
3535
ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
3636
loff_t seq_lseek(struct file *, loff_t, int);
3737
int seq_release(struct inode *, struct file *);

‎kernel/configs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
7575
return count;
7676
}
7777

78-
static struct file_operations ikconfig_file_ops = {
78+
static const struct file_operations ikconfig_file_ops = {
7979
.owner = THIS_MODULE,
8080
.read = ikconfig_read_current,
8181
};

‎kernel/cpuset.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry,
15311531
return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
15321532
}
15331533

1534-
static struct file_operations cpuset_file_operations = {
1534+
static const struct file_operations cpuset_file_operations = {
15351535
.read = cpuset_file_read,
15361536
.write = cpuset_file_write,
15371537
.llseek = generic_file_llseek,
@@ -2605,7 +2605,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
26052605
return single_open(file, proc_cpuset_show, pid);
26062606
}
26072607

2608-
struct file_operations proc_cpuset_operations = {
2608+
const struct file_operations proc_cpuset_operations = {
26092609
.open = cpuset_open,
26102610
.read = seq_read,
26112611
.llseek = seq_lseek,

‎kernel/dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file)
140140
return single_open(file, proc_dma_show, NULL);
141141
}
142142

143-
static struct file_operations proc_dma_operations = {
143+
static const struct file_operations proc_dma_operations = {
144144
.open = proc_dma_open,
145145
.read = seq_read,
146146
.llseek = seq_lseek,

‎kernel/futex.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp,
14921492
return ret;
14931493
}
14941494

1495-
static struct file_operations futex_fops = {
1495+
static const struct file_operations futex_fops = {
14961496
.release = futex_close,
14971497
.poll = futex_poll,
14981498
};

0 commit comments

Comments
 (0)