Skip to content

Commit 8bd858e

Browse files
author
jan.nijtmans
committed
(backport): Fix warnings in asserts (seen in debug-mode only). Fix some C++ usage.
1 parent 118c96c commit 8bd858e

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

.github/workflows/mac-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ jobs:
103103
env:
104104
ERROR_ON_FAILURES: 1
105105
MAC_CI: 1
106-
timeout-minutes: 15
106+
timeout-minutes: 20

unix/tclSelectNotfy.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,16 @@ static pthread_cond_t notifierCV = PTHREAD_COND_INITIALIZER;
180180

181181
/*
182182
* The pollState bits:
183-
*
184-
* POLL_WANT is set by each thread before it waits on its condition variable.
185-
* It is checked by the notifier before it does select.
186-
*
187-
* POLL_DONE is set by the notifier if it goes into select after seeing
188-
* POLL_WANT. The idea is to ensure it tries a select with the same bits
189-
* the initial thread had set.
190183
*/
191-
192-
#define POLL_WANT 0x1
193-
#define POLL_DONE 0x2
184+
enum SelectPollStateFlags {
185+
POLL_WANT = 0x1, /* Set by each thread before it waits on its
186+
* condition variable. Checked by the notifier
187+
* before it does select(). */
188+
POLL_DONE = 0x2 /* Set by the notifier if it goes into select()
189+
* after seeing POLL_WANT. The idea is to
190+
* ensure it tries a select() with the same
191+
* bits the initial thread had set. */
192+
};
194193

195194
/*
196195
* This is the thread ID of the notifier thread that does select.
@@ -254,33 +253,33 @@ typedef struct {
254253
const void *lpszClassName;
255254
} WNDCLASSW;
256255

257-
extern void CloseHandle(void *);
258-
extern void *CreateEventW(void *, unsigned char, unsigned char,
256+
extern void CloseHandle(void *);
257+
extern void * CreateEventW(void *, unsigned char, unsigned char,
259258
void *);
260-
extern void *CreateWindowExW(void *, const void *, const void *,
259+
extern void * CreateWindowExW(void *, const void *, const void *,
261260
unsigned int, int, int, int, int, void *, void *,
262261
void *, void *);
263-
extern unsigned int DefWindowProcW(void *, int, void *, void *);
264-
extern unsigned char DestroyWindow(void *);
265-
extern int DispatchMessageW(const MSG *);
266-
extern unsigned char GetMessageW(MSG *, void *, int, int);
267-
extern void MsgWaitForMultipleObjects(unsigned int, void *,
262+
extern unsigned int DefWindowProcW(void *, int, void *, void *);
263+
extern unsigned char DestroyWindow(void *);
264+
extern int DispatchMessageW(const MSG *);
265+
extern unsigned char GetMessageW(MSG *, void *, int, int);
266+
extern void MsgWaitForMultipleObjects(unsigned int, void *,
268267
unsigned char, unsigned int, unsigned int);
269-
extern unsigned char PeekMessageW(MSG *, void *, int, int, int);
270-
extern unsigned char PostMessageW(void *, unsigned int, void *,
268+
extern unsigned char PeekMessageW(MSG *, void *, int, int, int);
269+
extern unsigned char PostMessageW(void *, unsigned int, void *,
271270
void *);
272-
extern void PostQuitMessage(int);
273-
extern void *RegisterClassW(const WNDCLASSW *);
274-
extern unsigned char ResetEvent(void *);
275-
extern unsigned char TranslateMessage(const MSG *);
271+
extern void PostQuitMessage(int);
272+
extern void * RegisterClassW(const WNDCLASSW *);
273+
extern unsigned char ResetEvent(void *);
274+
extern unsigned char TranslateMessage(const MSG *);
276275

277276
/*
278277
* Threaded-cygwin specific constants and functions in this file:
279278
*/
280279

281280
#if TCL_THREADS && defined(__CYGWIN__)
282-
static const WCHAR className[] = L"TclNotifier";
283-
static unsigned int NotifierProc(void *hwnd, unsigned int message,
281+
static const WCHAR className[] = {'T', 'c', 'l', 'N', 'o', 't', 'i', 'f', 'i', 'e', 'r', '\0'};
282+
static unsigned int NotifierProc(void *hwnd, unsigned int message,
284283
void *wParam, void *lParam);
285284
#endif /* TCL_THREADS && defined(__CYGWIN__) */
286285
#ifdef __cplusplus
@@ -921,7 +920,7 @@ int
921920
TclAsyncNotifier(
922921
int sigNumber, /* Signal number. */
923922
TCL_UNUSED(Tcl_ThreadId), /* Target thread. */
924-
TCL_UNUSED(void *), /* Notifier data. */
923+
TCL_UNUSED(void *), /* Notifier data. */
925924
int *flagPtr, /* Flag to mark. */
926925
int value) /* Value of mark. */
927926
{

unix/tclUnixFile.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ TclpFindExecutable(
4646
TCL_UNUSED(const char *) /*argv0*/)
4747
{
4848
size_t length;
49-
WCHAR buf[PATH_MAX] = L"";
49+
WCHAR buf[PATH_MAX];
5050
char name[PATH_MAX * TCL_UTF_MAX + 1];
5151

52+
buf[0] = '\0';
5253
GetModuleFileNameW(NULL, buf, PATH_MAX);
5354
cygwin_conv_path(3, buf, name, sizeof(name));
5455
length = strlen(name);
@@ -166,7 +167,8 @@ TclpFindExecutable(
166167
if (name[0] == '/')
167168
#endif
168169
{
169-
Tcl_ExternalToUtfDStringEx(NULL, NULL, name, TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
170+
Tcl_ExternalToUtfDStringEx(NULL, NULL, name, TCL_INDEX_NONE,
171+
TCL_ENCODING_PROFILE_TCL8, &utfName, NULL);
170172
TclSetObjNameOfExecutable(Tcl_DStringToObj(&utfName), NULL);
171173
goto getShlibName;
172174
}
@@ -627,7 +629,8 @@ TclpGetUserHome(
627629
Tcl_DString ds;
628630
const char *native;
629631

630-
if (Tcl_UtfToExternalDStringEx(NULL, NULL, name, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
632+
if (Tcl_UtfToExternalDStringEx(NULL, NULL, name, TCL_INDEX_NONE, 0, &ds,
633+
NULL) != TCL_OK) {
631634
Tcl_DStringFree(&ds);
632635
return NULL;
633636
}
@@ -639,7 +642,8 @@ TclpGetUserHome(
639642
if (pwPtr == NULL) {
640643
return NULL;
641644
}
642-
if (Tcl_ExternalToUtfDStringEx(NULL, NULL, pwPtr->pw_dir, TCL_INDEX_NONE, 0, bufferPtr, NULL) != TCL_OK) {
645+
if (Tcl_ExternalToUtfDStringEx(NULL, NULL, pwPtr->pw_dir, TCL_INDEX_NONE,
646+
0, bufferPtr, NULL) != TCL_OK) {
643647
return NULL;
644648
} else {
645649
return Tcl_DStringValue(bufferPtr);
@@ -821,7 +825,8 @@ TclpGetCwd(
821825
}
822826
return NULL;
823827
}
824-
if (Tcl_ExternalToUtfDStringEx(interp, NULL, buffer, TCL_INDEX_NONE, 0, bufferPtr, NULL) != TCL_OK) {
828+
if (Tcl_ExternalToUtfDStringEx(interp, NULL, buffer, TCL_INDEX_NONE, 0,
829+
bufferPtr, NULL) != TCL_OK) {
825830
return NULL;
826831
}
827832
return Tcl_DStringValue(bufferPtr);
@@ -1112,7 +1117,8 @@ TclpNativeToNormalized(
11121117
{
11131118
Tcl_DString ds;
11141119

1115-
Tcl_ExternalToUtfDStringEx(NULL, NULL, (const char *) clientData, TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &ds, NULL);
1120+
Tcl_ExternalToUtfDStringEx(NULL, NULL, (const char *) clientData,
1121+
TCL_INDEX_NONE, TCL_ENCODING_PROFILE_TCL8, &ds, NULL);
11161122
return Tcl_DStringToObj(&ds);
11171123
}
11181124

win/tclWinThrd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static CRITICAL_SECTION initLock;
5050

5151
typedef struct WMutex {
5252
CRITICAL_SECTION crit;
53-
volatile LONG thread;
53+
volatile DWORD thread;
5454
int counter;
5555
} WMutex;
5656

@@ -564,7 +564,7 @@ static void
564564
WMutexLock(
565565
WMutex *wmPtr)
566566
{
567-
LONG mythread = GetCurrentThreadId();
567+
DWORD mythread = GetCurrentThreadId();
568568

569569
if (wmPtr->thread == mythread) {
570570
// We owned the lock already, so it's recursive.
@@ -813,7 +813,7 @@ Tcl_ConditionWait(
813813

814814
counter = wmPtr->counter;
815815
wmPtr->counter = 0;
816-
LONG mythread = GetCurrentThreadId();
816+
DWORD mythread = GetCurrentThreadId();
817817
assert(wmPtr->thread == mythread);
818818
wmPtr->thread = 0;
819819
LeaveCriticalSection(&wmPtr->crit);

0 commit comments

Comments
 (0)