diff options
author | nijtmans <nijtmans@noemail.net> | 2009-12-16 23:25:59 (GMT) |
---|---|---|
committer | nijtmans <nijtmans@noemail.net> | 2009-12-16 23:25:59 (GMT) |
commit | d4f67705e8218b7f9565547bd896608a914eec9b (patch) | |
tree | b7038bbc46d46d90860a433594776df4f31d744e | |
parent | ba58094401075a77c8f6cf6fb0c55471eea6b8c2 (diff) | |
download | tcl-d4f67705e8218b7f9565547bd896608a914eec9b.zip tcl-d4f67705e8218b7f9565547bd896608a914eec9b.tar.gz tcl-d4f67705e8218b7f9565547bd896608a914eec9b.tar.bz2 |
Fix gcc warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result
CONSTify functions TclpGetUserHome and
TclSetPreInitScript (TIP #27)
FossilOrigin-Name: e52afe7fa4a7ade909410cfb737f1f7bbe6c201a
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | generic/tclInt.decls | 6 | ||||
-rw-r--r-- | generic/tclIntDecls.h | 10 | ||||
-rw-r--r-- | generic/tclInterp.c | 10 | ||||
-rw-r--r-- | generic/tclTest.c | 14 | ||||
-rw-r--r-- | unix/.cvsignore | 7 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 4 | ||||
-rw-r--r-- | unix/tclUnixNotfy.c | 14 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 13 | ||||
-rw-r--r-- | win/tclWinFile.c | 6 |
10 files changed, 67 insertions, 28 deletions
@@ -1,3 +1,14 @@ +2009-12-11 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tclTest.c: Fix gcc warning: ignoring return value of ‘write’, + * unix/tclUnixNotify.c declared with attribute warn_unused_result + * unix/tclUnixPipe.c + * generic/tclInt.decls CONSTify functions TclpGetUserHome and + * generic/tclIntDecls.h TclSetPreInitScript (TIP #27) + * generic/tclInterp.c + * win/tclWinFile.c + * unix/tclUnixFile.c + 2009-12-16 Donal K. Fellows <dkf@users.sf.net> * doc/tm.n: [Bug 1911342]: Formatting rewrite to avoid bogus crosslink diff --git a/generic/tclInt.decls b/generic/tclInt.decls index dc4a7ff..2d0e460 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tclInt.decls,v 1.140 2009/07/15 13:17:18 dkf Exp $ +# RCS: @(#) $Id: tclInt.decls,v 1.141 2009/12/16 23:26:01 nijtmans Exp $ library tcl @@ -186,7 +186,7 @@ declare 41 generic { Tcl_Command TclGetOriginalCommand(Tcl_Command command) } declare 42 generic { - char *TclpGetUserHome(const char *name, Tcl_DString *bufferPtr) + CONST86 char *TclpGetUserHome(const char *name, Tcl_DString *bufferPtr) } # Removed in Tcl 8.5a2 #declare 43 generic { @@ -412,7 +412,7 @@ declare 98 generic { # Tcl_Obj *objPtr, int flags) #} declare 101 generic { - char *TclSetPreInitScript(char *string) + CONST86 char *TclSetPreInitScript(const char *string) } declare 102 generic { void TclSetupEnv(Tcl_Interp *interp) diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 5672e25..a01b938 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIntDecls.h,v 1.134 2009/07/15 13:17:18 dkf Exp $ + * RCS: @(#) $Id: tclIntDecls.h,v 1.135 2009/12/16 23:26:00 nijtmans Exp $ */ #ifndef _TCLINTDECLS @@ -208,7 +208,7 @@ EXTERN Tcl_Command TclGetOriginalCommand (Tcl_Command command); #ifndef TclpGetUserHome_TCL_DECLARED #define TclpGetUserHome_TCL_DECLARED /* 42 */ -EXTERN char * TclpGetUserHome (const char * name, +EXTERN CONST86 char * TclpGetUserHome (const char * name, Tcl_DString * bufferPtr); #endif /* Slot 43 is reserved */ @@ -408,7 +408,7 @@ EXTERN int TclServiceIdle (void); #ifndef TclSetPreInitScript_TCL_DECLARED #define TclSetPreInitScript_TCL_DECLARED /* 101 */ -EXTERN char * TclSetPreInitScript (char * string); +EXTERN CONST86 char * TclSetPreInitScript (const char * string); #endif #ifndef TclSetupEnv_TCL_DECLARED #define TclSetupEnv_TCL_DECLARED @@ -1100,7 +1100,7 @@ typedef struct TclIntStubs { TclObjCmdProcType (*tclGetObjInterpProc) (void); /* 39 */ int (*tclGetOpenMode) (Tcl_Interp * interp, const char * str, int * seekFlagPtr); /* 40 */ Tcl_Command (*tclGetOriginalCommand) (Tcl_Command command); /* 41 */ - char * (*tclpGetUserHome) (const char * name, Tcl_DString * bufferPtr); /* 42 */ + CONST86 char * (*tclpGetUserHome) (const char * name, Tcl_DString * bufferPtr); /* 42 */ void *reserved43; int (*tclGuessPackageName) (const char * fileName, Tcl_DString * bufPtr); /* 44 */ int (*tclHideUnsafeCommands) (Tcl_Interp * interp); /* 45 */ @@ -1159,7 +1159,7 @@ typedef struct TclIntStubs { int (*tclServiceIdle) (void); /* 98 */ void *reserved99; void *reserved100; - char * (*tclSetPreInitScript) (char * string); /* 101 */ + CONST86 char * (*tclSetPreInitScript) (const char * string); /* 101 */ void (*tclSetupEnv) (Tcl_Interp * interp); /* 102 */ int (*tclSockGetPort) (Tcl_Interp * interp, const char * str, const char * proto, int * portPtr); /* 103 */ int (*tclSockMinimumBuffers) (int sock, int size); /* 104 */ diff --git a/generic/tclInterp.c b/generic/tclInterp.c index edf31ff..89b635d 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInterp.c,v 1.107 2009/12/05 21:30:05 msofer Exp $ + * RCS: @(#) $Id: tclInterp.c,v 1.108 2009/12/16 23:26:01 nijtmans Exp $ */ #include "tclInt.h" @@ -21,7 +21,7 @@ * above. This variable can be modified by the function below. */ -static char *tclPreInitScript = NULL; +static const char *tclPreInitScript = NULL; /* Forward declaration */ struct Target; @@ -265,11 +265,11 @@ static void TimeLimitCallback(ClientData clientData); *---------------------------------------------------------------------- */ -char * +const char * TclSetPreInitScript( - char *string) /* Pointer to a script. */ + const char *string) /* Pointer to a script. */ { - char *prevString = tclPreInitScript; + const char *prevString = tclPreInitScript; tclPreInitScript = string; return(prevString); } diff --git a/generic/tclTest.c b/generic/tclTest.c index 812a610..192e7e2 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.142 2009/12/12 19:57:26 dkf Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.143 2009/12/16 23:26:01 nijtmans Exp $ */ #undef STATIC_BUILD @@ -2222,9 +2222,13 @@ ExitProcOdd( ClientData clientData) /* Integer value to print. */ { char buf[16 + TCL_INTEGER_SPACE]; + size_t len; sprintf(buf, "odd %d\n", PTR2INT(clientData)); - (void)write(1, buf, strlen(buf)); + len = strlen(buf); + if (len != (size_t) write(1, buf, len)) { + Tcl_Panic("ExitProcOdd: unable to write to stdout"); + } } static void @@ -2232,9 +2236,13 @@ ExitProcEven( ClientData clientData) /* Integer value to print. */ { char buf[16 + TCL_INTEGER_SPACE]; + size_t len; sprintf(buf, "even %d\n", PTR2INT(clientData)); - (void)write(1, buf, strlen(buf)); + len = strlen(buf); + if (len != (size_t) write(1, buf, len)) { + Tcl_Panic("ExitProcEven: unable to write to stdout"); + } } /* diff --git a/unix/.cvsignore b/unix/.cvsignore index 97b5f50..516d2b3 100644 --- a/unix/.cvsignore +++ b/unix/.cvsignore @@ -6,3 +6,10 @@ tclConfig.sh autom4te.cache tcl.pc tclsh.exe +cat +dltest.marker +longfile +tclsh +tcltest +test1 +test2 diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index c8ac03a..a656f4c 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixFile.c,v 1.55 2009/08/02 12:08:17 dkf Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.56 2009/12/16 23:26:00 nijtmans Exp $ */ #include "tclInt.h" @@ -568,7 +568,7 @@ NativeMatchType( *---------------------------------------------------------------------- */ -char * +const char * TclpGetUserHome( const char *name, /* User name for desired home directory. */ Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index edcd884..3be0bb9 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixNotfy.c,v 1.39 2009/04/10 18:02:37 das Exp $ + * RCS: @(#) $Id: tclUnixNotfy.c,v 1.40 2009/12/16 23:26:00 nijtmans Exp $ */ #include "tclInt.h" @@ -291,7 +291,9 @@ Tcl_FinalizeNotifier( * processes had terminated. [Bug: 4139] [Bug: 1222872] */ - write(triggerPipe, "q", 1); + if (write(triggerPipe, "q", 1) != 1) { + Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe"); + } close(triggerPipe); while(triggerPipe >= 0) { Tcl_ConditionWait(¬ifierCV, ¬ifierMutex, NULL); @@ -782,7 +784,9 @@ Tcl_WaitForEvent( waitingListPtr = tsdPtr; tsdPtr->onList = 1; - write(triggerPipe, "", 1); + if (write(triggerPipe, "", 1) != 1) { + Tcl_Panic("Tcl_FinalizeNotifier: unable to write to triggerPipe"); + } } FD_ZERO(&(tsdPtr->readyMasks.readable)); @@ -812,7 +816,9 @@ Tcl_WaitForEvent( } tsdPtr->nextPtr = tsdPtr->prevPtr = NULL; tsdPtr->onList = 0; - write(triggerPipe, "", 1); + if (write(triggerPipe, "", 1) != 1) { + Tcl_Panic("Tcl_FinalizeNotifier: unable to write to triggerPipe"); + } } #else diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 69250f8..208b6d9 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.49 2009/11/09 13:47:23 dkf Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.50 2009/12/16 23:26:00 nijtmans Exp $ */ #include "tclInt.h" @@ -448,6 +448,7 @@ TclpCreateProcess( pid = fork(); if (pid == 0) { + size_t len; int joinThisError = errorFile && (errorFile == outputFile); fd = GetFd(errPipeOut); @@ -463,7 +464,10 @@ TclpCreateProcess( ((dup2(1,2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) { sprintf(errSpace, "%dforked process couldn't set up input/output: ", errno); - (void) write(fd, errSpace, (size_t) strlen(errSpace)); + len = strlen(errSpace); + if (len != (size_t) write(fd, errSpace, len)) { + Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut"); + } _exit(1); } @@ -474,7 +478,10 @@ TclpCreateProcess( RestoreSignals(); execvp(newArgv[0], newArgv); /* INTL: Native. */ sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno, argv[0]); - (void) write(fd, errSpace, (size_t) strlen(errSpace)); + len = strlen(errSpace); + if (len != (size_t) write(fd, errSpace, len)) { + Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut"); + } _exit(1); } diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 25e1eac..23fea2b 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.99 2009/11/24 00:08:27 patthoyts Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.100 2009/12/16 23:26:02 nijtmans Exp $ */ /* #define _WIN32_WINNT 0x0500 */ @@ -1416,13 +1416,13 @@ NativeMatchType( *---------------------------------------------------------------------- */ -char * +const char * TclpGetUserHome( const char *name, /* User name for desired home directory. */ Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with * name of user's home directory. */ { - char *result; + const char *result; HINSTANCE netapiInst; result = NULL; |