From fb6b7a8d8df44ad9dc0d96bddf6acfed423fa873 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 2 Jul 2015 12:17:26 +0000 Subject: Remove unnecessary end-of-line spacing in compat/*.c --- compat/fake-rfc2553.c | 32 ++++++++++++++++---------------- compat/fixstrtod.c | 2 +- compat/gettod.c | 2 +- compat/mkstemp.c | 2 +- compat/opendir.c | 2 +- compat/strncasecmp.c | 2 +- compat/strstr.c | 2 +- compat/strtod.c | 6 +++--- compat/strtol.c | 2 +- compat/strtoul.c | 6 +++--- compat/waitpid.c | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/compat/fake-rfc2553.c b/compat/fake-rfc2553.c index 3b91041..c8e69400 100644 --- a/compat/fake-rfc2553.c +++ b/compat/fake-rfc2553.c @@ -1,7 +1,7 @@ /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. * Copyright (C) 1999 WIDE Project. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +13,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -67,7 +67,7 @@ strlcpy(char *dst, const char *src, size_t siz) } #endif -int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, +int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *)sa; @@ -96,7 +96,7 @@ int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, } else { int ret; Tcl_MutexLock(&netdbMutex); - hp = gethostbyaddr((char *)&sin->sin_addr, + hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); if (hp == NULL) { ret = EAI_NODATA; @@ -130,7 +130,7 @@ fake_gai_strerror(int err) default: return ("unknown/invalid error."); } -} +} #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO @@ -156,9 +156,9 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); if (ai == NULL) return (NULL); - + memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); - + ai->ai_addr = (struct sockaddr *)(ai + 1); /* XXX -- ssh doesn't use sa_len */ ai->ai_addrlen = sizeof(struct sockaddr_in); @@ -166,7 +166,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; - + /* XXX: the following is not generally correct, but does what we want */ if (hints->ai_socktype) ai->ai_socktype = hints->ai_socktype; @@ -180,7 +180,7 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) } int -fake_getaddrinfo(const char *hostname, const char *servname, +fake_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { struct hostent *hp; @@ -211,29 +211,29 @@ fake_getaddrinfo(const char *hostname, const char *servname, if (hostname && inet_aton(hostname, &in) != 0) addr = in.s_addr; *res = malloc_ai(port, addr, hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + if (!hostname) { *res = malloc_ai(port, htonl(0x7f000001), hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + if (inet_aton(hostname, &in)) { *res = malloc_ai(port, in.s_addr, hints); - if (*res == NULL) + if (*res == NULL) return (EAI_MEMORY); return (0); } - + /* Don't try DNS if AI_NUMERICHOST is set */ if (hints && hints->ai_flags & AI_NUMERICHOST) return (EAI_NONAME); - + Tcl_MutexLock(&netdbMutex); hp = gethostbyname(hostname); if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { diff --git a/compat/fixstrtod.c b/compat/fixstrtod.c index 91f309e..63fb8ef 100644 --- a/compat/fixstrtod.c +++ b/compat/fixstrtod.c @@ -1,4 +1,4 @@ -/* +/* * fixstrtod.c -- * * Source code for the "fixstrtod" procedure. This procedure is diff --git a/compat/gettod.c b/compat/gettod.c index 28e1432..ca20cf8 100644 --- a/compat/gettod.c +++ b/compat/gettod.c @@ -1,4 +1,4 @@ -/* +/* * gettod.c -- * * This file provides the gettimeofday function on systems diff --git a/compat/mkstemp.c b/compat/mkstemp.c index eaa0b66..1a44dfa 100644 --- a/compat/mkstemp.c +++ b/compat/mkstemp.c @@ -1,4 +1,4 @@ -/* +/* * mkstemp.c -- * * Source code for the "mkstemp" library routine. diff --git a/compat/opendir.c b/compat/opendir.c index a18f96b..22e8a3a 100644 --- a/compat/opendir.c +++ b/compat/opendir.c @@ -1,4 +1,4 @@ -/* +/* * opendir.c -- * * This file provides dirent-style directory-reading procedures for V7 diff --git a/compat/strncasecmp.c b/compat/strncasecmp.c index 299715d..0a69f35 100644 --- a/compat/strncasecmp.c +++ b/compat/strncasecmp.c @@ -1,4 +1,4 @@ -/* +/* * strncasecmp.c -- * * Source code for the "strncasecmp" library routine. diff --git a/compat/strstr.c b/compat/strstr.c index 6698c9f..e3b9b8d 100644 --- a/compat/strstr.c +++ b/compat/strstr.c @@ -1,4 +1,4 @@ -/* +/* * strstr.c -- * * Source code for the "strstr" library routine. diff --git a/compat/strtod.c b/compat/strtod.c index cb9f76d..9643c09 100644 --- a/compat/strtod.c +++ b/compat/strtod.c @@ -1,4 +1,4 @@ -/* +/* * strtod.c -- * * Source code for the "strtod" library procedure. @@ -137,7 +137,7 @@ strtod( * has more than 18 digits, ignore the extras, since they can't affect the * value anyway. */ - + pExp = p; p -= mantSize; if (decPt < 0) { @@ -217,7 +217,7 @@ strtod( * by processing the exponent one bit at a time to combine many powers of * 2 of 10. Then combine the exponent with the fraction. */ - + if (exp < 0) { expSign = TRUE; exp = -exp; diff --git a/compat/strtol.c b/compat/strtol.c index b111d97..811006a 100644 --- a/compat/strtol.c +++ b/compat/strtol.c @@ -1,4 +1,4 @@ -/* +/* * strtol.c -- * * Source code for the "strtol" library procedure. diff --git a/compat/strtoul.c b/compat/strtoul.c index d572c2b..15587f1 100644 --- a/compat/strtoul.c +++ b/compat/strtoul.c @@ -1,4 +1,4 @@ -/* +/* * strtoul.c -- * * Source code for the "strtoul" library procedure. @@ -90,7 +90,7 @@ strtoul( * If no base was provided, pick one from the leading characters of the * string. */ - + if (base == 0) { if (*p == '0') { p += 1; @@ -206,7 +206,7 @@ strtoul( if (overflow) { errno = ERANGE; return ULONG_MAX; - } + } if (negative) { return -result; } diff --git a/compat/waitpid.c b/compat/waitpid.c index 8f65799..e03275a 100644 --- a/compat/waitpid.c +++ b/compat/waitpid.c @@ -1,4 +1,4 @@ -/* +/* * waitpid.c -- * * This procedure emulates the POSIX waitpid kernel call on BSD systems -- cgit v0.12 From 9aa3e851043909a88856222ed97da6ed018a9bbe Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 2 Jul 2015 12:29:43 +0000 Subject: Revert some refcount changes on I/O structs. These are refcounts on structs, not Tcl_Obj's. Their scheme doesn't suffer the same difficulties and histories as Tcl_Obj's, and they need not copy every detail, appropriate or not, from Tcl_Obj refcount management. The "significant value" -- as dkf puts it -- for the struct refcounting scheme is 0 not 1. --- generic/tclIO.c | 4 ++-- generic/tclIOGT.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index eb924d1..8b2e149 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -1930,7 +1930,7 @@ TclChannelRelease( if (chanPtr->refCount == 0) { Tcl_Panic("Channel released more than preserved"); } - if (chanPtr->refCount-- > 1) { + if (--chanPtr->refCount) { return; } if (chanPtr->typePtr == NULL) { @@ -2426,7 +2426,7 @@ static void ReleaseChannelBuffer( ChannelBuffer *bufPtr) { - if (bufPtr->refCount-- > 1) { + if (--bufPtr->refCount) { return; } ckfree(bufPtr); diff --git a/generic/tclIOGT.c b/generic/tclIOGT.c index c1ce485..7f61def 100644 --- a/generic/tclIOGT.c +++ b/generic/tclIOGT.c @@ -225,7 +225,7 @@ static void ReleaseData( TransformChannelData *dataPtr) { - if (dataPtr->refCount-- > 1) { + if (--dataPtr->refCount) { return; } ResultClear(&dataPtr->result); -- cgit v0.12 From 20dafdc09ed912fb421b7968b910dd44fab379d1 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 2 Jul 2015 12:54:57 +0000 Subject: Revert refcount changes that were not cosmetic. Changing equality testing to inequality testing does more than make code prettier or clearer. It makes it less strict, and thus more tolerant of other bugs elsewhere. Such changes deserve separate consideration at least, not breezy entry in an otherwise "code cleanup" commit. --- generic/tclCompile.c | 2 +- generic/tclNamesp.c | 2 +- generic/tclObj.c | 4 ++-- generic/tclPreserve.c | 4 ++-- generic/tclProc.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index b9aee64..361c26f 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -1117,7 +1117,7 @@ TclCleanupByteCode( } } - if (codePtr->localCachePtr && (codePtr->localCachePtr->refCount-- <= 1)) { + if (codePtr->localCachePtr && (--codePtr->localCachePtr->refCount == 0)) { TclFreeLocalCache(interp, codePtr->localCachePtr); } diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 3231ce6..91239f0 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -402,7 +402,7 @@ Tcl_PopCallFrame( } if (framePtr->numCompiledLocals > 0) { TclDeleteCompiledLocalVars(iPtr, framePtr); - if (framePtr->localCachePtr->refCount-- <= 1) { + if (--framePtr->localCachePtr->refCount == 0) { TclFreeLocalCache(interp, framePtr->localCachePtr); } framePtr->localCachePtr = NULL; diff --git a/generic/tclObj.c b/generic/tclObj.c index 15d874f..f9216b3 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -4288,7 +4288,7 @@ FreeCmdNameInternalRep( * there are no more uses, free the ResolvedCmdName structure. */ - if (resPtr->refCount-- <= 1) { + if (resPtr->refCount-- == 1) { /* * Now free the cached command, unless it is still in its hash * table or if there are other references to it from other cmdName @@ -4404,7 +4404,7 @@ SetCmdNameFromAny( Command *oldCmdPtr = resPtr->cmdPtr; - if (oldCmdPtr->refCount-- <= 1) { + if (--oldCmdPtr->refCount == 0) { TclCleanupCommandMacro(oldCmdPtr); } } else { diff --git a/generic/tclPreserve.c b/generic/tclPreserve.c index 0b33d22..cca13e8 100644 --- a/generic/tclPreserve.c +++ b/generic/tclPreserve.c @@ -195,7 +195,7 @@ Tcl_Release( continue; } - if (refPtr->refCount-- > 1) { + if (--refPtr->refCount != 0) { Tcl_MutexUnlock(&preserveMutex); return; } @@ -459,7 +459,7 @@ TclHandleRelease( handlePtr, handlePtr->ptr2, handlePtr->ptr); } #endif - if ((handlePtr->refCount-- <= 1) && (handlePtr->ptr == NULL)) { + if ((--handlePtr->refCount == 0) && (handlePtr->ptr == NULL)) { ckfree(handlePtr); } } diff --git a/generic/tclProc.c b/generic/tclProc.c index a9705eb..7bf63c2 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -2445,7 +2445,7 @@ FreeLambdaInternalRep( Proc *procPtr = objPtr->internalRep.twoPtrValue.ptr1; Tcl_Obj *nsObjPtr = objPtr->internalRep.twoPtrValue.ptr2; - if (procPtr->refCount-- <= 1) { + if (procPtr->refCount-- == 1) { TclProcCleanupProc(procPtr); } TclDecrRefCount(nsObjPtr); -- cgit v0.12