public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE
@ 2018-01-29  8:58 Andreas Schwab
  2018-01-29 13:30 ` Dmitry V. Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2018-01-29  8:58 UTC (permalink / raw)
  To: libc-alpha

POSIX requires that the constants _POSIX_CHOWN_RESTRICTED,
_POSIX_NO_TRUNC, and _POSIX_VDISABLE are always defined to a value other
than -1.

	* sysdeps/posix/fpathconf.c (__fpathconf): Verify the values of
	_POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE.
	* sysdeps/posix/pathconf.c (__pathconf): Likewise.
---
 sysdeps/posix/fpathconf.c | 21 +++++++++------------
 sysdeps/posix/pathconf.c  | 21 +++++++++------------
 2 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
index 80af77e148..a9d164564e 100644
--- a/sysdeps/posix/fpathconf.c
+++ b/sysdeps/posix/fpathconf.c
@@ -103,25 +103,22 @@ __fpathconf (int fd, int name)
 #endif
 
     case _PC_CHOWN_RESTRICTED:
-#ifdef	_POSIX_CHOWN_RESTRICTED
-      return _POSIX_CHOWN_RESTRICTED;
-#else
-      return -1;
+#if _POSIX_CHOWN_RESTRICTED == -1
+# error "Invalid value for _POSIX_CHOWN_RESTRICTED"
 #endif
+      return _POSIX_CHOWN_RESTRICTED;
 
     case _PC_NO_TRUNC:
-#ifdef	_POSIX_NO_TRUNC
-      return _POSIX_NO_TRUNC;
-#else
-      return -1;
+#if _POSIX_NO_TRUNC == -1
+# error "Invalid value for _POSIX_NO_TRUNC"
 #endif
+      return _POSIX_NO_TRUNC;
 
     case _PC_VDISABLE:
-#ifdef	_POSIX_VDISABLE
-      return _POSIX_VDISABLE;
-#else
-      return -1;
+#if _POSIX_VDISABLE == -1
+# error "Invalid value for _POSIX_VDISABLE"
 #endif
+      return _POSIX_VDISABLE;
 
     case _PC_SYNC_IO:
 #ifdef	_POSIX_SYNC_IO
diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c
index 2059e55b4f..0f893ec1ba 100644
--- a/sysdeps/posix/pathconf.c
+++ b/sysdeps/posix/pathconf.c
@@ -101,25 +101,22 @@ __pathconf (const char *path, int name)
 #endif
 
     case _PC_CHOWN_RESTRICTED:
-#ifdef	_POSIX_CHOWN_RESTRICTED
-      return _POSIX_CHOWN_RESTRICTED;
-#else
-      return -1;
+#if _POSIX_CHOWN_RESTRICTED == -1
+# error "Invalid value for _POSIX_CHOWN_RESTRICTED"
 #endif
+      return _POSIX_CHOWN_RESTRICTED;
 
     case _PC_NO_TRUNC:
-#ifdef	_POSIX_NO_TRUNC
-      return _POSIX_NO_TRUNC;
-#else
-      return -1;
+#if _POSIX_NO_TRUNC == -1
+# error "Invalid value for _POSIX_NO_TRUNC"
 #endif
+      return _POSIX_NO_TRUNC;
 
     case _PC_VDISABLE:
-#ifdef	_POSIX_VDISABLE
-      return _POSIX_VDISABLE;
-#else
-      return -1;
+#if _POSIX_VDISABLE == -1
+# error "Invalid value for _POSIX_VDISABLE"
 #endif
+      return _POSIX_VDISABLE;
 
     case _PC_SYNC_IO:
 #ifdef	_POSIX_SYNC_IO
-- 
2.16.1


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE
  2018-01-29  8:58 [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE Andreas Schwab
@ 2018-01-29 13:30 ` Dmitry V. Levin
  2018-01-29 13:33   ` Samuel Thibault
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry V. Levin @ 2018-01-29 13:30 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]

On Sun, Jan 28, 2018 at 06:58:00PM +0100, Andreas Schwab wrote:
> POSIX requires that the constants _POSIX_CHOWN_RESTRICTED,
> _POSIX_NO_TRUNC, and _POSIX_VDISABLE are always defined to a value other
> than -1.
> 
> 	* sysdeps/posix/fpathconf.c (__fpathconf): Verify the values of
> 	_POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE.
> 	* sysdeps/posix/pathconf.c (__pathconf): Likewise.
> ---
>  sysdeps/posix/fpathconf.c | 21 +++++++++------------
>  sysdeps/posix/pathconf.c  | 21 +++++++++------------
>  2 files changed, 18 insertions(+), 24 deletions(-)
> 
> diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
> index 80af77e148..a9d164564e 100644
> --- a/sysdeps/posix/fpathconf.c
> +++ b/sysdeps/posix/fpathconf.c
> @@ -103,25 +103,22 @@ __fpathconf (int fd, int name)
>  #endif
>  
>      case _PC_CHOWN_RESTRICTED:
> -#ifdef	_POSIX_CHOWN_RESTRICTED
> -      return _POSIX_CHOWN_RESTRICTED;
> -#else
> -      return -1;
> +#if _POSIX_CHOWN_RESTRICTED == -1
> +# error "Invalid value for _POSIX_CHOWN_RESTRICTED"
>  #endif
> +      return _POSIX_CHOWN_RESTRICTED;
>  
>      case _PC_NO_TRUNC:
> -#ifdef	_POSIX_NO_TRUNC
> -      return _POSIX_NO_TRUNC;
> -#else
> -      return -1;
> +#if _POSIX_NO_TRUNC == -1
> +# error "Invalid value for _POSIX_NO_TRUNC"
>  #endif
> +      return _POSIX_NO_TRUNC;
>  
>      case _PC_VDISABLE:
> -#ifdef	_POSIX_VDISABLE
> -      return _POSIX_VDISABLE;
> -#else
> -      return -1;
> +#if _POSIX_VDISABLE == -1
> +# error "Invalid value for _POSIX_VDISABLE"
>  #endif
> +      return _POSIX_VDISABLE;

sysdeps/mach/hurd/bits/posix_opt.h defines _POSIX_VDISABLE
to ((unsigned char) -1), should it be fixed, too?


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE
  2018-01-29 13:30 ` Dmitry V. Levin
@ 2018-01-29 13:33   ` Samuel Thibault
  2018-01-29 13:48     ` Dmitry V. Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Thibault @ 2018-01-29 13:33 UTC (permalink / raw)
  To: libc-alpha

Dmitry V. Levin, on lun. 29 janv. 2018 01:50:51 +0300, wrote:
> >      case _PC_VDISABLE:
> > -#ifdef	_POSIX_VDISABLE
> > -      return _POSIX_VDISABLE;
> > -#else
> > -      return -1;
> > +#if _POSIX_VDISABLE == -1
> > +# error "Invalid value for _POSIX_VDISABLE"
> >  #endif
> > +      return _POSIX_VDISABLE;
> 
> sysdeps/mach/hurd/bits/posix_opt.h defines _POSIX_VDISABLE
> to ((unsigned char) -1), should it be fixed, too?

Posix says that using -1 is invalid, indeed.

Samuel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE
  2018-01-29 13:33   ` Samuel Thibault
@ 2018-01-29 13:48     ` Dmitry V. Levin
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry V. Levin @ 2018-01-29 13:48 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

On Mon, Jan 29, 2018 at 12:02:13AM +0100, Samuel Thibault wrote:
> Dmitry V. Levin, on lun. 29 janv. 2018 01:50:51 +0300, wrote:
> > >      case _PC_VDISABLE:
> > > -#ifdef	_POSIX_VDISABLE
> > > -      return _POSIX_VDISABLE;
> > > -#else
> > > -      return -1;
> > > +#if _POSIX_VDISABLE == -1
> > > +# error "Invalid value for _POSIX_VDISABLE"
> > >  #endif
> > > +      return _POSIX_VDISABLE;
> > 
> > sysdeps/mach/hurd/bits/posix_opt.h defines _POSIX_VDISABLE
> > to ((unsigned char) -1), should it be fixed, too?
> 
> Posix says that using -1 is invalid, indeed.

As it's fixed now, the patch should be safe to commit.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-28 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29  8:58 [PATCH] Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE Andreas Schwab
2018-01-29 13:30 ` Dmitry V. Levin
2018-01-29 13:33   ` Samuel Thibault
2018-01-29 13:48     ` Dmitry V. Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).