* [LTP] reason of pwritev01_64 failure on 32-bit arm
@ 2016-09-02 15:58 Nikita Yushchenko
2016-09-05 10:54 ` Jan Stancek
0 siblings, 1 reply; 6+ messages in thread
From: Nikita Yushchenko @ 2016-09-02 15:58 UTC (permalink / raw)
To: ltp
Hi,
I've reproduced and analyzed failure of pwritev01_64 described at [1]
[1] http://lists.linux.it/pipermail/ltp/2016-March/001201.html
pwritev01_64 fail is an LTP issue
pwrite01 and pwrite01_64 are built from the same source, pwrite01.c
64-bit version is built with additional define, -D_FILE_OFFSET_BITS=64,
which causes 'off_t' type defined by glibc to become 64-bit.
Problem is that both pwrite01.o and pwrite01_64.o link against the same
utility library, libltp
From this library, a routine called safe_pread() is used.
One of arguments of this routine has type off_t.
This means that ABI for this routine is different when built with
-D_FILE_OFFSET_BITS=64 and without it.
Library is built without -D_FILE_OFFSET_BITS=64, thus on 32-bit platform
safe_pread() inside library expects ABI with 32-bit 'off_t'. And
pwrite01_64.o, built with -D_FILE_OFFSET_BITS=64, uses different ABI.
If a copy of safe_pread() is injected inside pwrite01.c (and compile
issue is resolved), test passes.
In general, it is not safe to link together object files built with and
without -D_FILE_OFFSET_BITS=64, since that code is not always
binary-compatible.
On 64-bit platform, sizeof(off_t) is 8 both with and without
-D_FILE_OFFSET_BITS=64, this issue does not show.
WBR,
Nikita Yushchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] reason of pwritev01_64 failure on 32-bit arm
2016-09-02 15:58 [LTP] reason of pwritev01_64 failure on 32-bit arm Nikita Yushchenko
@ 2016-09-05 10:54 ` Jan Stancek
2016-09-27 11:58 ` [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline Nikita Yushchenko
0 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2016-09-05 10:54 UTC (permalink / raw)
To: ltp
----- Original Message -----
> From: "Nikita Yushchenko" <nyushchenko@dev.rtsoft.ru>
> To: ltp@lists.linux.it
> Cc: "arusalin" <arusalin@dev.rtsoft.ru>
> Sent: Friday, 2 September, 2016 5:58:51 PM
> Subject: [LTP] reason of pwritev01_64 failure on 32-bit arm
>
> Hi,
>
> I've reproduced and analyzed failure of pwritev01_64 described at [1]
>
> [1] http://lists.linux.it/pipermail/ltp/2016-March/001201.html
>
>
> pwritev01_64 fail is an LTP issue
>
> pwrite01 and pwrite01_64 are built from the same source, pwrite01.c
> 64-bit version is built with additional define, -D_FILE_OFFSET_BITS=64,
> which causes 'off_t' type defined by glibc to become 64-bit.
>
> Problem is that both pwrite01.o and pwrite01_64.o link against the same
> utility library, libltp
> From this library, a routine called safe_pread() is used.
> One of arguments of this routine has type off_t.
> This means that ABI for this routine is different when built with
> -D_FILE_OFFSET_BITS=64 and without it.
> Library is built without -D_FILE_OFFSET_BITS=64, thus on 32-bit platform
> safe_pread() inside library expects ABI with 32-bit 'off_t'. And
> pwrite01_64.o, built with -D_FILE_OFFSET_BITS=64, uses different ABI.
>
> If a copy of safe_pread() is injected inside pwrite01.c (and compile
> issue is resolved), test passes.
>
> In general, it is not safe to link together object files built with and
> without -D_FILE_OFFSET_BITS=64, since that code is not always
> binary-compatible.
>
>
> On 64-bit platform, sizeof(off_t) is 8 both with and without
> -D_FILE_OFFSET_BITS=64, this issue does not show.
Hi,
Thanks for following up on this. Looks like we should do same thing for
pread/pwrite as we already do for lseek, that is to move these
from lib to headers as inline functions:
$ grep -B2 off_t -r lib/*.c
lib/safe_macros.c-ssize_t safe_pread(const char *file, const int lineno, void (*cleanup_fn)(void),
lib/safe_macros.c- char len_strict, int fildes, void *buf, size_t nbyte,
lib/safe_macros.c: off_t offset)
--
lib/safe_macros.c-ssize_t safe_pwrite(const char *file, const int lineno,
lib/safe_macros.c- void (cleanup_fn) (void), char len_strict, int fildes,
lib/safe_macros.c: const void *buf, size_t nbyte, off_t offset)
Are you planning to submit a patch?
Regards,
Jan
>
> WBR,
> Nikita Yushchenko
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline
2016-09-05 10:54 ` Jan Stancek
@ 2016-09-27 11:58 ` Nikita Yushchenko
2016-09-27 12:56 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: Nikita Yushchenko @ 2016-09-27 11:58 UTC (permalink / raw)
To: ltp
These routines have an argument of type off_t, which has size dependent
on compile options on 32-bit builds. Thus having there rotines compiled
inside library cause ABI issues.
Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
include/old/safe_macros.h | 39 +++++++++++++++++++++++++++++++++++++++
include/safe_macros_fn.h | 8 --------
include/tst_safe_macros.h | 39 +++++++++++++++++++++++++++++++++++++++
lib/safe_macros.c | 32 --------------------------------
4 files changed, 78 insertions(+), 40 deletions(-)
diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
index 8ed2eb4..e3be1f2 100644
--- a/include/old/safe_macros.h
+++ b/include/old/safe_macros.h
@@ -70,6 +70,26 @@
safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pread(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pread(fildes, buf, nbyte, offset);
+
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pread(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PREAD(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
safe_pread(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte), (offset))
@@ -112,6 +132,25 @@
safe_write(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pwrite(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, const void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pwrite(fildes, buf, nbyte, offset);
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pwrite(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PWRITE(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
safe_pwrite(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte), (offset))
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index 121a8fb..dcea775 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -71,10 +71,6 @@ ssize_t safe_read(const char *file, const int lineno,
void (*cleanup_fn)(void), char len_strict, int fildes,
void *buf, size_t nbyte);
-ssize_t safe_pread(const char *file, const int lineno,
- void (*cleanup_fn)(void), char len_strict,
- int fildes, void *buf, size_t nbyte, off_t offset);
-
int safe_setegid(const char *file, const int lineno,
void (*cleanup_fn)(void), gid_t egid);
@@ -118,10 +114,6 @@ ssize_t safe_write(const char *file, const int lineno,
void (cleanup_fn)(void), char len_strict, int fildes,
const void *buf, size_t nbyte);
-ssize_t safe_pwrite(const char *file, const int lineno,
- void (cleanup_fn)(void), char len_strict, int fildes,
- const void *buf, size_t nbyte, off_t offset);
-
long safe_strtol(const char *file, const int lineno,
void (cleanup_fn)(void), char *str, long min, long max);
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 3cf154e..ff4ef49 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -97,6 +97,26 @@ static inline int safe_dup(const char *file, const int lineno,
#define SAFE_READ(len_strict, fildes, buf, nbyte) \
safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pread(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pread(fildes, buf, nbyte, offset);
+
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pread(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PREAD(len_strict, fildes, buf, nbyte, offset) \
safe_pread(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
(buf), (nbyte), (offset))
@@ -170,6 +190,25 @@ static inline pid_t safe_getpgid(const char *file, const int lineno,
#define SAFE_WRITE(len_strict, fildes, buf, nbyte) \
safe_write(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pwrite(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, const void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pwrite(fildes, buf, nbyte, offset);
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pwrite(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PWRITE(len_strict, fildes, buf, nbyte, offset) \
safe_pwrite(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
(buf), (nbyte), (offset))
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 5a05c84..6c96091 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -252,22 +252,6 @@ ssize_t safe_read(const char *file, const int lineno, void (*cleanup_fn) (void),
return rval;
}
-ssize_t safe_pread(const char *file, const int lineno, void (*cleanup_fn)(void),
- char len_strict, int fildes, void *buf, size_t nbyte,
- off_t offset)
-{
- ssize_t rval;
-
- rval = pread(fildes, buf, nbyte, offset);
- if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
- tst_brkm(TBROK | TERRNO, cleanup_fn,
- "%s:%d: read(%d,%p,%zu,%ld) failed, returned %zd",
- file, lineno, fildes, buf, nbyte, offset, rval);
- }
-
- return rval;
-}
-
int safe_setegid(const char *file, const int lineno, void (*cleanup_fn) (void),
gid_t egid)
{
@@ -458,22 +442,6 @@ ssize_t safe_write(const char *file, const int lineno, void (cleanup_fn) (void),
return rval;
}
-ssize_t safe_pwrite(const char *file, const int lineno,
- void (cleanup_fn) (void), char len_strict, int fildes,
- const void *buf, size_t nbyte, off_t offset)
-{
- ssize_t rval;
-
- rval = pwrite(fildes, buf, nbyte, offset);
- if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
- tst_brkm(TBROK | TERRNO, cleanup_fn,
- "%s:%d: pwrite(%d,%p,%zu,%ld) failed",
- file, lineno, fildes, buf, rval, offset);
- }
-
- return rval;
-}
-
long safe_strtol(const char *file, const int lineno,
void (cleanup_fn) (void), char *str, long min, long max)
{
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline
2016-09-27 11:58 ` [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline Nikita Yushchenko
@ 2016-09-27 12:56 ` Cyril Hrubis
2016-11-26 8:30 ` Nikita Yushchenko
0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2016-09-27 12:56 UTC (permalink / raw)
To: ltp
Hi!
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 3cf154e..ff4ef49 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -97,6 +97,26 @@ static inline int safe_dup(const char *file, const int lineno,
> #define SAFE_READ(len_strict, fildes, buf, nbyte) \
> safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
>
> +/*
> + * inline function that uses off_t since sizeof(off_t) depends on compile flags
> + */
> +static inline ssize_t safe_pread(const char *file, const int lineno,
> + void (*cleanup_fn)(void), char len_strict,
> + int fildes, void *buf, size_t nbyte, off_t offset)
> +{
> + ssize_t rval;
> +
> + rval = pread(fildes, buf, nbyte, offset);
> +
> + if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
> + tst_brkm(TBROK | TERRNO, cleanup_fn,
> + "%s:%d: pread(%d,%p,%zu,%lld) failed, returned %zd",
> + file, lineno, fildes, buf, nbyte, (long long)offset,
> + rval);
> + }
> +
> + return rval;
> +}
> #define SAFE_PREAD(len_strict, fildes, buf, nbyte, offset) \
> safe_pread(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
> (buf), (nbyte), (offset))
> @@ -170,6 +190,25 @@ static inline pid_t safe_getpgid(const char *file, const int lineno,
> #define SAFE_WRITE(len_strict, fildes, buf, nbyte) \
> safe_write(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
>
> +/*
> + * inline function that uses off_t since sizeof(off_t) depends on compile flags
> + */
We already have a comment in this file explaining why there are a few
inline functions so I would omit these.
> +static inline ssize_t safe_pwrite(const char *file, const int lineno,
> + void (*cleanup_fn)(void), char len_strict,
> + int fildes, const void *buf, size_t nbyte, off_t offset)
> +{
> + ssize_t rval;
> +
> + rval = pwrite(fildes, buf, nbyte, offset);
> + if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
> + tst_brkm(TBROK | TERRNO, cleanup_fn,
> + "%s:%d: pwrite(%d,%p,%zu,%lld) failed, returned %zd",
> + file, lineno, fildes, buf, nbyte, (long long)offset,
> + rval);
> + }
> +
> + return rval;
> +}
> #define SAFE_PWRITE(len_strict, fildes, buf, nbyte, offset) \
> safe_pwrite(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
> (buf), (nbyte), (offset))
These newlib inline function should omit the cleanup_fn parameter and
use tst_brk_() instead.
Otherwise it looks fine.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline
2016-09-27 12:56 ` Cyril Hrubis
@ 2016-11-26 8:30 ` Nikita Yushchenko
2016-11-28 15:45 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: Nikita Yushchenko @ 2016-11-26 8:30 UTC (permalink / raw)
To: ltp
These routines have an argument of type off_t, which has size dependent
on compile options on 32-bit builds. Thus having there rotines compiled
inside library cause ABI issues.
Signed-off-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
---
include/old/safe_macros.h | 39 +++++++++++++++++++++++++++++++++++++++
include/safe_macros_fn.h | 8 --------
include/tst_safe_macros.h | 38 ++++++++++++++++++++++++++++++++++++--
lib/safe_macros.c | 32 --------------------------------
4 files changed, 75 insertions(+), 42 deletions(-)
diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
index 8ed2eb4..e3be1f2 100644
--- a/include/old/safe_macros.h
+++ b/include/old/safe_macros.h
@@ -70,6 +70,26 @@
safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pread(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pread(fildes, buf, nbyte, offset);
+
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pread(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PREAD(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
safe_pread(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte), (offset))
@@ -112,6 +132,25 @@
safe_write(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pwrite(const char *file, const int lineno,
+ void (*cleanup_fn)(void), char len_strict,
+ int fildes, const void *buf, size_t nbyte, off_t offset)
+{
+ ssize_t rval;
+
+ rval = pwrite(fildes, buf, nbyte, offset);
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brkm(TBROK | TERRNO, cleanup_fn,
+ "%s:%d: pwrite(%d,%p,%zu,%lld) failed, returned %zd",
+ file, lineno, fildes, buf, nbyte, (long long)offset,
+ rval);
+ }
+
+ return rval;
+}
#define SAFE_PWRITE(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
safe_pwrite(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
(buf), (nbyte), (offset))
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index 121a8fb..dcea775 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -71,10 +71,6 @@ ssize_t safe_read(const char *file, const int lineno,
void (*cleanup_fn)(void), char len_strict, int fildes,
void *buf, size_t nbyte);
-ssize_t safe_pread(const char *file, const int lineno,
- void (*cleanup_fn)(void), char len_strict,
- int fildes, void *buf, size_t nbyte, off_t offset);
-
int safe_setegid(const char *file, const int lineno,
void (*cleanup_fn)(void), gid_t egid);
@@ -118,10 +114,6 @@ ssize_t safe_write(const char *file, const int lineno,
void (cleanup_fn)(void), char len_strict, int fildes,
const void *buf, size_t nbyte);
-ssize_t safe_pwrite(const char *file, const int lineno,
- void (cleanup_fn)(void), char len_strict, int fildes,
- const void *buf, size_t nbyte, off_t offset);
-
long safe_strtol(const char *file, const int lineno,
void (cleanup_fn)(void), char *str, long min, long max);
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 59cba1a..e91dbd2 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -97,8 +97,27 @@ static inline int safe_dup(const char *file, const int lineno,
#define SAFE_READ(len_strict, fildes, buf, nbyte) \
safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
+/*
+ * inline function that uses off_t since sizeof(off_t) depends on compile flags
+ */
+static inline ssize_t safe_pread(const char *file, const int lineno,
+ char len_strict, int fildes, void *buf, size_t nbyte,
+ off_t offset)
+{
+ ssize_t rval;
+
+ rval = pread(fildes, buf, nbyte, offset);
+
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "pread(%d,%p,%zu,%lld) failed",
+ fildes, buf, nbyte, (long long)offset);
+ }
+
+ return rval;
+}
#define SAFE_PREAD(len_strict, fildes, buf, nbyte, offset) \
- safe_pread(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
+ safe_pread(__FILE__, __LINE__, (len_strict), (fildes), \
(buf), (nbyte), (offset))
#define SAFE_SETEGID(egid) \
@@ -170,8 +189,23 @@ static inline pid_t safe_getpgid(const char *file, const int lineno,
#define SAFE_WRITE(len_strict, fildes, buf, nbyte) \
safe_write(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
+static inline ssize_t safe_pwrite(const char *file, const int lineno,
+ char len_strict, int fildes, const void *buf, size_t nbyte,
+ off_t offset)
+{
+ ssize_t rval;
+
+ rval = pwrite(fildes, buf, nbyte, offset);
+ if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "pwrite(%d,%p,%zu,%lld) failed",
+ fildes, buf, nbyte, (long long)offset);
+ }
+
+ return rval;
+}
#define SAFE_PWRITE(len_strict, fildes, buf, nbyte, offset) \
- safe_pwrite(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
+ safe_pwrite(__FILE__, __LINE__, (len_strict), (fildes), \
(buf), (nbyte), (offset))
#define SAFE_STRTOL(str, min, max) \
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index b97f43d..31dc61c 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -252,22 +252,6 @@ ssize_t safe_read(const char *file, const int lineno, void (*cleanup_fn) (void),
return rval;
}
-ssize_t safe_pread(const char *file, const int lineno, void (*cleanup_fn)(void),
- char len_strict, int fildes, void *buf, size_t nbyte,
- off_t offset)
-{
- ssize_t rval;
-
- rval = pread(fildes, buf, nbyte, offset);
- if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
- tst_brkm(TBROK | TERRNO, cleanup_fn,
- "%s:%d: read(%d,%p,%zu,%ld) failed, returned %zd",
- file, lineno, fildes, buf, nbyte, offset, rval);
- }
-
- return rval;
-}
-
int safe_setegid(const char *file, const int lineno, void (*cleanup_fn) (void),
gid_t egid)
{
@@ -458,22 +442,6 @@ ssize_t safe_write(const char *file, const int lineno, void (cleanup_fn) (void),
return rval;
}
-ssize_t safe_pwrite(const char *file, const int lineno,
- void (cleanup_fn) (void), char len_strict, int fildes,
- const void *buf, size_t nbyte, off_t offset)
-{
- ssize_t rval;
-
- rval = pwrite(fildes, buf, nbyte, offset);
- if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
- tst_brkm(TBROK | TERRNO, cleanup_fn,
- "%s:%d: pwrite(%d,%p,%zu,%ld) failed",
- file, lineno, fildes, buf, rval, offset);
- }
-
- return rval;
-}
-
long safe_strtol(const char *file, const int lineno,
void (cleanup_fn) (void), char *str, long min, long max)
{
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline
2016-11-26 8:30 ` Nikita Yushchenko
@ 2016-11-28 15:45 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2016-11-28 15:45 UTC (permalink / raw)
To: ltp
Hi!
> diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
> index 8ed2eb4..e3be1f2 100644
> --- a/include/old/safe_macros.h
> +++ b/include/old/safe_macros.h
> @@ -70,6 +70,26 @@
> safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
> (buf), (nbyte))
>
> +/*
> + * inline function that uses off_t since sizeof(off_t) depends on compile flags
> + */
> +static inline ssize_t safe_pread(const char *file, const int lineno,
> + void (*cleanup_fn)(void), char len_strict,
> + int fildes, void *buf, size_t nbyte, off_t offset)
> +{
> + ssize_t rval;
> +
> + rval = pread(fildes, buf, nbyte, offset);
> +
> + if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
> + tst_brkm(TBROK | TERRNO, cleanup_fn,
> + "%s:%d: pread(%d,%p,%zu,%lld) failed, returned %zd",
> + file, lineno, fildes, buf, nbyte, (long long)offset,
> + rval);
> + }
> +
> + return rval;
> +}
> #define SAFE_PREAD(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
> safe_pread(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
> (buf), (nbyte), (offset))
> @@ -112,6 +132,25 @@
> safe_write(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
> (buf), (nbyte))
>
I've removed this part (SAFE_PREAD in old library headers), since the
old library is deprecated and there are more users for this function.
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-11-28 15:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-02 15:58 [LTP] reason of pwritev01_64 failure on 32-bit arm Nikita Yushchenko
2016-09-05 10:54 ` Jan Stancek
2016-09-27 11:58 ` [LTP] [PATCH] safe_macros: make safe_pread() and safe_pwrite() inline Nikita Yushchenko
2016-09-27 12:56 ` Cyril Hrubis
2016-11-26 8:30 ` Nikita Yushchenko
2016-11-28 15:45 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.