> From: Jeremie Courreges-Anglas <[email protected]>
> Date: Thu, 19 Oct 2017 11:26:38 +0200
> 
> On Thu, Oct 19 2017, Jeremie Courreges-Anglas <[email protected]> wrote:
> > When building an updated version of ports/security/polarssl, I hit the
> > following failure:
> >
> > [219/427] /usr/ports/pobj/mbedtls-2.6.0/bin/cc  
> > -I/usr/ports/pobj/mbedtls-2.6.0/mbedtls-2.6.0/include 
> > -I/usr/ports/pobj/mbedtls-2.6.0/mbedtls-2.6.0/tests -O2 -pipe -Wall -Wextra 
> > -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith 
> > -Wimplicit-fallthrough -Wshadow -Wno-unused-function -DNDEBUG -MD -MT 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o
> >  -MF 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o.d
> >  -o 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o
> >    -c tests/test_suite_hmac_drbg.misc.c
> > FAILED: 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o
> >  
> > /usr/ports/pobj/mbedtls-2.6.0/bin/cc  
> > -I/usr/ports/pobj/mbedtls-2.6.0/mbedtls-2.6.0/include 
> > -I/usr/ports/pobj/mbedtls-2.6.0/mbedtls-2.6.0/tests -O2 -pipe -Wall -Wextra 
> > -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith 
> > -Wimplicit-fallthrough -Wshadow -Wno-unused-function -DNDEBUG -MD -MT 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o
> >  -MF 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o.d
> >  -o 
> > tests/CMakeFiles/test_suite_hmac_drbg.misc.dir/test_suite_hmac_drbg.misc.c.o
> >    -c tests/test_suite_hmac_drbg.misc.c
> > main_test.function:411:50: error: cannot take the address of an rvalue of 
> > type 'FILE *' (aka 'struct __sFILE *')
> >                     stdout_fd = redirect_output( &stdout, "/dev/null" );
> >                                                  ^~~~~~~
> > main_test.function:423:56: error: cannot take the address of an rvalue of 
> > type 'FILE *' (aka 'struct __sFILE *')
> >                 if( !option_verbose && restore_output( &stdout, stdout_fd ) 
> > )
> >                                                        ^~~~~~~
> > 2 errors generated.
> > ninja: build stopped: subcommand failed.
> >
> > And indeed, stdio.h declares stdout as follows:
> >
> >   #define   stdin   (&__sF[0])
> >   #define   stdout  (&__sF[1])
> >   #define   stderr  (&__sF[2])
> >
> > POSIX says pretty much the same as the C standard:
> >
> >   The <stdio.h> header shall define the following macros which shall
> >   expand to expressions of type "pointer to FILE" that point to the FILE
> >   objects associated, respectively, with the standard error, input, and
> >   output streams:
> >
> > So maybe libc should expose stdin/out/err as individual, modifiable
> > pointers?  This is what FreeBSD seems to do.
> 
> The C standard says:
> 
>   The primary use of the freopen function is to change the file
>   associated with a standard text stream (stderr, stdin, or stdout), as
>   those identifiers need not be modifiable lvalues to which the value
>   returned by the fopen function may be assigned.
> 
> so I guess that a valid way to "solve" this problem is just to fix the
> offending application.

Right.  The application is violating the standard.

Reply via email to