Skip to contentSkip to conversation

fs: replace int param with size_t for seq_open_private()

PATCH In review Rob Jones 3 participants 6 messages Sep 1, 2014 – Sep 12, 2014 VFS

lore
Share & tools
lore

Rob Jones

author
#0 lore raw

PATCH 1/1 fs: replace int param with size_t for seq_open_private()

also for __seq_open_private()

Resubmitted due to email address typo.

---
 fs/seq_file.c            |    4 ++--
 include/linux/seq_file.h |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/seq_file.c +2 -2
index 1d641bb..dc2dfec 100644
@@ -640,7 +640,7 @@ int seq_release_private(struct inode *inode, struct file *file)
 EXPORT_SYMBOL(seq_release_private);
 
 void *__seq_open_private(struct file *f, const struct seq_operations *ops,
-		int psize)
+		size_t psize)
 {
 	int rc;
 	void *private;
@@ -666,7 +666,7 @@ out:
 EXPORT_SYMBOL(__seq_open_private);
 
 int seq_open_private(struct file *filp, const struct seq_operations *ops,
-		int psize)
+		size_t psize)
 {
 	return __seq_open_private(filp, ops, psize) ? 0 : -ENOMEM;
 }
include/linux/seq_file.h +2 -2
index 52e0097..9382339 100644
@@ -140,8 +140,8 @@ static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
 int single_open_size(struct file *, int (*)(struct seq_file *, void *), void *, size_t);
 int single_release(struct inode *, struct file *);
-void *__seq_open_private(struct file *, const struct seq_operations *, int);
-int seq_open_private(struct file *, const struct seq_operations *, int);
+void *__seq_open_private(struct file *, const struct seq_operations *, size_t);
+int seq_open_private(struct file *, const struct seq_operations *, size_t);
 int seq_release_private(struct inode *, struct file *);
 int seq_put_decimal_ull(struct seq_file *m, char delimiter,
 			unsigned long long num);
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

Review

Quoted 3 lines · Rob Jones

void *__seq_open_private(struct file *f, const struct seq_operations *ops,

(quoted diff) +1 -1
-		int psize)
+		size_t psize)

<sarcasm>
It is a horrible limitation to impose, indeed. Why, a lousy 2 gigabytes per line in procfs file - that's intolerable... </sarcasm>

author
#2 lore raw
Quoted 11 lines · Al Viro

Review

Quoted 3 lines · Rob Jones

void *__seq_open_private(struct file *f, const struct seq_operations *ops,

(quoted diff) +1 -1
-		int psize)
+		size_t psize)

<sarcasm>
It is a horrible limitation to impose, indeed. Why, a lousy 2 gigabytes per line in procfs file - that's intolerable... </sarcasm>

<shrug>

Consistency?

kmalloc() expects a size_t and I haven't heard anyone whingeing about that.

Ultimately, this function calls kmalloc().

Quoted 1 line
Signature · 4 lines
Rob Jones
Codethink Ltd
mailto:[email protected]
tel:+44 161 236 5575
author
#3 lore raw
In reply to Al Viro
Quoted 12 lines · Al Viro

Review

Quoted 3 lines · Rob Jones

void *__seq_open_private(struct file *f, const struct seq_operations *ops,

(quoted diff) +1 -1
-		int psize)
+		size_t psize)

<sarcasm>
It is a horrible limitation to impose, indeed. Why, a lousy 2 gigabytes per line in procfs file - that's intolerable... </sarcasm>

OK, I know this is a trivial patch but I've gone away and thought about it and done some reading to see what the rest of the world thinks about using size_t vs unsigned int (signed int is an abomination in this context regardless).

I think Al's sarcasm is misplaced.

The correct type to use here *is* size_t. It's about consistency and, more importantly, it's about not making assumptions about the hardware architecture. It's included in the language for very good reasons and it seems to me to be risky to ignore those reasons.

I would like the patch to be considered for inclusion, it costs nothing and could avoid a future problem coming up to bite us in the bum.

Signature · 4 lines
Rob Jones
Codethink Ltd
mailto:[email protected]
tel:+44 161 236 5575
#4 lore raw
Quoted 24 lines · Rob Jones
Quoted 9 lines · Al Viro

Review

Quoted 4 lines · Rob Jones

void *__seq_open_private(struct file *f, const struct seq_operations
*ops,

(quoted diff) +1 -1
-               int psize)
+               size_t psize)
Quoted 6 lines

<sarcasm>
It is a horrible limitation to impose, indeed. Why, a lousy 2 gigabytes per line in procfs file - that's intolerable... </sarcasm>

OK, I know this is a trivial patch but I've gone away and thought about it and done some reading to see what the rest of the world thinks about using size_t vs unsigned int (signed int is an abomination in this context regardless).

Quoted 6 lines

I think Al's sarcasm is misplaced.

The correct type to use here *is* size_t. It's about consistency and, more importantly, it's about not making assumptions about the hardware architecture. It's included in the language for very good reasons and it seems to me to be risky to ignore those reasons.

Please don't forget to patch all for loops to use size_t instead of int too.

Signature · 2 lines
Thanks,
//richard
author
#5 lore raw
Quoted 25 lines · Richard Weinberger
Quoted 24 lines · Rob Jones
Quoted 9 lines · Al Viro

Review

Quoted 4 lines · Rob Jones

void *__seq_open_private(struct file *f, const struct seq_operations
*ops,

(quoted diff) +1 -1
-               int psize)
+               size_t psize)
Quoted 6 lines

<sarcasm>
It is a horrible limitation to impose, indeed. Why, a lousy 2 gigabytes per line in procfs file - that's intolerable... </sarcasm>

OK, I know this is a trivial patch but I've gone away and thought about it and done some reading to see what the rest of the world thinks about using size_t vs unsigned int (signed int is an abomination in this context regardless).

Quoted 9 lines
Quoted 6 lines

I think Al's sarcasm is misplaced.

The correct type to use here *is* size_t. It's about consistency and, more importantly, it's about not making assumptions about the hardware architecture. It's included in the language for very good reasons and it seems to me to be risky to ignore those reasons.

Please don't forget to patch all for loops to use size_t instead of int too.

Yes, I'm sure we've all read that argument too. Now try behaving like a grown up.

Signature · 4 lines
Rob Jones
Codethink Ltd
mailto:[email protected]
tel:+44 161 236 5575