Skip to contentSkip to conversation

sendfile0{2,9}: Remove OFF_T workaround

PATCH New Petr Vorel 2 participants 4 messages May 26, 2021 – Jun 2, 2021

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 sendfile0{2,9}: Remove OFF_T workaround

Using OFF_T definition to off64_t for 64bit variants seems to be am old workaround for buggy libc. Nowadays we can rely on off_t to have correct size (i.e.: 32bit: 4 bytes; 64bit or 32bit with -D_FILE_OFFSET_BITS=64: 8 bytes)

---
NOTE: -DOFF_T=off64_t is also defined in testcases/kernel/io/disktest and mentioned in {tst_,}safe_macros.h.

Kind regards,
Petr

 testcases/kernel/syscalls/sendfile/Makefile     |  2 +-
 testcases/kernel/syscalls/sendfile/sendfile02.c |  6 +-----
 testcases/kernel/syscalls/sendfile/sendfile09.c | 10 +++-------
 3 files changed, 5 insertions(+), 13 deletions(-)
testcases/kernel/syscalls/sendfile/Makefile +1 -1
index f63a42fe9..7ee7bbed4 100644
@@ -6,6 +6,6 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/testcases.mk
 include $(abs_srcdir)/../utils/newer_64.mk
 
-%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=off64_t -D_GNU_SOURCE
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/sendfile/sendfile02.c +1 -5
index e5f115146..729a9e123 100644
@@ -59,10 +59,6 @@
 #include "test.h"
 #include "safe_macros.h"
 
-#ifndef OFF_T
-#define OFF_T off_t
-#endif /* Not def: OFF_T */
-
 TCID_DEFINE(sendfile02);
 int TST_TOTAL = 4;
 
@@ -95,7 +91,7 @@ struct test_case_t {
 static char *argv0;
 #endif
 
-void do_sendfile(OFF_T offset, int i)
+void do_sendfile(off_t offset, int i)
 {
 	int in_fd;
 	struct stat sb;
testcases/kernel/syscalls/sendfile/sendfile09.c +3 -7
index 297b3e212..320649dcd 100644
@@ -26,17 +26,13 @@
 
 #ifndef TST_ABI32
 
-#ifndef OFF_T
-#define OFF_T off_t
-#endif
-
 #define ONE_GB		(INT64_C(1) << 30)
 #define IN_FILE		"in_file"
 #define OUT_FILE	"out_file"
 
 static struct test_case_t {
 	char *desc;
-	OFF_T offset;
+	off_t offset;
 	int64_t count;
 	int64_t exp_retval;
 	int64_t exp_updated_offset;
@@ -67,9 +63,9 @@ static void run(unsigned int i)
 {
 	int in_fd = SAFE_OPEN(IN_FILE, O_RDONLY);
 	int out_fd = SAFE_OPEN(OUT_FILE, O_WRONLY);
-	OFF_T offset = tc[i].offset;
+	off_t offset = tc[i].offset;
 
-	OFF_T before_pos, after_pos;
+	off_t before_pos, after_pos;
 	before_pos = SAFE_LSEEK(in_fd, 0, SEEK_CUR);
 
 	TEST(sendfile(out_fd, in_fd, &offset, tc[i].count));
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 sendfile0{2,9}: Remove OFF_T workaround

Hi!

Quoted 3 lines

Using OFF_T definition to off64_t for 64bit variants seems to be am old workaround for buggy libc. Nowadays we can rely on off_t to have correct size (i.e.: 32bit: 4 bytes; 64bit or 32bit with -D_FILE_OFFSET_BITS=64: 8 bytes)

Looks good to me, Reviewed-by: Cyril Hrubis <[email protected]>

Quoted 5 lines

---
NOTE: -DOFF_T=off64_t is also defined in testcases/kernel/io/disktest and mentioned in {tst_,}safe_macros.h.

We should remove the -DOFF_T=off64_t comment from the *safe_macros.h and keep only the _FILE_OFFSET_BITS there.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 sendfile0{2,9}: Remove OFF_T workaround

Hi Cyril,

Quoted 7 lines

Hi!

Quoted 3 lines

Using OFF_T definition to off64_t for 64bit variants seems to be am old workaround for buggy libc. Nowadays we can rely on off_t to have correct size (i.e.: 32bit: 4 bytes; 64bit or 32bit with -D_FILE_OFFSET_BITS=64: 8 bytes)

Looks good to me, Reviewed-by: Cyril Hrubis <[email protected]>

Quoted 8 lines
Quoted 5 lines

---
NOTE: -DOFF_T=off64_t is also defined in testcases/kernel/io/disktest and mentioned in {tst_,}safe_macros.h.

We should remove the -DOFF_T=off64_t comment from the *safe_macros.h and keep only the _FILE_OFFSET_BITS there.

Good. OK, after I solve our CI (github actions) I'll merge this and send another patch which removes it in testcases/kernel/io/disktest + the comment in *safe_macros.h.

Thanks for review and hints!

Kind regards,
Petr

author
#3 lore raw

PATCH 1/1 sendfile0{2,9}: Remove OFF_T workaround

Hi Cyril,

Quoted 15 lines

Hi Cyril,

Quoted 12 lines

Hi!

Quoted 3 lines

Using OFF_T definition to off64_t for 64bit variants seems to be am old workaround for buggy libc. Nowadays we can rely on off_t to have correct size (i.e.: 32bit: 4 bytes; 64bit or 32bit with -D_FILE_OFFSET_BITS=64: 8 bytes)

Looks good to me, Reviewed-by: Cyril Hrubis <[email protected]>

Quoted 5 lines

---
NOTE: -DOFF_T=off64_t is also defined in testcases/kernel/io/disktest and mentioned in {tst_,}safe_macros.h.

Quoted 6 lines
Quoted 2 lines

We should remove the -DOFF_T=off64_t comment from the *safe_macros.h and keep only the _FILE_OFFSET_BITS there.

Good. OK, after I solve our CI (github actions) I'll merge this and send another patch which removes it in testcases/kernel/io/disktest + the comment in *safe_macros.h.

Merged with your reviewed-by tag and going to implement above in separate patch.

Kind regards,
Petr

Quoted 4 lines

Thanks for review and hints!

Kind regards,
Petr