From b6388dfd130c7c2f050df2d37337d65157d31247 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 11 Jun 2021 09:28:25 +0000 Subject: [PATCH] Maintenance: Update astyle version to 3.1 (#841) Version 2.04 is quite outdated now, and there are only minor formatting differences with v3.1. All changes look to be good syntax. Also, pass the astyle executable with command line option to formater.pl. Avoiding environment variables which do not work on servers with sanitized sub-shell environments such as our main server. --- compat/GnuRegex.c | 2 +- lib/base64.c | 32 +++++++++---------- lib/smblib/smblib-util.c | 2 +- scripts/formater.pl | 28 ++++++++-------- scripts/source-maintenance.sh | 5 ++- src/DiskIO/IpcIo/IpcIoFile.cc | 2 +- .../external/kerberos_ldap_group/support.h | 4 +-- src/adaptation/ecap/ServiceRep.cc | 2 +- src/clients/FtpClient.cc | 12 +++---- src/comm.cc | 6 ++-- src/dns_internal.cc | 2 +- src/fs/rock/RockIoRequests.cc | 14 ++++---- src/peer_select.cc | 2 +- 13 files changed, 56 insertions(+), 57 deletions(-) diff --git a/compat/GnuRegex.c b/compat/GnuRegex.c index 775830204c..344da3ad63 100644 --- a/compat/GnuRegex.c +++ b/compat/GnuRegex.c @@ -2757,7 +2757,7 @@ static int wordchar_p(const char *d, const char *end1, const char *string2) { return re_syntax_table[(d) == end1 ? *string2 - : (d) == string2 - 1 ? *(end1 - 1) : *(d)] + : (d) == string2 - 1 ? *(end1 - 1) : *(d)] == Sword; } diff --git a/lib/base64.c b/lib/base64.c index a2f2dfa2f9..3fa002ef7e 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -57,22 +57,22 @@ base64_decode_init(struct base64_decode_ctx *ctx) { /* White space is HT, VT, FF, CR, LF and SPC */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - }; + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; ctx->word = ctx->bits = ctx->padding = 0; ctx->table = base64_decode_table; diff --git a/lib/smblib/smblib-util.c b/lib/smblib/smblib-util.c index b914c7ed9c..c6376693b8 100644 --- a/lib/smblib/smblib-util.c +++ b/lib/smblib/smblib-util.c @@ -52,7 +52,7 @@ int SMB_Types[] = {SMB_P_Core, SMB_P_NT1, SMB_P_NT1, -1 - }; + }; #if UNDEFINED char *SMB_DOSTimToStr(int DOS_time); diff --git a/scripts/formater.pl b/scripts/formater.pl index d77579bca7..91efbbf121 100755 --- a/scripts/formater.pl +++ b/scripts/formater.pl @@ -28,28 +28,23 @@ use strict; use IPC::Open2; +use Getopt::Long; -my $ASTYLE_BIN = defined $ENV{'ASTYLE'} ? $ENV{'ASTYLE'} : 'astyle'; +my $ASTYLE_BIN = "astyle"; my $ASTYLE_ARGS ="--mode=c -s4 --convert-tabs --keep-one-line-blocks --lineend=linux"; #$ASTYLE_ARGS="--mode=c -s4 -O --break-blocks -l"; +Getopt::Long::Configure("require_order"); +GetOptions( + 'help', sub { usage($0) }, + 'with-astyle=s', \$ASTYLE_BIN + ) or die(usage($0)); + $ASTYLE_BIN=$ASTYLE_BIN." ".$ASTYLE_ARGS; my $INDENT = ""; my $out = shift @ARGV; -#read options, currently no options available -while($out eq "" || $out =~ /^-\w+$/){ - if($out eq "-h") { - usage($0); - exit 0; - } else { - usage($0); - exit -1; - } -} - - while($out){ if( $out !~ /\.cc$|\.cci$|\.h$|\.c$/) { @@ -207,5 +202,10 @@ sub output_filter{ sub usage{ my($name)=@_; - print "Usage:\n $name file1 file2 file3 ....\n"; + print "Usage:\n"; + print " $name [options] file1 file2 file3 ....\n"; + print "\n"; + print "Options:\n"; + print " --help This usage text.\n"; + print " --with-astyle astyle executable to use.\n"; } diff --git a/scripts/source-maintenance.sh b/scripts/source-maintenance.sh index 1c5addc692..8d5a64d5a2 100755 --- a/scripts/source-maintenance.sh +++ b/scripts/source-maintenance.sh @@ -33,7 +33,7 @@ KeepGoingDirective="" # has changed in different releases. # if --with-astyle /path/to/astyle is used, the check is still performed # and a warning is printed, but the sources are reformatted -TargetAstyleVersion="2.04" +TargetAstyleVersion="3.1" ASTYLE='astyle' # whether to check and, if necessary, update boilerplate copyright years @@ -71,7 +71,6 @@ while [ $# -ge 1 ]; do ;; --with-astyle) ASTYLE=$2 - export ASTYLE shift 2 ;; *) @@ -231,7 +230,7 @@ for FILENAME in `git ls-files`; do # applyPluginsTo ${FILENAME} scripts/maintenance/ || return if test "${ASVER}"; then - ./scripts/formater.pl ${FILENAME} + ./scripts/formater.pl --with-astyle ${ASTYLE} ${FILENAME} if test -e $FILENAME -a -e "$FILENAME.astylebak"; then md51=`cat $FILENAME| tr -d "\n \t\r" | $MD5`; md52=`cat $FILENAME.astylebak| tr -d "\n \t\r" | $MD5`; diff --git a/src/DiskIO/IpcIo/IpcIoFile.cc b/src/DiskIO/IpcIo/IpcIoFile.cc index 0211e5faa9..0ecbdb4bbf 100644 --- a/src/DiskIO/IpcIo/IpcIoFile.cc +++ b/src/DiskIO/IpcIo/IpcIoFile.cc @@ -615,7 +615,7 @@ IpcIoFile::scheduleTimeoutCheck() CallService(nullptr, [&] { // we check all older requests at once so some may be wait for 2*Timeout eventAdd("IpcIoFile::CheckTimeouts", &IpcIoFile::CheckTimeouts, - reinterpret_cast(diskId), Timeout, 0, false); + reinterpret_cast(diskId), Timeout, 0, false); timeoutCheckScheduled = true; }); } diff --git a/src/acl/external/kerberos_ldap_group/support.h b/src/acl/external/kerberos_ldap_group/support.h index 377c2fddd3..2d9803f2d5 100644 --- a/src/acl/external/kerberos_ldap_group/support.h +++ b/src/acl/external/kerberos_ldap_group/support.h @@ -127,11 +127,11 @@ SQUIDCEXTERN int log_enabled; #define error(X...) \ fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \ fprintf(stderr,X); \ - + #define warn(X...) \ fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \ fprintf(stderr,X); \ - + #else /* __GNUC__ */ /* non-GCC compilers can't do the above macro define yet. */ diff --git a/src/adaptation/ecap/ServiceRep.cc b/src/adaptation/ecap/ServiceRep.cc index 5989f1383d..bc008b2466 100644 --- a/src/adaptation/ecap/ServiceRep.cc +++ b/src/adaptation/ecap/ServiceRep.cc @@ -152,7 +152,7 @@ Adaptation::Ecap::Engine::kickAsyncServices(timeval &timeout) /* Adaptation::Ecap::ServiceRep */ Adaptation::Ecap::ServiceRep::ServiceRep(const ServiceConfigPointer &cfg): -/*AsyncJob("Adaptation::Ecap::ServiceRep"),*/ Adaptation::Service(cfg), + /*AsyncJob("Adaptation::Ecap::ServiceRep"),*/ Adaptation::Service(cfg), isDetached(false) { } diff --git a/src/clients/FtpClient.cc b/src/clients/FtpClient.cc index 1d3b2d9348..98f4d6975c 100644 --- a/src/clients/FtpClient.cc +++ b/src/clients/FtpClient.cc @@ -182,12 +182,12 @@ Ftp::DataChannel::addr(const Ip::Address &import) Ftp::Client::Client(FwdState *fwdState): AsyncJob("Ftp::Client"), ::Client(fwdState), - ctrl(), - data(), - state(BEGIN), - old_request(NULL), - old_reply(NULL), - shortenReadTimeout(false) + ctrl(), + data(), + state(BEGIN), + old_request(NULL), + old_reply(NULL), + shortenReadTimeout(false) { ++statCounter.server.all.requests; ++statCounter.server.ftp.requests; diff --git a/src/comm.cc b/src/comm.cc index 5c049a91d2..60d4f1b39f 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1245,8 +1245,8 @@ ClientInfo::writeOrDequeue() const auto ccb = COMMIO_FD_WRITECB(head); // check that the head descriptor is still relevant if (headFde.clientInfo == this && - quotaPeekReserv() == ccb->quotaQueueReserv && - !headFde.closing()) { + quotaPeekReserv() == ccb->quotaQueueReserv && + !headFde.closing()) { // wait for the head descriptor to become ready for writing Comm::SetSelect(head, COMM_SELECT_WRITE, Comm::HandleWrite, ccb, 0); @@ -1627,7 +1627,7 @@ commHalfClosedCheck(void *) if (!fd_table[c->fd].halfClosedReader) { // not reading already CallBack(fd_table[c->fd].codeContext, [&c] { AsyncCall::Pointer call = commCbCall(5,4, "commHalfClosedReader", - CommIoCbPtrFun(&commHalfClosedReader, nullptr)); + CommIoCbPtrFun(&commHalfClosedReader, nullptr)); Comm::Read(c, call); fd_table[c->fd].halfClosedReader = call; }); diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 70d0ae9c74..d75f42ad35 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -1125,7 +1125,7 @@ idnsCallbackAllCallersWithNewAnswer(const idns_query * const answered, const boo for (auto looker = master; looker; looker = looker->queue) { CallBack(looker->codeContext, [&] { (void)idnsCallbackOneWithAnswer(looker->callback, looker->callback_data, - *answered, lastAnswer); + *answered, lastAnswer); }); } } diff --git a/src/fs/rock/RockIoRequests.cc b/src/fs/rock/RockIoRequests.cc index d9af9de937..cb1d23c550 100644 --- a/src/fs/rock/RockIoRequests.cc +++ b/src/fs/rock/RockIoRequests.cc @@ -16,18 +16,18 @@ CBDATA_NAMESPACED_CLASS_INIT(Rock, WriteRequest); Rock::ReadRequest::ReadRequest(const ::ReadRequest &base, const IoState::Pointer &anSio, const IoXactionId anId): ::ReadRequest(base), - sio(anSio), - id(anId) + sio(anSio), + id(anId) { } Rock::WriteRequest::WriteRequest(const ::WriteRequest &base, const IoState::Pointer &anSio, const IoXactionId anId): ::WriteRequest(base), - sio(anSio), - sidPrevious(-1), - sidCurrent(-1), - id(anId), - eof(false) + sio(anSio), + sidPrevious(-1), + sidCurrent(-1), + id(anId), + eof(false) { } diff --git a/src/peer_select.cc b/src/peer_select.cc index 8a22d122c4..97a8e9f2f1 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -171,7 +171,7 @@ PeerSelectorPingMonitor::noteWaitOver() CallBack(selector->al, [selector,this] { selector->ping.monitorRegistration = npos(); AsyncCall::Pointer callback = asyncCall(44, 4, "PeerSelector::HandlePingTimeout", - cbdataDialer(PeerSelector::HandlePingTimeout, selector)); + cbdataDialer(PeerSelector::HandlePingTimeout, selector)); ScheduleCallHere(callback); }); selectors.erase(selectors.begin()); -- 2.47.2