summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixChan.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2025-04-01 08:13:35 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2025-04-01 08:13:35 (GMT)
commit79ed51d25a48dce0d084a2c57f199821e58eac99 (patch)
tree8de2f1cd37877eb5773cd0106a1de4e42703d936 /unix/tclUnixChan.c
parentb915f649c229620e5a17add0e25b85ee99c9c91d (diff)
parent254025c6d682cfde6e1cada371c419af7c60087b (diff)
downloadtcl-79ed51d25a48dce0d084a2c57f199821e58eac99.zip
tcl-79ed51d25a48dce0d084a2c57f199821e58eac99.tar.gz
tcl-79ed51d25a48dce0d084a2c57f199821e58eac99.tar.bz2
Fix some -Wconversion warnings
Diffstat (limited to 'unix/tclUnixChan.c')
-rw-r--r--unix/tclUnixChan.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 75584fe..ac4734c 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -266,7 +266,7 @@ FileInputProc(
int *errorCodePtr) /* Where to store error code. */
{
FileState *fsPtr = (FileState *)instanceData;
- int bytesRead; /* How many bytes were actually read from the
+ ssize_t bytesRead; /* How many bytes were actually read from the
* input device? */
*errorCodePtr = 0;
@@ -286,7 +286,7 @@ FileInputProc(
*errorCodePtr = errno;
return -1;
}
- return bytesRead;
+ return (int)bytesRead;
}
/*
@@ -315,7 +315,7 @@ FileOutputProc(
int *errorCodePtr) /* Where to store error code. */
{
FileState *fsPtr = (FileState *)instanceData;
- int written;
+ ssize_t written;
*errorCodePtr = 0;
@@ -330,7 +330,7 @@ FileOutputProc(
}
written = write(fsPtr->fd, buf, toWrite);
if (written >= 0) {
- return written;
+ return (int)written;
}
*errorCodePtr = errno;
return -1;
@@ -659,7 +659,7 @@ FileGetOptionProc(
{
FileState *fsPtr = (FileState *)instanceData;
int valid = 0; /* Flag if valid option parsed. */
- int len;
+ size_t len;
if (optionName == NULL) {
len = 0;
@@ -860,18 +860,18 @@ TtySetOptionProc(
iostate.c_cc[VSTOP] = argv[1][0];
if (argv[0][0] & 0x80 || argv[1][0] & 0x80) {
Tcl_UniChar character = 0;
- int charLen;
+ Tcl_Size charLen;
charLen = TclUtfToUniChar(argv[0], &character);
if ((character > 0xFF) || argv[0][charLen]) {
goto badXchar;
}
- iostate.c_cc[VSTART] = character;
+ iostate.c_cc[VSTART] = (cc_t)character;
charLen = TclUtfToUniChar(argv[1], &character);
if ((character > 0xFF) || argv[1][charLen]) {
goto badXchar;
}
- iostate.c_cc[VSTOP] = character;
+ iostate.c_cc[VSTOP] = (cc_t)character;
}
Tcl_Free(argv);
@@ -891,7 +891,7 @@ TtySetOptionProc(
return TCL_ERROR;
}
iostate.c_cc[VMIN] = 0;
- iostate.c_cc[VTIME] = (msec==0) ? 0 : (msec<100) ? 1 : (msec+50)/100;
+ iostate.c_cc[VTIME] = (msec==0) ? 0 : (msec<100) ? 1 : (cc_t)((msec+50)/100);
tcsetattr(fsPtr->fileState.fd, TCSADRAIN, &iostate);
return TCL_OK;
}
@@ -1779,22 +1779,16 @@ TclpOpenFileChannel(
* Note: since paths starting with ~ are absolute, it also considers tilde expansion,
* (proper error message of tests *io-40.17 "tilde substitution in open")
*/
- if (
- (
- (
- !TclFSCwdIsNative() &&
- (Tcl_FSGetPathType(pathPtr) != TCL_PATH_ABSOLUTE)
- ) ||
- (*TclGetString(pathPtr) == '~') /* possible tilde expansion */
- ) &&
- Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL
- ) {
+ if (((!TclFSCwdIsNative()
+ && (Tcl_FSGetPathType(pathPtr) != TCL_PATH_ABSOLUTE))
+ || (*TclGetString(pathPtr) == '~')) /* possible tilde expansion */
+ && Tcl_FSGetNormalizedPath(interp, pathPtr) == NULL) {
return NULL;
}
Tcl_AppendResult(interp, "couldn't open \"",
- TclGetString(pathPtr), "\": filename is invalid on this platform",
- (char *)NULL);
+ TclGetString(pathPtr),
+ "\": filename is invalid on this platform", (char *)NULL);
}
return NULL;
}
@@ -1906,7 +1900,7 @@ Tcl_MakeFileChannel(
{
TtyState *fsPtr;
char channelName[16 + TCL_INTEGER_SPACE];
- int fd = PTR2INT(handle);
+ int fd = (int)PTR2INT(handle);
const Tcl_ChannelType *channelTypePtr;
Tcl_StatBuf buf;
@@ -2112,7 +2106,7 @@ Tcl_GetOpenFile(
|| (strcmp(chanTypePtr->typeName, "pipe") == 0)) {
if (Tcl_GetChannelHandle(chan,
(forWriting ? TCL_WRITABLE : TCL_READABLE), &data) == TCL_OK) {
- fd = PTR2INT(data);
+ fd = (int)PTR2INT(data);
/*
* The call to fdopen below is probably dangerous, since it will