2
1

0010-use-bool-from-stdbool.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. From 914bfe7d44f8e693d21178055f0b845c613dc777 Mon Sep 17 00:00:00 2001
  2. From: Davide Beatrici <git@davidebeatrici.dev>
  3. Date: Sun, 28 Feb 2021 06:04:11 +0100
  4. Subject: [PATCH] Use bool from stdbool.h, get rid of BOOL
  5. BOOL was just an alias for bool, this commit replaces all instances of it for consistency.
  6. For some reason bool was defined as a 4-byte integer instead of a 1-byte one, presumably to match WinAPI's definition: https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types
  7. Nothing should break now that bool is 1-byte, as no protocol code appears to be relying on the size of the data type.
  8. PACK, for example, explicitly stores boolean values as 4-byte integers.
  9. This commit can be seen as a follow-up to 61ccaed4f6c1bba53202a6d10841fd78b8b6cf8.
  10. Upstream: https://github.com/SoftEtherVPN/SoftEtherVPN/commit/914bfe7d44f8e693d21178055f0b845c613dc777
  11. Signed-off-by: Thomas Perale <thomas.perale@mind.be>
  12. ---
  13. src/Cedar/Cedar.h | 4 ----
  14. src/Cedar/Command.c | 2 +-
  15. src/Cedar/Connection.h | 2 +-
  16. src/Cedar/EtherLog.h | 2 +-
  17. src/Cedar/Radius.c | 2 +-
  18. src/Cedar/Win32Com.cpp | 2 --
  19. src/Cedar/Win32Com.h | 6 ------
  20. src/Cedar/WinJumpList.cpp | 3 ---
  21. src/Mayaqua/MayaType.h | 9 ++-------
  22. 9 files changed, 6 insertions(+), 26 deletions(-)
  23. diff --git a/src/Cedar/Cedar.h b/src/Cedar/Cedar.h
  24. index cc32fc28..267b3957 100644
  25. --- a/src/Cedar/Cedar.h
  26. +++ b/src/Cedar/Cedar.h
  27. @@ -121,10 +121,6 @@
  28. #endif // VPN_SPEED
  29. -#define bool UINT
  30. -#define BOOL UINT
  31. -
  32. -
  33. // Version number
  34. #define CEDAR_VER 430
  35. diff --git a/src/Cedar/Command.c b/src/Cedar/Command.c
  36. index 5b2c67e8..7bd19799 100644
  37. --- a/src/Cedar/Command.c
  38. +++ b/src/Cedar/Command.c
  39. @@ -22433,7 +22433,7 @@ void CtEscapeCsv(wchar_t *dst, UINT size, wchar_t *src){
  40. UINT i;
  41. UINT len = UniStrLen(src);
  42. UINT idx;
  43. - BOOL need_to_escape = false;
  44. + bool need_to_escape = false;
  45. wchar_t tmp[2]=L"*";
  46. // Check the input value
  47. diff --git a/src/Cedar/Connection.h b/src/Cedar/Connection.h
  48. index 2b1f8091..47b2e4aa 100644
  49. --- a/src/Cedar/Connection.h
  50. +++ b/src/Cedar/Connection.h
  51. @@ -244,7 +244,7 @@ struct UDP
  52. // Data block
  53. struct BLOCK
  54. {
  55. - BOOL Compressed; // Compression flag
  56. + bool Compressed; // Compression flag
  57. UINT Size; // Block size
  58. UINT SizeofData; // Data size
  59. UCHAR *Buf; // Buffer
  60. diff --git a/src/Cedar/EtherLog.h b/src/Cedar/EtherLog.h
  61. index 3fdcf140..e3dda9da 100644
  62. --- a/src/Cedar/EtherLog.h
  63. +++ b/src/Cedar/EtherLog.h
  64. @@ -148,7 +148,7 @@ struct RPC_ENUM_DEVICE
  65. // License status of the service
  66. struct RPC_EL_LICENSE_STATUS
  67. {
  68. - BOOL Valid; // Enable flag
  69. + bool Valid; // Enable flag
  70. UINT64 SystemId; // System ID
  71. UINT64 SystemExpires; // System expiration date
  72. };
  73. diff --git a/src/Cedar/Radius.c b/src/Cedar/Radius.c
  74. index bcbac5d4..9dcfe05d 100644
  75. --- a/src/Cedar/Radius.c
  76. +++ b/src/Cedar/Radius.c
  77. @@ -1889,7 +1889,7 @@ bool RadiusLogin(CONNECTION *c, char *server, UINT port, UCHAR *secret, UINT sec
  78. SOCK *sock;
  79. USHORT sz = 0;
  80. UINT pos = 0;
  81. - BOOL *finish = ZeroMallocEx(sizeof(BOOL) * LIST_NUM(ip_list), true);
  82. + bool *finish = ZeroMallocEx(sizeof(bool) * LIST_NUM(ip_list), true);
  83. Zero(tmp, sizeof(tmp));
  84. diff --git a/src/Cedar/Win32Com.cpp b/src/Cedar/Win32Com.cpp
  85. index e567c557..65c21988 100644
  86. --- a/src/Cedar/Win32Com.cpp
  87. +++ b/src/Cedar/Win32Com.cpp
  88. @@ -106,8 +106,6 @@
  89. #ifdef WIN32
  90. -#define WIN32COM_CPP
  91. -
  92. #define _WIN32_DCOM
  93. //#define _WIN32_WINNT 0x0502
  94. diff --git a/src/Cedar/Win32Com.h b/src/Cedar/Win32Com.h
  95. index 6191d7e0..eb4810e4 100644
  96. --- a/src/Cedar/Win32Com.h
  97. +++ b/src/Cedar/Win32Com.h
  98. @@ -105,12 +105,6 @@
  99. #ifndef WIN32COM_H
  100. #define WIN32COM_H
  101. -#ifdef WIN32COM_CPP
  102. -
  103. -// Internal function
  104. -
  105. -#endif // WIN32COM_CPP
  106. -
  107. // For external function
  108. #pragma comment(lib,"htmlhelp.lib")
  109. diff --git a/src/Cedar/WinJumpList.cpp b/src/Cedar/WinJumpList.cpp
  110. index 7bd375a1..7b5fabe2 100644
  111. --- a/src/Cedar/WinJumpList.cpp
  112. +++ b/src/Cedar/WinJumpList.cpp
  113. @@ -132,9 +132,6 @@
  114. #undef StrCmp
  115. #endif
  116. -
  117. -#define WIN32COM_CPP
  118. -
  119. //#define _WIN32_WINNT 0x0502
  120. //#define WINVER 0x0502
  121. #include <winsock2.h>
  122. diff --git a/src/Mayaqua/MayaType.h b/src/Mayaqua/MayaType.h
  123. index ae173617..9d5bc3c1 100644
  124. --- a/src/Mayaqua/MayaType.h
  125. +++ b/src/Mayaqua/MayaType.h
  126. @@ -105,6 +105,8 @@
  127. #ifndef MAYATYPE_H
  128. #define MAYATYPE_H
  129. +#include <stdbool.h>
  130. +
  131. // Check whether the windows.h header is included
  132. #ifndef WINDOWS_H
  133. #ifdef _WINDOWS_
  134. @@ -252,13 +254,6 @@ typedef unsigned int BOOL;
  135. #define FALSE 0
  136. #endif // WINDOWS_H
  137. -// bool type
  138. -#ifndef WIN32COM_CPP
  139. -typedef unsigned int bool;
  140. -#define true 1
  141. -#define false 0
  142. -#endif // WIN32COM_CPP
  143. -
  144. // 32bit integer type
  145. #ifndef WINDOWS_H
  146. typedef unsigned int UINT;
  147. --
  148. 2.39.5