Shouldn’t we cast the DWORD to unsigned int for the GetCurrentProcessId?



On 2/5/17, 8:41 PM, "ovs-dev-boun...@openvswitch.org on behalf of Alin Serdean" 
<ovs-dev-boun...@openvswitch.org on behalf of aserd...@cloudbasesolutions.com> 
wrote:

>getcwd - is used in lib/util.c. getcwd is deprecated on Windows but has
>_getcwd which is defined in <direct.h>:
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_sf98bd4y-28v-3Dvs.120-29.aspx&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo&m=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk&s=CVjSRN456APj3-mMAQuXYxdJ4oUgduwqZHzkod6cLvQ&e=
> 
>
>getpid - is used in several files (i.e. lib/vlog.c). getpid
>is also and deprecated and _getpid should be used:
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_t2y34y40-28v-3Dvs.120-29.aspx&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo&m=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk&s=pDh2W8ECiQdxZdHgHBdWHIDhLPcTJ9A6rb2n1YcRZ94&e=
> 
>The problem using _getpid is that the definition is in <process.h>.
>A file called process.h also exists in the lib folder. This will mess up
>includes.
>An option would be to use a wrapper like we use for lib/string.h(.in) but
>that would mean to also add it to the automake chain.
>A simple solution would be to map it to GetCurrentProcessId
>https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_windows_desktop_ms683180-28v-3Dvs.85-29.aspx&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo&m=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk&s=QWV0dTQAbL1Jt9ZeQeUAUs-WBb8w5YW0mn1cHxFeaZs&e=
> 
>The disadvantage is the type but Windows recycles pids so in theory
>it should be ok.
>
>Signed-off-by: Alin Gabriel Serdean <aserd...@cloudbasesolutions.com>
>---
> include/windows/unistd.h | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/include/windows/unistd.h b/include/windows/unistd.h
>index 8629f7e..3f92616 100644
>--- a/include/windows/unistd.h
>+++ b/include/windows/unistd.h
>@@ -18,8 +18,11 @@
> 
> #define WIN32_LEAN_AND_MEAN
> #include <windows.h>
>+#include <direct.h>
> 
> #define fsync _commit
>+#define getpid GetCurrentProcessId
>+#define getcwd _getcwd
> 
> /* Standard file descriptors.  */
> #define STDIN_FILENO    0   /* Standard input.  */
>-- 
>2.10.2.windows.1
>_______________________________________________
>dev mailing list
>d...@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=Z6vowHUOjP5ysP_g372c49Nqc1vEKqHKNBkR5Q5Z7uo&m=og4savUMMSe8GoOfKq6AMAirivJFLgVTMx5lx7hx6gk&s=864IlShezC_8X9CmDoHDkTjOqBJ3IcRu1LeeoRJrhdM&e=
> 
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to