Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-10-25
07:32 • Ticket [b58e689703] Return value of `Tcl_Flush` status still Closed with 5 o... artifact: ecb677d156 user: dram
2017-10-23
12:11 • Closed ticket [b58e689703]. artifact: d17072f060 user: jan.nijtmans
12:09
Fix [b58e6897034fc5292c9d36ba8099d9a835c98172|b58e689703]: Return value of 'Tcl_Flush' check-in: f7b55d3100 user: jan.nijtmans tags: core-8-6-branch
2017-10-19
10:55 • New ticket [b58e689703] Return value of `Tcl_Flush`. artifact: c372d923df user: dram

Return value of `Tcl_Flush`

Closed / Fixedb58e6897034fc5292c9d36ba8099d9a835c98172Created 9 years agoUpdated 9 years ago
Descriptionplain2017-10-19 10:55:18
It seems that return value description of `Tcl_Flush` in document[1] is not consistent with the implementation, it says result will be `TCL_OK` or `TCL_ERROR`, but sometimes `-1` is returned. e.g.:

```
#include <tcl.h>


int main()
{
        Tcl_Interp *interp = Tcl_CreateInterp();

        Tcl_Channel channel = Tcl_GetStdChannel(TCL_STDIN);

        printf("TCL_OK = %d\n", TCL_OK);
        printf("TCL_ERROR = %d\n", TCL_ERROR);
        printf("Tcl_Flush(stdin) = %d\n", Tcl_Flush(channel));

        Tcl_DeleteInterp(interp);

        return 0;
}
```

Output:

```
TCL_OK = 0
TCL_ERROR = 1
Tcl_Flush(stdin) = -1
```

[1] https://tcl.tk/man/tcl8.6/TclLib/OpenFileChnl.htm#M19
Referenced by1
jan.nijtmanswiki2017-10-23 12:11:09

Good catch! In this case there is no reason to distingish the channel being non-writable with other errors, since the actual error situation is expected to be returned in errno anyway in both cases. It looks like an ancient copy/paste error, since a lot of other functions where CheckChannelErrors() is used return -1 for error.

Therefore: agreed with the analyses. Should be fixed now in core-8-6-branch and trunk.

Thanks!

dramplain2017-10-25 07:32:21
Fix confirmed, thanks.
Log in (anonymous is fine) to add a comment.