diff mbox series

[hurd,commited,1/3] hurd: Fix building libio/tst-memstream3.c

Message ID 20180128172308.7647-2-samuel.thibault@ens-lyon.org
State New
Headers show
Series hurd: fix building tests | expand

Commit Message

Samuel Thibault Jan. 28, 2018, 5:23 p.m. UTC
FWRITE is already an fcntl.h macro.

	* libio/tst-memstream3.c (FWRITE): Rename to _FWRITE.
	(do_test_bz20181): Rename accordingly.
	* libio/tst-wmemstream3.c (FWRITE): Rename accordingly.
---
 ChangeLog               |  3 +++
 libio/tst-memstream3.c  | 10 +++++-----
 libio/tst-wmemstream3.c |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

Comments

Joseph Myers Jan. 29, 2018, 4:33 p.m. UTC | #1
On Sun, 28 Jan 2018, Samuel Thibault wrote:

> FWRITE is already an fcntl.h macro.
> 
> 	* libio/tst-memstream3.c (FWRITE): Rename to _FWRITE.
> 	(do_test_bz20181): Rename accordingly.
> 	* libio/tst-wmemstream3.c (FWRITE): Rename accordingly.

I think we should leave the testcase using FWRITE (and certainly not make 
tests use reserved-namespace names with leading '_' if it can be avoided), 
and instead remove the FREAD and FWRITE macros from the generic and Hurd 
bits/fcntl.h.

(There's a case for removing all the F* aliases for O_* from all 
bits/fcntl.h variants, as one of many likely obsolete __USE_MISC APIs, but 
that would need more investigation of how widely used they might be.  
Removal of names that only appear in the Hurd-specific and (currently 
unused) generic headers is pretty safe, however.)
Samuel Thibault Jan. 29, 2018, 9:14 p.m. UTC | #2
Joseph Myers, on lun. 29 janv. 2018 16:33:40 +0000, wrote:
> and instead remove the FREAD and FWRITE macros from the generic and Hurd 
> bits/fcntl.h.

What do we do of sysdeps/unix/bsd/tcflush.c's use of FREAD and FWRITE
then?

Samuel
Joseph Myers Jan. 29, 2018, 9:32 p.m. UTC | #3
On Mon, 29 Jan 2018, Samuel Thibault wrote:

> Joseph Myers, on lun. 29 janv. 2018 16:33:40 +0000, wrote:
> > and instead remove the FREAD and FWRITE macros from the generic and Hurd 
> > bits/fcntl.h.
> 
> What do we do of sysdeps/unix/bsd/tcflush.c's use of FREAD and FWRITE
> then?

I would have said change it to use O_RDONLY and O_WRONLY of which FREAD 
and FWRITE are aliases, but in the generic header they aren't aliases.

The comments in both bits/fcntl.h headers, referring to those names as 
being for bits returned by F_GETFL, are clearly wrong - F_GETFL returns 
the O_* bits, not some possibly rewritten bits.  So maybe those macros 
should stay, but with the comments in both places changed to say they are 
flags for TIOCFLUSH (e.g. FreeBSD's fcntl.h has a comment referring to 
TIOCFLUSH above the definition of those macros).  And then use a name such 
as FWRITE_FUNC in the tests, since they still shouldn't be using 
implementation-namespace _FWRITE.
diff mbox series

Patch

diff --git a/ChangeLog b/ChangeLog
index 1261148996..23a56d69cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,9 @@ 
 	* sysdeps/mach/hurd/check_pf.c: New file.
 	* sysdeps/mach/hurd/libhurduser.abilist: New file.
 	* sysdeps/mach/libmachuser.abilist: New file.
+	* libio/tst-memstream3.c (FWRITE): Rename to _FWRITE.
+	(do_test_bz20181): Rename accordingly.
+	* libio/tst-wmemstream3.c (FWRITE): Rename accordingly.
 
 2008-12-18  Thomas Schwinge  <tschwinge@gnu.org>
 
diff --git a/libio/tst-memstream3.c b/libio/tst-memstream3.c
index 331314f784..df0da5bac5 100644
--- a/libio/tst-memstream3.c
+++ b/libio/tst-memstream3.c
@@ -29,7 +29,7 @@ 
 # define W(o) o
 # define OPEN_MEMSTREAM open_memstream
 # define PRINTF printf
-# define FWRITE fwrite
+# define _FWRITE fwrite
 # define FPUTC fputc
 # define STRCMP strcmp
 #endif
@@ -114,14 +114,14 @@  do_test_bz20181 (void)
   if (fp == NULL)
     ERROR_RET1 ("%s failed\n", S(OPEN_MEMSTREAM));
 
-  if ((ret = FWRITE (W("abc"), 1, 3, fp)) != 3)
-    ERROR_RET1 ("%s failed (errno = %d)\n", S(FWRITE), errno);
+  if ((ret = _FWRITE (W("abc"), 1, 3, fp)) != 3)
+    ERROR_RET1 ("%s failed (errno = %d)\n", S(_FWRITE), errno);
 
   if (fseek (fp, 0, SEEK_SET) != 0)
     ERROR_RET1 ("fseek failed (errno = %d)\n", errno);
 
-  if (FWRITE (W("z"), 1, 1, fp) != 1)
-    ERROR_RET1 ("%s failed (errno = %d)\n", S(FWRITE), errno);
+  if (_FWRITE (W("z"), 1, 1, fp) != 1)
+    ERROR_RET1 ("%s failed (errno = %d)\n", S(_FWRITE), errno);
 
   if (fflush (fp) != 0)
     ERROR_RET1 ("fflush failed (errno = %d)\n", errno);
diff --git a/libio/tst-wmemstream3.c b/libio/tst-wmemstream3.c
index d0e4973768..4edc2b9094 100644
--- a/libio/tst-wmemstream3.c
+++ b/libio/tst-wmemstream3.c
@@ -37,7 +37,7 @@  fwwrite (const void *ptr, size_t size, size_t nmemb, FILE *arq)
 #define W(o) L##o
 #define OPEN_MEMSTREAM open_wmemstream
 #define PRINTF wprintf
-#define FWRITE fwwrite
+#define _FWRITE fwwrite
 #define FPUTC  fputwc
 #define STRCMP wcscmp