Messages in this thread Patch in this message | | | Date | Tue, 24 Apr 2018 00:39:54 +0300 | From | Alexey Dobriyan <> | Subject | [PATCH] proc: skip branch in /proc/*/* lookup |
| |
Code is structured like this:
for ( ... p < last; p++) { if (memcmp == 0) break; } if (p >= last) ERROR OK
gcc doesn't see that if if lookup succeeds than post loop branch will never be taken and skip it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> ---
fs/proc/base.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
--- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2485,14 +2485,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir, for (p = ents; p < last; p++) { if (p->len != dentry->d_name.len) continue; - if (!memcmp(dentry->d_name.name, p->name, p->len)) + if (!memcmp(dentry->d_name.name, p->name, p->len)) { + error = proc_pident_instantiate(dir, dentry, task, p); break; + } } - if (p >= last) - goto out; - - error = proc_pident_instantiate(dir, dentry, task, p); -out: put_task_struct(task); out_no_task: return ERR_PTR(error);
| |