[PATCH] contort getdents64 to pacify gcc-2.96

Adam Kropelin
2005-01-13T03:42:27Z

A recent trivial fixup in sys_getdents64...

> diff -Nru a/fs/readdir.c b/fs/readdir.c
> --- a/fs/readdir.c 2005-01-12 19:22:35 -08:00
> +++ b/fs/readdir.c 2005-01-12 19:22:35 -08:00
> @@ -287,8 +287,9 @@
> lastdirent = buf.previous;
> if (lastdirent) {
> typeof(lastdirent->d_off) d_off = file->f_pos;
> - __put_user(d_off, &lastdirent->d_off);
> error = count - buf.count;
> + if (__put_user(d_off, &lastdirent->d_off))
> + error = -EFAULT;
> }
>
> out_putf:

...gives gcc-2.96 indigestion:

> fs/readdir.c: In function `sys_getdents64':
> fs/readdir.c:299: Unrecognizable insn:
> (insn 166 257 174 (parallel[
> (set (reg/v:SI 6 ebp)
> (asm_operands/v ("1: movl %%eax,0(%2)
> 2: movl %%edx,4(%2)
> 3:
> .section .fixup,"ax"
> 4: movl %3,%0
> jmp 3b
> .previous
> .section __ex_table,"a"
> .align 4
> .long 1b,4b
> .long 2b,4b
> .previous") ("=r") 0[
> (reg:DI 1 edx)
> (reg:SI 0 eax)
> (const_int -14 [0xfffffff2])
> (reg/v:SI 6 ebp)
> ]
> [
> (asm_input:DI ("A"))
> (asm_input:SI ("r"))
> (asm_input:SI ("i"))
> (asm_input:SI ("0"))
> ] ("fs/readdir.c") 291))
> (clobber (reg:QI 19 dirflag))
> (clobber (reg:QI 18 fpsr))
> (clobber (reg:QI 17 flags))
> ] ) -1 (insn_list 132 (insn_list 146 (insn_list 165 (nil))))
> (nil))
> fs/readdir.c:299: confused by earlier errors, bailing out

While upgrading to a sane gcc would be the preferred solution,
rewriting the change as follows eliminates the error for those who
cannot do so.

Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com>

--- linux-2.6.11-rc1.orig/fs/readdir.c Wed Jan 12 22:35:03 2005
+++ linux-2.6.11-rc1/fs/readdir.c Wed Jan 12 22:16:55 2005
@@ -287,9 +287,10 @@
lastdirent = buf.previous;
if (lastdirent) {
typeof(lastdirent->d_off) d_off = file->f_pos;
- error = count - buf.count;
+ error = -EFAULT;
if (__put_user(d_off, &lastdirent->d_off))
- error = -EFAULT;
+ goto out_putf;
+ error = count - buf.count;
}