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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

David T Lewis
 

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, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/442?email_source=notifications\u0026email_token=AIJPEW7AEQXHV3RPF5YFSPLQRSMUBA5CNFSM4JIAEQHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HWG5QXQ", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/442?email_source=notifications\u0026email_token=AIJPEW7AEQXHV3RPF5YFSPLQRSMUBA5CNFSM4JIAEQHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HWG5QXQ", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

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

David T Lewis
 

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


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/442?email_source=notifications\u0026email_token=AIJPEW2MUVG3VOBRC3UMPL3QRSM4VA5CNFSM4JIAEQHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC4GMKQ#issuecomment-548955690", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/442?email_source=notifications\u0026email_token=AIJPEW2MUVG3VOBRC3UMPL3QRSM4VA5CNFSM4JIAEQHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC4GMKQ#issuecomment-548955690", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

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

timrowledge
 


> On 2019-11-01, at 2:23 PM, Nicolas Cellier <[hidden email]> 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; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: JTC: Jump To Conclusions