Skip to content

Commit

Permalink
Add some typecasts, remove duplicate "memset", remove some spacing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed May 8, 2024
1 parent 7f68f29 commit 6d59767
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion generic/tclClockFmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ ClockGetOrParseScanFormat(
wordTok->tokWord.start = p;
wordTok->map = &ScnWordTokenMap;
}

do {
if (isspace(UCHAR(*p))) {
fss->scnSpaceCount++;
Expand Down
5 changes: 2 additions & 3 deletions win/tclWinConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ RingBufferInit(
if (capacity <= 0 || capacity > TCL_SIZE_MAX) {
Tcl_Panic("Internal error: invalid ring buffer capacity requested.");
}
ringPtr->bufPtr = (char *) ckalloc(capacity);
ringPtr->bufPtr = (char *)ckalloc(capacity);
ringPtr->capacity = capacity;
ringPtr->start = 0;
ringPtr->length = 0;
Expand Down Expand Up @@ -2006,8 +2006,7 @@ AllocateConsoleHandleInfo(
ConsoleHandleInfo *handleInfoPtr;
DWORD consoleMode;

handleInfoPtr = (ConsoleHandleInfo *) ckalloc(sizeof(*handleInfoPtr));
memset(handleInfoPtr, 0, sizeof(*handleInfoPtr));
handleInfoPtr = (ConsoleHandleInfo *)ckalloc(sizeof(*handleInfoPtr));
memset(handleInfoPtr, 0, sizeof(*handleInfoPtr));
handleInfoPtr->console = consoleHandle;
InitializeSRWLock(&handleInfoPtr->lock);
Expand Down
10 changes: 5 additions & 5 deletions win/tclWinSock.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ InitializeHostName(

*encodingPtr = Tcl_GetEncoding(NULL, "utf-8");
*lengthPtr = Tcl_DStringLength(&ds);
*valuePtr = (char *) ckalloc(*lengthPtr + 1);
*valuePtr = (char *)ckalloc(*lengthPtr + 1);
memcpy(*valuePtr, Tcl_DStringValue(&ds), *lengthPtr + 1);
Tcl_DStringFree(&ds);
}
Expand Down Expand Up @@ -2572,7 +2572,7 @@ SocketCheckProc(
statePtr->watchEvents | FD_CONNECT | FD_ACCEPT)
&& !GOT_BITS(statePtr->flags, SOCKET_PENDING)) {
SET_BITS(statePtr->flags, SOCKET_PENDING);
evPtr = (SocketEvent *) ckalloc(sizeof(SocketEvent));
evPtr = (SocketEvent *)ckalloc(sizeof(SocketEvent));
evPtr->header.proc = SocketEventProc;
evPtr->socket = statePtr->sockets->fd;
Tcl_QueueEvent((Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
Expand Down Expand Up @@ -2847,7 +2847,7 @@ AddSocketInfoFd(
* Add the first FD.
*/

statePtr->sockets = (TcpFdList *) ckalloc(sizeof(TcpFdList));
statePtr->sockets = (TcpFdList *)ckalloc(sizeof(TcpFdList));
fds = statePtr->sockets;
} else {
/*
Expand All @@ -2858,7 +2858,7 @@ AddSocketInfoFd(
fds = fds->next;
}

fds->next = (TcpFdList *) ckalloc(sizeof(TcpFdList));
fds->next = (TcpFdList *)ckalloc(sizeof(TcpFdList));
fds = fds->next;
}

Expand Down Expand Up @@ -2891,7 +2891,7 @@ static TcpState *
NewSocketInfo(
SOCKET socket)
{
TcpState *statePtr = (TcpState *) ckalloc(sizeof(TcpState));
TcpState *statePtr = (TcpState *)ckalloc(sizeof(TcpState));

memset(statePtr, 0, sizeof(TcpState));

Expand Down
6 changes: 3 additions & 3 deletions win/tclWinTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ TestplatformChmod(
goto done;
}
aceEntry[nSids].sidLen = GetLengthSid(pTokenUser->User.Sid);
aceEntry[nSids].pSid = ckalloc(aceEntry[nSids].sidLen);
aceEntry[nSids].pSid = (PSID)ckalloc(aceEntry[nSids].sidLen);
if (!CopySid(aceEntry[nSids].sidLen, aceEntry[nSids].pSid,
pTokenUser->User.Sid)) {
ckfree(aceEntry[nSids].pSid); /* Since we have not ++'ed nSids */
Expand Down Expand Up @@ -527,7 +527,7 @@ TestplatformChmod(
goto done;
}
aceEntry[nSids].sidLen = GetLengthSid(pTokenGroup->PrimaryGroup);
aceEntry[nSids].pSid = ckalloc(aceEntry[nSids].sidLen);
aceEntry[nSids].pSid = (PSID)ckalloc(aceEntry[nSids].sidLen);
if (!CopySid(aceEntry[nSids].sidLen, aceEntry[nSids].pSid, pTokenGroup->PrimaryGroup)) {
ckfree(pTokenGroup);
ckfree(aceEntry[nSids].pSid); /* Since we have not ++'ed nSids */
Expand Down Expand Up @@ -557,7 +557,7 @@ TestplatformChmod(
goto done;
}
aceEntry[nSids].sidLen = GetLengthSid(pWorldSid);
aceEntry[nSids].pSid = ckalloc(aceEntry[nSids].sidLen);
aceEntry[nSids].pSid = (PSID)ckalloc(aceEntry[nSids].sidLen);
if (!CopySid(aceEntry[nSids].sidLen, aceEntry[nSids].pSid, pWorldSid)) {
LocalFree(pWorldSid);
ckfree(aceEntry[nSids].pSid); /* Since we have not ++'ed nSids */
Expand Down

0 comments on commit 6d59767

Please sign in to comment.