[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] minheadless sqWin32Common.c (#345)

Ben Coman notifications at github.com
Sat Jan 5 04:03:00 UTC 2019


Questions arising from general review and familiarization with minheadless...

[platforms/minheadless/windows/sqWin32Common.c](https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/1d97d79/platforms/minheadless/windows/sqWin32Common.c) defines functions...
```
fromSqueakInto()
fromSqueak()
fromSqueak2()
sqWin32PrintLastError()
```
The first three don't seem to be used from Windows... 
```
$ grep -RIn fromSqueak * | grep -v sqWin32Common.c
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:21:#define fromSqueak(string,length) string
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:72:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:78:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:84:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:91:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:100:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
platforms/Mac OS/plugins/SecurityPlugin/sqMacSecurity.c:106:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
platforms/minheadless/windows/sqWin32.h:32:TCHAR *fromSqueak(const char *sqPtr, int sqSize);
platforms/minheadless/windows/sqWin32.h:33:TCHAR *fromSqueak2(const char *sqPtr, int sqSize);
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:24:static char* fromSqueak(char* string, int len)
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:76:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:84:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:92:  return isAccessiblePathName(fromSqueak(pathString, pathStringLength));
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:103:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:118:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c:125:  return isAccessibleFileName(fromSqueak(pathString, pathStringLength));
```
So what are the pros/cons of the other two definitions? Can these be consolidated to a higher-commonality?  Is there a security benefit to defining the function statically local just to that file.  

```
#define fromSqueak(string,length) string
```
```
static char* fromSqueak(char* string, int len)
{
  static char buf[MAXPATHLEN];
  strncpy(buf, string, len);
  buf[len] = '\0';
  return buf;
}
```

For the last, what is the benefit versus printLastError(TEXT())...
```
$ grep -RIn sqWin32PrintLastError * | grep -v sqWin32Common.c
platforms/minheadless/windows/sqWin32.h:30:void sqWin32PrintLastError(const char *message);
platforms/minheadless/windows/sqWin32Alloc.c:192:               sqWin32PrintLastError("VirtualProtect(x,y,PAGE_EXECUTE_READWRITE)");
platforms/minheadless/windows/sqWin32Alloc.c:204:               sqWin32PrintLastError("VirtualProtect(x,y,PAGE_EXECUTE_READWRITE)");
platforms/minheadless/windows/sqWin32SpurAlloc.c:210:           sqWin32PrintLastError("VirtualProtect(x,y,PAGE_EXECUTE_READWRITE)");
platforms/minheadless/windows/sqWin32SpurAlloc.c:224:           sqWin32PrintLastError("VirtualProtect(x,y,PAGE_EXECUTE_READWRITE)");
```

@nicolas-cellier-aka-nice some of the above seems related to your recent comments on the mail list

-- 
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/345
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190104/6c76c2d1/attachment-0001.html>


More information about the Vm-dev mailing list