[Ocfs2-test-devel] [PATCH] splice: fix splice() conflicted definitions

Coly Li coly.li at suse.de
Sun Mar 22 23:12:47 PDT 2009



tristan.ye Wrote:
> On Sat, 2009-03-21 at 01:54 +0800, Coly Li wrote:
>> the splice() defined in programs/splice/splice_test.h is conflicted with the one
>> defined in /usr/include/bits/fcntl.h, which results a compiling error:
>>
>> splice_test.h:35: error: conflicting types for ‘splice’
>> /usr/include/bits/fcntl.h:244: error: previous declaration of ‘splice’ was here
>>
>> This patch fixes the compiling error. When people wants to test the code with
>> splice() from libc, just define USE_LIBC_SPLICE.
>>
>> Signed-off-by: Coly Li <coly.li at suse.de>
>> ---
>>  programs/splice/splice_test.h |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/programs/splice/splice_test.h b/programs/splice/splice_test.h
>> index 5113bbb..9a223d3 100644
>> --- a/programs/splice/splice_test.h
>> +++ b/programs/splice/splice_test.h
>> @@ -31,9 +31,12 @@
>>  #error unsupported arch
>>  #endif
>>
>> -int splice(int fdin, loff_t *off_in, int fdout,
>> +int test_splice(int fdin, loff_t *off_in, int fdout,
>>  			 loff_t *off_out, size_t len, unsigned int flags)
>>  {
>>  	return syscall(__NR_splice, fdin, off_in, fdout, off_out, len, flags);
>>  }
>>
>> +#ifndef USE_LIBC_SPLICE
>> +#define splice test_splice
>> +#endif
> 
> shouldn't it be following:
> 
> #ifndef USE_LIBC_SPLICE
> int test_splice(int fdin, loff_t *off_in, int fdout,
>                          loff_t *off_out, size_t len, unsigned int
> flags)
> {
>         return syscall(__NR_splice, fdin, off_in, fdout, off_out, len,
> flags);
> }
> 
> #define splice test_splice
> #else
> int splice(int fdin, loff_t *off_in, int fdout,
>                          loff_t *off_out, size_t len, unsigned int
> flags)
> {
>         return syscall(__NR_splice, fdin, off_in, fdout, off_out, len,
> flags);
> }
> 
when USE_LIBC_SPLICE is not defined, splice() defined here will conflict with
the one from glibc. That's why I rename non-glibc splice() to test_splice() when
USE_GLIBC_SPLICE is define.


-- 
Coly Li
SuSE Labs



More information about the Ocfs2-test-devel mailing list