From 8a0f2c19a4874ee97f6e20d202d2b34a69a38e06 Mon Sep 17 00:00:00 2001 From: bch Date: Tue, 20 Jan 2015 23:40:23 +0000 Subject: assert() on missing definitions for Tcl_ChannelCreate() required struct Tcl_ChannelType{} fields. --- generic/tclIO.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generic/tclIO.c b/generic/tclIO.c index a9091af..596ba3f 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1548,6 +1548,15 @@ Tcl_CreateChannel( */ assert(sizeof(Tcl_ChannelTypeVersion) == sizeof(Tcl_DriverBlockModeProc *)); + assert(NULL!=typePtr->closeProc); + assert(NULL!=typePtr->inputProc); + assert(NULL!=typePtr->outputProc); + assert(NULL!=typePtr->watchProc); + assert(NULL!=typePtr->truncateProc); + assert(NULL!=typePtr->getHandleProc); + if (NULL!=typePtr->wideSeekProc) { + assert(NULL!=typePtr->seekProc && "Must define seekProc if defining wideSeekProc"); + } /* * JH: We could subsequently memset these to 0 to avoid the numerous -- cgit v0.12 From 80c303fe985156a04d9565cc50a77e52c4f62269 Mon Sep 17 00:00:00 2001 From: bch Date: Wed, 21 Jan 2015 00:21:18 +0000 Subject: truncateProc *can* be NULL --- generic/tclIO.c | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 596ba3f..eb33106 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1552,7 +1552,6 @@ Tcl_CreateChannel( assert(NULL!=typePtr->inputProc); assert(NULL!=typePtr->outputProc); assert(NULL!=typePtr->watchProc); - assert(NULL!=typePtr->truncateProc); assert(NULL!=typePtr->getHandleProc); if (NULL!=typePtr->wideSeekProc) { assert(NULL!=typePtr->seekProc && "Must define seekProc if defining wideSeekProc"); -- cgit v0.12 From 0184284dd608ec5b462e9cf9fb64df29814b3695 Mon Sep 17 00:00:00 2001 From: bch Date: Sat, 7 Feb 2015 21:19:05 +0000 Subject: switch raw assert() to Tcl_Panic() per discussion w/ dkf --- generic/tclIO.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 025708b..702e2a0 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1548,13 +1548,23 @@ Tcl_CreateChannel( */ assert(sizeof(Tcl_ChannelTypeVersion) == sizeof(Tcl_DriverBlockModeProc *)); - assert(NULL!=typePtr->closeProc); - assert(NULL!=typePtr->inputProc); - assert(NULL!=typePtr->outputProc); - assert(NULL!=typePtr->watchProc); - assert(NULL!=typePtr->getHandleProc); - if (NULL!=typePtr->wideSeekProc) { - assert(NULL!=typePtr->seekProc && "Must define seekProc if defining wideSeekProc"); + if (NULL == typePtr->closeProc) + Tcl_Panic("Required closeProc is unset."); + + if (NULL == typePtr->inputProc) + Tcl_Panic("Required inputProc is unset."); + + if (NULL == typePtr->outputProc) + Tcl_Panic("Required outputProc is unset."); + + if (NULL == typePtr->watchProc) + Tcl_Panic("Required watchProc is unset."); + + if (NULL == typePtr->getHandleProc) + Tcl_Panic("Required getHandleProc is unset."); + + if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) { + Tcl_Panic("Must define seekProc if defining wideSeekProc"); } /* -- cgit v0.12 From 884bdbb9401fca546ba8dd20b4d713fd8897840d Mon Sep 17 00:00:00 2001 From: bch Date: Sun, 8 Feb 2015 05:04:33 +0000 Subject: inputProc and outputProc tests run conditionally on TCL_READABLE, TCL_WRITABLE mask --- generic/tclIO.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 702e2a0..0ba864a 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1551,10 +1551,10 @@ Tcl_CreateChannel( if (NULL == typePtr->closeProc) Tcl_Panic("Required closeProc is unset."); - if (NULL == typePtr->inputProc) + if ((TCL_READABLE & mask) && (NULL == typePtr->inputProc)) Tcl_Panic("Required inputProc is unset."); - if (NULL == typePtr->outputProc) + if ((TCL_WRITABLE & mask) && (NULL == typePtr->outputProc)) Tcl_Panic("Required outputProc is unset."); if (NULL == typePtr->watchProc) -- cgit v0.12 From 4d05a07f5bfa8d6ef796bfb9edf79e49d6fda7e3 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 11 Feb 2015 15:56:27 +0000 Subject: Even clearer failure messages. --- generic/tclIO.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 0ba864a..aabae0b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1548,23 +1548,24 @@ Tcl_CreateChannel( */ assert(sizeof(Tcl_ChannelTypeVersion) == sizeof(Tcl_DriverBlockModeProc *)); - if (NULL == typePtr->closeProc) - Tcl_Panic("Required closeProc is unset."); - - if ((TCL_READABLE & mask) && (NULL == typePtr->inputProc)) - Tcl_Panic("Required inputProc is unset."); - - if ((TCL_WRITABLE & mask) && (NULL == typePtr->outputProc)) - Tcl_Panic("Required outputProc is unset."); - - if (NULL == typePtr->watchProc) - Tcl_Panic("Required watchProc is unset."); - - if (NULL == typePtr->getHandleProc) - Tcl_Panic("Required getHandleProc is unset."); - + assert(typePtr->typeName != NULL); + if (NULL == typePtr->closeProc) { + Tcl_Panic("channel type %s must define closeProc", typePtr->typeName); + } + if ((TCL_READABLE & mask) && (NULL == typePtr->inputProc)) { + Tcl_Panic("channel type %s must define inputProc when used for reader channel", typePtr->typeName); + } + if ((TCL_WRITABLE & mask) && (NULL == typePtr->outputProc)) { + Tcl_Panic("channel type %s must define outputProc when used for writer channel", typePtr->typeName); + } + if (NULL == typePtr->watchProc) { + Tcl_Panic("channel type %s must define watchProc", typePtr->typeName); + } + if (NULL == typePtr->getHandleProc) { + Tcl_Panic("channel type %s must define getHandleProc", typePtr->typeName); + } if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) { - Tcl_Panic("Must define seekProc if defining wideSeekProc"); + Tcl_Panic("channel type %s must define seekProc if defining wideSeekProc", typePtr->typeName); } /* -- cgit v0.12 From 44aa000539d0865e99c9bc3f4d4c2984d1eeb876 Mon Sep 17 00:00:00 2001 From: bch Date: Thu, 19 Feb 2015 19:16:37 +0000 Subject: backout backwards-incompatible experiment that was accidentally committed --- generic/tclIORChan.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 0f7f021..21c766e 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -30,8 +30,6 @@ /* * Signatures of all functions used in the C layer of the reflection. */ -static int ReflectGetHandle( ClientData instanceData, - int direction, ClientData *handlePtr); static int ReflectClose(ClientData clientData, Tcl_Interp *interp); @@ -70,7 +68,7 @@ static const Tcl_ChannelType tclRChannelType = { ReflectSetOption, /* Set options. NULL'able */ ReflectGetOption, /* Get options. NULL'able */ ReflectWatch, /* Initialize notifier */ - ReflectGetHandle, /* Get OS handle from the channel. */ + NULL, /* Get OS handle from the channel. NULL'able */ NULL, /* No close2 support. NULL'able */ ReflectBlock, /* Set blocking/nonblocking. NULL'able */ NULL, /* Flush channel. Not used by core. NULL'able */ @@ -1646,32 +1644,6 @@ ReflectWatch( /* *---------------------------------------------------------------------- * - * ReflectGetHandle -- - * - * This function is invoked to return OS channel handles, or EINVAL - * if not applicable or otherwise invalid. - * - * Results: - * EINVAL. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -ReflectGetHandle( - ClientData instanceData, - int direction, - ClientData *handlePtr) -{ - return EINVAL; -} - -/* - *---------------------------------------------------------------------- - * * ReflectBlock -- * * This function is invoked to tell the channel which blocking behaviour -- cgit v0.12