opensmalltalk-vm icon indicating copy to clipboard operation
opensmalltalk-vm copied to clipboard

suspect code in sqUnixFileCopyPlugin.c

Open nicolas-cellier-aka-nice opened this issue 6 years ago • 2 comments

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

Given the introductory comment, shouldn't we just nuke the whole thing?

On 2019-11-01, at 2:23 PM, Nicolas Cellier [email protected] wrote:

Given the introductory comment, shouldn't we just nuke the whole thing?

Almost certainly yes. It was a deliberately tacky quick hack done nearly 20 years ago as a way to copy a file with assorted metadata intact, mostly necessitated by Andreas' barking mad determination to have the VMMaker related file tree in a totally nuts layout. As best I recall it isn't used anymore but - warning - I haven't checked in a good while.

What we should have is a way to do it cleanly from the image, by using a well designed file handling regime. I know, I know, I'll stop there so you can cease laughing hysterically and catch your breath.

tim

tim Rowledge; [email protected]; http://www.rowledge.org/tim Strange OpCodes: JTC: Jump To Conclusions

OpenSmalltalk-Bot avatar Nov 01 '19 21:11 OpenSmalltalk-Bot