Skip to content

Commit 1330976

Browse files
Alexey Dobriyanakpm00
authored andcommitted
proc: use __auto_type more
Switch away from quite chatty declarations using typeof_member(). In theory this is faster to compile too because there is no macro expansion and there is less type checking. Link: https://lkml.kernel.org/r/81bf02fd-8724-4f4d-a2bb-c59620b7d716@p183 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent dab2214 commit 1330976

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

fs/proc/inode.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,7 @@ static ssize_t proc_reg_read_iter(struct kiocb *iocb, struct iov_iter *iter)
303303

304304
static ssize_t pde_read(struct proc_dir_entry *pde, struct file *file, char __user *buf, size_t count, loff_t *ppos)
305305
{
306-
typeof_member(struct proc_ops, proc_read) read;
307-
308-
read = pde->proc_ops->proc_read;
306+
__auto_type read = pde->proc_ops->proc_read;
309307
if (read)
310308
return read(file, buf, count, ppos);
311309
return -EIO;
@@ -327,9 +325,7 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count,
327325

328326
static ssize_t pde_write(struct proc_dir_entry *pde, struct file *file, const char __user *buf, size_t count, loff_t *ppos)
329327
{
330-
typeof_member(struct proc_ops, proc_write) write;
331-
332-
write = pde->proc_ops->proc_write;
328+
__auto_type write = pde->proc_ops->proc_write;
333329
if (write)
334330
return write(file, buf, count, ppos);
335331
return -EIO;
@@ -351,9 +347,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t
351347

352348
static __poll_t pde_poll(struct proc_dir_entry *pde, struct file *file, struct poll_table_struct *pts)
353349
{
354-
typeof_member(struct proc_ops, proc_poll) poll;
355-
356-
poll = pde->proc_ops->proc_poll;
350+
__auto_type poll = pde->proc_ops->proc_poll;
357351
if (poll)
358352
return poll(file, pts);
359353
return DEFAULT_POLLMASK;
@@ -375,9 +369,7 @@ static __poll_t proc_reg_poll(struct file *file, struct poll_table_struct *pts)
375369

376370
static long pde_ioctl(struct proc_dir_entry *pde, struct file *file, unsigned int cmd, unsigned long arg)
377371
{
378-
typeof_member(struct proc_ops, proc_ioctl) ioctl;
379-
380-
ioctl = pde->proc_ops->proc_ioctl;
372+
__auto_type ioctl = pde->proc_ops->proc_ioctl;
381373
if (ioctl)
382374
return ioctl(file, cmd, arg);
383375
return -ENOTTY;
@@ -400,9 +392,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
400392
#ifdef CONFIG_COMPAT
401393
static long pde_compat_ioctl(struct proc_dir_entry *pde, struct file *file, unsigned int cmd, unsigned long arg)
402394
{
403-
typeof_member(struct proc_ops, proc_compat_ioctl) compat_ioctl;
404-
405-
compat_ioctl = pde->proc_ops->proc_compat_ioctl;
395+
__auto_type compat_ioctl = pde->proc_ops->proc_compat_ioctl;
406396
if (compat_ioctl)
407397
return compat_ioctl(file, cmd, arg);
408398
return -ENOTTY;
@@ -424,9 +414,7 @@ static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned
424414

425415
static int pde_mmap(struct proc_dir_entry *pde, struct file *file, struct vm_area_struct *vma)
426416
{
427-
typeof_member(struct proc_ops, proc_mmap) mmap;
428-
429-
mmap = pde->proc_ops->proc_mmap;
417+
__auto_type mmap = pde->proc_ops->proc_mmap;
430418
if (mmap)
431419
return mmap(file, vma);
432420
return -EIO;
@@ -483,7 +471,6 @@ static int proc_reg_open(struct inode *inode, struct file *file)
483471
struct proc_dir_entry *pde = PDE(inode);
484472
int rv = 0;
485473
typeof_member(struct proc_ops, proc_open) open;
486-
typeof_member(struct proc_ops, proc_release) release;
487474
struct pde_opener *pdeo;
488475

489476
if (!pde->proc_ops->proc_lseek)
@@ -510,7 +497,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
510497
if (!use_pde(pde))
511498
return -ENOENT;
512499

513-
release = pde->proc_ops->proc_release;
500+
__auto_type release = pde->proc_ops->proc_release;
514501
if (release) {
515502
pdeo = kmem_cache_alloc(pde_opener_cache, GFP_KERNEL);
516503
if (!pdeo) {
@@ -547,9 +534,7 @@ static int proc_reg_release(struct inode *inode, struct file *file)
547534
struct pde_opener *pdeo;
548535

549536
if (pde_is_permanent(pde)) {
550-
typeof_member(struct proc_ops, proc_release) release;
551-
552-
release = pde->proc_ops->proc_release;
537+
__auto_type release = pde->proc_ops->proc_release;
553538
if (release) {
554539
return release(inode, file);
555540
}

0 commit comments

Comments
 (0)