This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libgomp, nvptx] Fix libgomp.c/target-5.c compilation


On Thu, Dec 13, 2018 at 01:09:25PM +0100, Tom de Vries wrote:
> 2018-12-13  Tom de Vries  <tdevries@suse.de>
> 
> 	* affinity-fmt.c (gomp_print_string): New function, factored out of ...
> 	(omp_display_affinity, gomp_display_affinity_thread): ... here, and ...
> 	* fortran.c (omp_display_affinity_): ... here.
> 	* libgomp.h (gomp_print_string): Declare.
> 	* config/nvptx/affinity-fmt.c: New file.  Include affinity-fmt.c,
> 	undefining HAVE_GETPID and HAVE_GETHOSTNAME, and mapping fwrite to
> 	write.

> +/* The nvptx newlib implementation does not support fwrite, but it does support
> +   write.  Map fwrite to write for size == 1.  */
> +#undef fwrite
> +#define fwrite(ptr, size, nmemb, stream) \
> +  ((size) == 1 ? write (1, (ptr), (nmemb)) : 0)

Why not
  write (1, (ptr), (nmemb) * (size))
I know it doesn't handle the overflow case properly, but the callers are
using 1 and it actually isn't a security threat if it prints fewer chars
than it should.  We don't have anything where we'd rely on fwrite failing
when stuff overflows...

Ok with that change (plus adjust the comment).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]