[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] suspect code in sqUnixFileCopyPlugin.c (#442)

Nicolas Cellier notifications at github.com
Fri Nov 1 21:21:04 UTC 2019


So says the compiler:

> 
> ../../platforms/unix/plugins/FileCopyPlugin/sqUnixFileCopyPlugin.c:94:61: warning: result of comparison of constant 0 with boolean expression is always true [-Wtautological-constant-compare]
>               if ((  (read(in, mem, stat.st_size) != stat.st_size) >= 0)
>                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
> ../../platforms/unix/plugins/FileCopyPlugin/sqUnixFileCopyPlugin.c:95:56: warning: result of comparison of constant 0 with boolean expression is always true [-Wtautological-constant-compare]
>                   && (write(out, mem, stat.st_size) != stat.st_size) >= 0)

The compiler is right, this makes not much sense:

	      if ((  (read(in, mem, stat.st_size) != stat.st_size) >= 0)
		  && (write(out, mem, stat.st_size) != stat.st_size) >= 0)

Also, the `copy` function may leave open file descriptors in case of failure, so it badly need some attention.

https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/unix/plugins/FileCopyPlugin/sqUnixFileCopyPlugin.c

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/442
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20191101/543f5086/attachment-0001.html>


More information about the Vm-dev mailing list