This patch fixes a size of 4th argument in a prototype
in case of _FILE_OFFSET_BITS=64 to match an implementation
on 32 bit architectures
#ifdef __NR_pwritev
ssize_t
pwritev (int fd, const struct iovec *vector, int count, off_t offset)
{
unsigned long pos_l, pos_h;
pos_h = (unsigned long)((long long)offset >> 32);
pos_l = (unsigned long)((long long)offset);
return INLINE_SYSCALL (pwritev, 5, fd, vector, count, pos_l, pos_h);
}
#endif
A simple test program compiled with gcc 7.3 and -Wconversion
#include <stdio.h>
#include <stdint.h>
#include <sys/uio.h>
int main()
{
const off_t ofs = INT64_MAX;
pwritev(0, NULL, 0, ofs);
return 0;
}
gives a warning
test.c:9:22: warning: conversion to '__off_t {aka long int}' from 'off_t
{aka const long long int}' may alter its value [-Wconversion]
pwritev(0, NULL, 0, ofs);
^~~
Without the patch the prototype tells a compiler to pass only 32 bits
to preadv/pwritev definitions that gives a corrupted offset value.
On Mon, Jun 11, 2018 at 6:14 AM, Waldemar Brodkorb <wbx(a)uclibc-ng.org>
wrote:
Hi Sergey,
what does the patch fixes?
Compiler warnings? Runtime issues? ...
best regards
Waldemar
Am 10.06.2018 um 22:28 schrieb Sergey Korolev
<s.korolev(a)ndmsystems.com
:
As preadv and pwritev accept off_t type the prototypes should be
declared as
follows
extern ssize_t preadv (int __fd, const struct iovec *__iovec, int
__count,
off_t __offset) __wur;
extern ssize_t pwritev (int __fd, const struct
iovec *__iovec, int
__count,
off_t __offset) __wur;
to take into account _FILE_OFFSET_BITS=64 define.
I am not sure but probably it is better to redeclare these prototypes
by analogy with sendfile using __REDIRECT_NTH.
<Fix-prototypes-for-preadv-pwritev.patch>
_______________________________________________
devel mailing list
devel(a)uclibc-ng.org
https://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel