lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d794a058-0506-7c3c-6f3e-518a788933af@gmail.com>
Date:   Fri, 2 Oct 2020 20:38:47 +0200
From:   Alejandro Colomar <colomar.6.4.3@...il.com>
To:     Paul Eggert <eggert@...ucla.edu>
Cc:     mtk.manpages@...il.com, linux-man@...r.kernel.org,
        gcc-patches@....gnu.org, libc-alpha@...rceware.org,
        linux-kernel@...r.kernel.org, jwakely.gcc@...il.com,
        David.Laight@...LAB.COM
Subject: Re: [PATCH v4 1/2] system_data_types.7: Add 'void *'

Hi Paul,

On 2020-10-02 18:53, Paul Eggert wrote:
 > On 10/2/20 8:14 AM, Alejandro Colomar wrote:
 >
 >> +.I void *
 >
 > GNU style is a space between "void" and "*", so this should be '.I
 > "void\ *"', both here and elsewhere. The backslash prevents a line break.

.I void *

renders with a space in between.
I'll show you the rendered version at the end of this email.

 >
 >> +Conversions from and to any other pointer type are done implicitly,
 >> +not requiring casts at all.
 >> +Note that this feature prevents any kind of type checking:
 >> +the programmer should be careful not to cast a
 >
 > Change "cast" to "convert", since the point is that no cast is needed.

Ok.

 >
 >> +.PP
 >> +The conversion specifier for
 >> +.I void *
 >> +for the
 >> +.BR printf (3)
 >> +and the
 >> +.BR scanf (3)
 >> +families of functions is
 >> +.BR p ;
 >> +resulting commonly in
 >> +.B %p
 >> +for printing
 >> +.I void *
 >> +values.
 >
 > %p works with any object pointer type (or in POSIX, any pointer type),
 > not just  void *.
In theory, no (if otherwise, I'd like to know why):

[[
p
     The argument shall be a pointer to void. The value of the pointer 
is converted to a sequence of printable characters, in an 
implementation-defined manner.
]] POSIX.1-2008

However, it's unlikely to cause any problems, I must admit.

 >
 > Should also mention "void const *", "void volatile *", etc.

I already answered to this:
https://lore.kernel.org/linux-man/CAH6eHdQhh46TjVc72meWFTWCi7iouAod0iC1zLRga+c-36G+ig@mail.gmail.com/T/#m6f657e988558a556cb70f7c056ef7a24e73dbe4a

 > Plus it
 > really should talk about plain "void", saying that it's a placeholder as
 > a return value for functions, for casting away values, and as a keyword
 > in C11 for functions with no parameters (though this is being changed in
 > the next C version!). I sent comments about most of this stuff already.

'void' is a completely different type from 'void *'.

This patch is for 'void *'.

If 'void' is documented,
it'll be in a different entry (although in the same page),
and therefore, that'll be for a different patch.

Thanks,

Alex

__________________

void *
       According  to  the  C language standard, a pointer to any object
       type may be converted to a pointer to void and back.  POSIX fur-
       ther requires that any pointer, including pointers to functions,
       may be converted to a pointer to void and back.

       Conversions from and to any other pointer type are done  implic-
       itly,  not  requiring casts at all.  Note that this feature pre-
       vents any kind of type checking: the programmer should be  care-
       ful not to cast a void * value to a type incompatible to that of
       the underlying data, because that would result in undefined  be-
       havior.

       This  type  is useful in function parameters and return value to
       allow passing values of any type.  The function will usually use
       some  mechanism to know of which type the underlying data passed
       to the function really is.

       A value of this type can't be dereferenced, as it would  give  a
       value  of  type  void  which is not possible.  Likewise, pointer
       arithmetic is not possible with this type.  However, in  GNU  C,
       poitner  arithmetic  is allowed as an extension to the standard;
       this is done by treating the size of a void or of a function  as
       1.  A consequence of this is that sizeof is also allowed on void
       and on function types, and returns 1.

       The conversion specifier for void * for the  printf(3)  and  the
       scanf(3)  families  of  functions is p; resulting commonly in %p
       for printing void * values.

       Versions: The POSIX requirement about compatibility between void
       * and function pointers was added in POSIX.1-2008 Technical Cor-
       rigendum 1 (2013).

       Conforming to: C99 and later; POSIX.1-2001 and later.

       See also: malloc(3), memcmp(3), memcpy(3), memset(3)

       See also the intptr_t and uintptr_t types in this page.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ