Skip to content

Commit

Permalink
More size_t -> Tcl_Size changes, which were missed before. Also (expe…
Browse files Browse the repository at this point in the history
…rimental) make the wrapper macro's produce compiler warnings is Tcl_Size is not used.
  • Loading branch information
jan.nijtmans committed Apr 26, 2023
1 parent e722de1 commit ccccb21
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
46 changes: 23 additions & 23 deletions generic/tclDecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -4041,15 +4041,15 @@ extern const TclStubs *tclStubsPtr;
# define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetBytesFromObj(interp, objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetBytesFromObj(interp, objPtr, (Tcl_Size *)(void *)(sizePtr)))
tclStubsPtr->tcl_GetBytesFromObj(interp, objPtr, (sizePtr)))
# define Tcl_GetStringFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetStringFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetStringFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
tclStubsPtr->tcl_GetStringFromObj(objPtr, (sizePtr)))
# define Tcl_GetUnicodeFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetUnicodeFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetUnicodeFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
tclStubsPtr->tcl_GetUnicodeFromObj(objPtr, (sizePtr)))
# endif
#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \
(tclStubsPtr->tcl_GetIndexFromObjStruct((interp), (objPtr), (tablePtr), (offset), (msg), \
Expand All @@ -4064,18 +4064,18 @@ extern const TclStubs *tclStubsPtr;
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetBytesFromObj(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr)))
tclStubsPtr->tcl_GetBytesFromObj(NULL, objPtr, (sizePtr)))
#else
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
tclStubsPtr->tclGetByteArrayFromObj(objPtr, (int *)(void *)(sizePtr)) : \
tclStubsPtr->tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)(void *)(sizePtr)))
tclStubsPtr->tcl_GetByteArrayFromObj(objPtr, (sizePtr)))
#endif
#else
#define Tcl_GetBytesFromObj(interp, objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(interp, objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetBytesFromObj)(interp, objPtr, (Tcl_Size *)(void *)(sizePtr)))
(Tcl_GetBytesFromObj)(interp, objPtr, (sizePtr)))
#define Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr) \
((Tcl_GetIndexFromObjStruct)((interp), (objPtr), (tablePtr), (offset), (msg), \
(flags)|(int)(sizeof(*(indexPtr))<<1), (indexPtr)))
Expand All @@ -4088,15 +4088,15 @@ extern const TclStubs *tclStubsPtr;
#define Tcl_GetStringFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetStringFromObj(objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetStringFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
(Tcl_GetStringFromObj)(objPtr, (sizePtr)))
#define Tcl_GetByteArrayFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetBytesFromObj(NULL, objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetBytesFromObj)(NULL, objPtr, (Tcl_Size *)(void *)(sizePtr)))
(Tcl_GetBytesFromObj)(NULL, objPtr, (sizePtr)))
#define Tcl_GetUnicodeFromObj(objPtr, sizePtr) \
(sizeof(*(sizePtr)) <= sizeof(int) ? \
TclGetUnicodeFromObj(objPtr, (int *)(void *)(sizePtr)) : \
(Tcl_GetUnicodeFromObj)(objPtr, (Tcl_Size *)(void *)(sizePtr)))
(Tcl_GetUnicodeFromObj)(objPtr, (sizePtr)))
#endif

#ifdef TCL_MEM_DEBUG
Expand Down Expand Up @@ -4172,31 +4172,31 @@ extern const TclStubs *tclStubsPtr;
# undef Tcl_ListObjGetElements
# define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \
? tclStubsPtr->tclListObjGetElements((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \
: tclStubsPtr->tcl_ListObjGetElements((interp), (listPtr), (Tcl_Size *)(void *)(objcPtr), (objvPtr)))
: tclStubsPtr->tcl_ListObjGetElements((interp), (listPtr), (objcPtr), (objvPtr)))
# undef Tcl_ListObjLength
# define Tcl_ListObjLength(interp, listPtr, lengthPtr) (sizeof(*(lengthPtr)) == sizeof(int) \
? tclStubsPtr->tclListObjLength((interp), (listPtr), (int *)(void *)(lengthPtr)) \
: tclStubsPtr->tcl_ListObjLength((interp), (listPtr), (Tcl_Size *)(void *)(lengthPtr)))
: tclStubsPtr->tcl_ListObjLength((interp), (listPtr), (lengthPtr)))
# undef Tcl_DictObjSize
# define Tcl_DictObjSize(interp, dictPtr, sizePtr) (sizeof(*(sizePtr)) == sizeof(int) \
? tclStubsPtr->tclDictObjSize((interp), (dictPtr), (int *)(void *)(sizePtr)) \
: tclStubsPtr->tcl_DictObjSize((interp), (dictPtr), (Tcl_Size *)(void *)(sizePtr)))
: tclStubsPtr->tcl_DictObjSize((interp), (dictPtr), (sizePtr)))
# undef Tcl_SplitList
# define Tcl_SplitList(interp, listStr, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? tclStubsPtr->tclSplitList((interp), (listStr), (int *)(void *)(argcPtr), (argvPtr)) \
: tclStubsPtr->tcl_SplitList((interp), (listStr), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
: tclStubsPtr->tcl_SplitList((interp), (listStr), (argcPtr), (argvPtr)))
# undef Tcl_SplitPath
# define Tcl_SplitPath(path, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? tclStubsPtr->tclSplitPath((path), (int *)(void *)(argcPtr), (argvPtr)) \
: tclStubsPtr->tcl_SplitPath((path), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
: tclStubsPtr->tcl_SplitPath((path), (argcPtr), (argvPtr)))
# undef Tcl_FSSplitPath
# define Tcl_FSSplitPath(pathPtr, lenPtr) (sizeof(*(lenPtr)) == sizeof(int) \
? tclStubsPtr->tclFSSplitPath((pathPtr), (int *)(void *)(lenPtr)) \
: tclStubsPtr->tcl_FSSplitPath((pathPtr), (Tcl_Size *)(void *)(lenPtr)))
: tclStubsPtr->tcl_FSSplitPath((pathPtr), (lenPtr)))
# undef Tcl_ParseArgsObjv
# define Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv) (sizeof(*(objcPtr)) == sizeof(int) \
? tclStubsPtr->tclParseArgsObjv((interp), (argTable), (int *)(void *)(objcPtr), (objv), (remObjv)) \
: tclStubsPtr->tcl_ParseArgsObjv((interp), (argTable), (Tcl_Size *)(void *)(objcPtr), (objv), (remObjv)))
: tclStubsPtr->tcl_ParseArgsObjv((interp), (argTable), (objcPtr), (objv), (remObjv)))
#endif /* TCL_MAJOR_VERSION < 9 || !defined(TCL_NO_DEPRECATED) */
#else
# define Tcl_WCharToUtfDString (sizeof(wchar_t) != sizeof(short) \
Expand All @@ -4214,25 +4214,25 @@ extern const TclStubs *tclStubsPtr;
#if !defined(BUILD_tcl) && !defined(TCL_NO_DEPRECATED)
# define Tcl_ListObjGetElements(interp, listPtr, objcPtr, objvPtr) (sizeof(*(objcPtr)) == sizeof(int) \
? TclListObjGetElements((interp), (listPtr), (int *)(void *)(objcPtr), (objvPtr)) \
: (Tcl_ListObjGetElements)((interp), (listPtr), (Tcl_Size *)(void *)(objcPtr), (objvPtr)))
: (Tcl_ListObjGetElements)((interp), (listPtr), (objcPtr), (objvPtr)))
# define Tcl_ListObjLength(interp, listPtr, lengthPtr) (sizeof(*(lengthPtr)) == sizeof(int) \
? TclListObjLength((interp), (listPtr), (int *)(void *)(lengthPtr)) \
: (Tcl_ListObjLength)((interp), (listPtr), (Tcl_Size *)(void *)(lengthPtr)))
: (Tcl_ListObjLength)((interp), (listPtr), (lengthPtr)))
# define Tcl_DictObjSize(interp, dictPtr, sizePtr) (sizeof(*(sizePtr)) == sizeof(int) \
? TclDictObjSize((interp), (dictPtr), (int *)(void *)(sizePtr)) \
: (Tcl_DictObjSize)((interp), (dictPtr), (Tcl_Size *)(void *)(sizePtr)))
: (Tcl_DictObjSize)((interp), (dictPtr), (sizePtr)))
# define Tcl_SplitList(interp, listStr, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? TclSplitList((interp), (listStr), (int *)(void *)(argcPtr), (argvPtr)) \
: (Tcl_SplitList)((interp), (listStr), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
: (Tcl_SplitList)((interp), (listStr), (argcPtr), (argvPtr)))
# define Tcl_SplitPath(path, argcPtr, argvPtr) (sizeof(*(argcPtr)) == sizeof(int) \
? TclSplitPath((path), (int *)(void *)(argcPtr), (argvPtr)) \
: (Tcl_SplitPath)((path), (Tcl_Size *)(void *)(argcPtr), (argvPtr)))
: (Tcl_SplitPath)((path), (argcPtr), (argvPtr)))
# define Tcl_FSSplitPath(pathPtr, lenPtr) (sizeof(*(lenPtr)) == sizeof(int) \
? TclFSSplitPath((pathPtr), (int *)(void *)(lenPtr)) \
: (Tcl_FSSplitPath)((pathPtr), (Tcl_Size *)(void *)(lenPtr)))
: (Tcl_FSSplitPath)((pathPtr), (lenPtr)))
# define Tcl_ParseArgsObjv(interp, argTable, objcPtr, objv, remObjv) (sizeof(*(objcPtr)) == sizeof(int) \
? TclParseArgsObjv((interp), (argTable), (int *)(void *)(objcPtr), (objv), (remObjv)) \
: (Tcl_ParseArgsObjv)((interp), (argTable), (Tcl_Size *)(void *)(objcPtr), (objv), (remObjv)))
: (Tcl_ParseArgsObjv)((interp), (argTable), (objcPtr), (objv), (remObjv)))
#endif /* !defined(BUILD_tcl) */
#endif

Expand Down
4 changes: 2 additions & 2 deletions generic/tclExecute.c
Original file line number Diff line number Diff line change
Expand Up @@ -5272,7 +5272,7 @@ TEBCresume(
TclNewObj(objResultPtr);
} else if (TclIsPureByteArray(valuePtr)) {
objResultPtr = Tcl_NewByteArrayObj(
Tcl_GetByteArrayFromObj(valuePtr, (size_t *)NULL)+index, 1);
Tcl_GetByteArrayFromObj(valuePtr, (Tcl_Size *)NULL)+index, 1);
} else if (valuePtr->bytes && slength == valuePtr->length) {
objResultPtr = Tcl_NewStringObj((const char *)
valuePtr->bytes+index, 1);
Expand Down Expand Up @@ -5536,7 +5536,7 @@ TEBCresume(
nocase);
} else if (TclIsPureByteArray(valuePtr) && TclIsPureByteArray(value2Ptr) && !nocase) {
unsigned char *bytes1, *bytes2;
size_t wlen1 = 0, wlen2 = 0;
Tcl_Size wlen1 = 0, wlen2 = 0;

bytes1 = Tcl_GetByteArrayFromObj(valuePtr, &wlen1);
bytes2 = Tcl_GetByteArrayFromObj(value2Ptr, &wlen2);
Expand Down
4 changes: 2 additions & 2 deletions generic/tclIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -4649,7 +4649,7 @@ Tcl_GetsObj(
if (statePtr->encoding == GetBinaryEncoding()
&& ((statePtr->inputTranslation == TCL_TRANSLATE_LF)
|| (statePtr->inputTranslation == TCL_TRANSLATE_CR))
&& Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL) != NULL) {
&& Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL) != NULL) {
return TclGetsObjBinary(chan, objPtr);
}

Expand Down Expand Up @@ -5990,7 +5990,7 @@ DoReadChars(
&& (statePtr->inEofChar == '\0');

if (appendFlag) {
if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (size_t *)NULL))) {
if (binaryMode && (NULL == Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL))) {
binaryMode = 0;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion generic/tclIOGT.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ ExecuteCallback(
* interpreters. */
{
Tcl_Obj *resObj; /* See below, switch (transmit). */
size_t resLen = 0;
Tcl_Size resLen = 0;
unsigned char *resBuf;
Tcl_InterpState state = NULL;
int res = TCL_OK;
Expand Down
18 changes: 9 additions & 9 deletions generic/tclIORTrans.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ struct ForwardParamTransform {
ForwardParamBase base; /* "Supertype". MUST COME FIRST. */
char *buf; /* I: Bytes to transform,
* O: Bytes in transform result */
size_t size; /* I: #bytes to transform,
Tcl_Size size; /* I: #bytes to transform,
* O: #bytes in the transform result */
};
struct ForwardParamLimit {
Expand Down Expand Up @@ -2562,7 +2562,7 @@ ForwardProc(
* Sent it back to the request originator.
*/

size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */

Expand Down Expand Up @@ -2596,7 +2596,7 @@ ForwardProc(
* Sent it back to the request originator.
*/

size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */

Expand Down Expand Up @@ -2626,7 +2626,7 @@ ForwardProc(
* Sent it back to the request originator.
*/

size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */

bytev = Tcl_GetByteArrayFromObj(resObj, &bytec);
Expand All @@ -2652,7 +2652,7 @@ ForwardProc(
* Sent it back to the request originator.
*/

size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev;
/* Array of returned bytes */

Expand Down Expand Up @@ -3045,7 +3045,7 @@ TransformRead(
Tcl_Obj *bufObj)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */

/*
Expand Down Expand Up @@ -3100,7 +3100,7 @@ TransformWrite(
{
Tcl_Obj *bufObj;
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
int res;

Expand Down Expand Up @@ -3167,7 +3167,7 @@ TransformDrain(
int *errorCodePtr)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */

/*
Expand Down Expand Up @@ -3216,7 +3216,7 @@ TransformFlush(
int op)
{
Tcl_Obj *resObj;
size_t bytec = 0; /* Number of returned bytes */
Tcl_Size bytec = 0; /* Number of returned bytes */
unsigned char *bytev; /* Array of returned bytes */
int res;

Expand Down
2 changes: 1 addition & 1 deletion generic/tclObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ TclGetStringFromObj(
if (lengthPtr != NULL) {
if (objPtr->length > INT_MAX) {
Tcl_Panic("Tcl_GetStringFromObj with 'int' lengthPtr"
" cannot handle such long strings. Please use 'size_t'");
" cannot handle such long strings. Please use 'Tcl_Size'");
}
*lengthPtr = (int)objPtr->length;
}
Expand Down
2 changes: 1 addition & 1 deletion generic/tclZlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -3761,7 +3761,7 @@ ZlibStackChannelTransform(
if (compDictObj != NULL) {
cd->compDictObj = Tcl_DuplicateObj(compDictObj);
Tcl_IncrRefCount(cd->compDictObj);
Tcl_GetByteArrayFromObj(cd->compDictObj, (size_t *)NULL);
Tcl_GetByteArrayFromObj(cd->compDictObj, (Tcl_Size *)NULL);
}

if (format == TCL_ZLIB_FORMAT_RAW) {
Expand Down
2 changes: 1 addition & 1 deletion win/tclWinFCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ GetWinFileAttributes(
* We test for, and fix that case, here.
*/

size_t len;
Tcl_Size len;
const char *str = Tcl_GetStringFromObj(fileName, &len);

if (len < 4) {
Expand Down
10 changes: 5 additions & 5 deletions win/tclWinFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ TclpMatchInDirectory(

DWORD attr;
WIN32_FILE_ATTRIBUTE_DATA data;
size_t len = 0;
Tcl_Size len = 0;
const char *str = Tcl_GetStringFromObj(norm, &len);

native = (const WCHAR *)Tcl_FSGetNativePath(pathPtr);
Expand All @@ -943,7 +943,7 @@ TclpMatchInDirectory(
WIN32_FIND_DATAW data;
const char *dirName; /* UTF-8 dir name, later with pattern
* appended. */
size_t dirLength;
Tcl_Size dirLength;
int matchSpecialDots;
Tcl_DString ds; /* Native encoding of dir, also used
* temporarily for other things. */
Expand Down Expand Up @@ -2796,7 +2796,7 @@ TclpObjNormalizePath(
*/

Tcl_Obj *tmpPathPtr;
size_t len;
Tcl_Size len;

tmpPathPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds),
nextCheckpoint);
Expand Down Expand Up @@ -2885,7 +2885,7 @@ TclWinVolumeRelativeNormalize(
* also on drive C.
*/

size_t cwdLen;
Tcl_Size cwdLen;
const char *drive = Tcl_GetStringFromObj(useThisCwd, &cwdLen);
char drive_cur = path[0];

Expand Down Expand Up @@ -3022,7 +3022,7 @@ TclNativeCreateNativeRep(
WCHAR *nativePathPtr = NULL;
const char *str;
Tcl_Obj *validPathPtr;
size_t len;
Tcl_Size len;
WCHAR *wp;

if (TclFSCwdIsNative()) {
Expand Down
2 changes: 1 addition & 1 deletion win/tclWinInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ TclpInitLibraryPath(
Tcl_Obj *pathPtr;
char installLib[LIBRARY_SIZE];
const char *bytes;
size_t length;
Tcl_Size length;

TclNewObj(pathPtr);

Expand Down
2 changes: 1 addition & 1 deletion win/tclWinPipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ TclpOpenTemporaryFile(
char *namePtr;
HANDLE handle;
DWORD flags = FILE_ATTRIBUTE_TEMPORARY;
size_t length;
Tcl_Size length;
int counter, counter2;
Tcl_DString buf;

Expand Down

0 comments on commit ccccb21

Please sign in to comment.