[PATCH] Test p{read,write}64 with offset > 4GB [BZ #20350]

H.J. Lu hjl.tools@gmail.com
Tue Jul 12 15:34:00 GMT 2016


On Tue, Jul 12, 2016 at 7:17 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> LGTM with 2 remarks below.
>
> On 11/07/2016 22:01, H.J. Lu wrote:
>> Test p{read,write}64 with offset > 4GB.  Since it is not an error for a
>> successful pread/pwrite call to transfer fewer bytes than requested, we
>> should check if the return value is -1.   No need to close and unlink
>> temporary file, which is handled by test-skeleton.c.
>>
>> Tested on x86-64 and i686.  OK for trunk?
>>
>> H.J.
>> ---
>>       [BZ #20350]
>>       * posix/tst-preadwrite.c: Renamed to ...
>>       * posix/tst-preadwrite-common.c: This.
>>       (do_prepare): Make it static and remove function arguments.
>>       (do_test): Likewise.
>>       (PREPARE): Updated.
>>       (TEST_FUNCTION): New.
>>       (name): Make it static.
>>       (fd): Likewise.
>>       (do_prepare): Use create_temp_file.
>>       (do_test): Renamed to ...
>>       (do_test_with_offset): This.  Make it static and accept offset.
>>       Properly check return value of PWRITE and PREAD.  Return bytes
>>       read.  Don't close fd nor unlink name.
>>       * posix/tst-preadwrite.c: Rewrite.
>>       * posix/tst-preadwrite64.c: Likewise.
>> ---
>>  posix/tst-preadwrite-common.c | 96 +++++++++++++++++++++++++++++++++++++++++++
>>  posix/tst-preadwrite.c        | 87 ++-------------------------------------
>>  posix/tst-preadwrite64.c      | 40 +++++++++++++++++-
>>  3 files changed, 138 insertions(+), 85 deletions(-)
>>  create mode 100644 posix/tst-preadwrite-common.c
>>
>> diff --git a/posix/tst-preadwrite-common.c b/posix/tst-preadwrite-common.c
>> new file mode 100644
>> index 0000000..67a67af
>> --- /dev/null
>> +++ b/posix/tst-preadwrite-common.c
>> @@ -0,0 +1,96 @@
>> +/* Common definitions for pread and pwrite.
>> +   Copyright (C) 1998-2016 Free Software Foundation, Inc.
>
> I think it should be just 2016.
>
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library; if not, see
>> +   <http://www.gnu.org/licenses/>.  */
>> +
>> +#include <errno.h>
>> +#include <error.h>
>> +#include <string.h>
>> +#include <unistd.h>
>> +
>> +
>> +/* Allow testing of the 64-bit versions as well.  */
>> +#ifndef PREAD
>> +# define PREAD pread
>> +# define PWRITE pwrite
>> +#endif
>
> It we define _FILE_OFFSET_BITS to 64 in tst-preadwrite64, should we still
> use pread64? Could we just use the plain pread/pwrite instead and avoid
> the name redefinition?
>

This is what I checked in.

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Test-p-read-write-64-with-offset-4GB.patch
Type: text/x-patch
Size: 8517 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160712/134b7453/attachment.bin>


More information about the Libc-alpha mailing list