]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceFormat Enforcement
authorSource Maintenance <squidadm@squid-cache.org>
Tue, 23 May 2017 12:12:15 +0000 (12:12 +0000)
committerSource Maintenance <squidadm@squid-cache.org>
Tue, 23 May 2017 12:12:15 +0000 (12:12 +0000)
src/base/File.cc
src/sbuf/Stream.h
src/tests/Stub.list
src/tests/stub_url.cc

index d5118a6f1fe419c814f4db3d17e24aae94cdf151..4087ec039705f12767fb91474658a8cc5e65ad3e 100644 (file)
@@ -309,73 +309,73 @@ File::synchronize()
         throw TexcHere(sysCallError("fsync", savedErrno));
     }
 #endif
-}
+    }
 
 /// calls lockOnce() as many times as necessary (including zero)
-void
-File::lock(const FileOpeningConfig &cfg)
-{
-    unsigned int attemptsLeft = cfg.lockAttempts;
-    while (attemptsLeft) {
-        try {
-            --attemptsLeft;
-            return lockOnce(cfg);
-        } catch (const std::exception &ex) {
-            if (!attemptsLeft)
-                throw;
-            debugs(54, 4, "sleeping and then trying up to " << attemptsLeft <<
-                   " more time(s) after a failure: " << ex.what());
+    void
+    File::lock(const FileOpeningConfig &cfg)
+    {
+        unsigned int attemptsLeft = cfg.lockAttempts;
+        while (attemptsLeft) {
+            try {
+                --attemptsLeft;
+                return lockOnce(cfg);
+            } catch (const std::exception &ex) {
+                if (!attemptsLeft)
+                    throw;
+                debugs(54, 4, "sleeping and then trying up to " << attemptsLeft <<
+                       " more time(s) after a failure: " << ex.what());
+            }
+            Must(attemptsLeft); // the catch statement handles the last attempt
+            xusleep(cfg.RetryGapUsec);
         }
-        Must(attemptsLeft); // the catch statement handles the last attempt
-        xusleep(cfg.RetryGapUsec);
+        debugs(54, 9, "disabled");
     }
-    debugs(54, 9, "disabled");
-}
 
 /// locks, blocking or returning immediately depending on the lock waiting mode
-void
-File::lockOnce(const FileOpeningConfig &cfg)
-{
+    void
+    File::lockOnce(const FileOpeningConfig &cfg)
+    {
 #if _SQUID_WINDOWS_
-    if (!LockFileEx(fd_, cfg.lockFlags, 0, 0, 1, 0)) {
-        const auto savedError = GetLastError();
-        throw TexcHere(sysCallFailure("LockFileEx", WindowsErrorMessage(savedError).c_str()));
-    }
+        if (!LockFileEx(fd_, cfg.lockFlags, 0, 0, 1, 0)) {
+            const auto savedError = GetLastError();
+            throw TexcHere(sysCallFailure("LockFileEx", WindowsErrorMessage(savedError).c_str()));
+        }
 #elif _SQUID_SOLARIS_
-    if (fcntlLock(fd_, cfg.lockType) != 0) {
-        const auto savedErrno = errno;
-        throw TexcHere(sysCallError("fcntl(flock)", savedErrno));
-    }
+        if (fcntlLock(fd_, cfg.lockType) != 0) {
+            const auto savedErrno = errno;
+            throw TexcHere(sysCallError("fcntl(flock)", savedErrno));
+        }
 #else
-    if (::flock(fd_, cfg.flockMode) != 0) {
-        const auto savedErrno = errno;
-        throw TexcHere(sysCallError("flock", savedErrno));
-    }
+        if (::flock(fd_, cfg.flockMode) != 0) {
+            const auto savedErrno = errno;
+            throw TexcHere(sysCallError("flock", savedErrno));
+        }
 #endif
-    debugs(54, 3, "succeeded for " << name_);
-}
+        debugs(54, 3, "succeeded for " << name_);
+    }
 
-bool
-File::isOpen() const
-{
+    bool
+    File::isOpen() const
+    {
 #if _SQUID_WINDOWS_
-    return fd_ != InvalidHandle;
+        return fd_ != InvalidHandle;
 #else
-    return fd_ >= 0;
+        return fd_ >= 0;
 #endif
-}
+    }
 
 /// \returns a description a system call-related failure
-SBuf
-File::sysCallFailure(const char *callName, const char *error) const
-{
-    return ToSBuf("failed to ", callName, ' ', name_, ": ", error);
-}
+    SBuf
+    File::sysCallFailure(const char *callName, const char *error) const
+    {
+        return ToSBuf("failed to ", callName, ' ', name_, ": ", error);
+    }
 
 /// \returns a description of an errno-based system call failure
-SBuf
-File::sysCallError(const char *callName, const int savedErrno) const
-{
-    return sysCallFailure(callName, xstrerr(savedErrno));
-}
+    SBuf
+    File::sysCallError(const char *callName, const int savedErrno) const
+    {
+        return sysCallFailure(callName, xstrerr(savedErrno));
+    }
 
index 2fdda6b57c534fd46528444f3a1a93405f9d9776..b6d6bd0b331f5a1e8557255ad31a0ce110a8abf3 100644 (file)
@@ -126,7 +126,7 @@ SBuf ToSBuf(Args&&... args)
     // TODO: Make this code readable after requiring C++17.
     SBufStream out;
     using expander = int[];
-    (void)expander{0, (void(out << std::forward<Args>(args)),0)...};
+    (void)expander {0, (void(out << std::forward<Args>(args)),0)...};
     return out.buf();
 }
 
index 73904764d724599e0c8e0d29918d1d70c97a090c..0f2335d88e87b59cde60832bd8f0cf2235d7982b 100644 (file)
@@ -81,6 +81,7 @@ STUB_SOURCE= tests/STUB.h \
        tests/stub_tools.cc \
        tests/stub_tunnel.cc \
        tests/stub_UdsOp.cc \
+       tests/stub_url.cc \
        tests/stub_wccp2.cc \
        tests/stub_whois.cc \
        tests/stub_wordlist.cc 
index 82319cf476de1c181f9e230c5690abd223b0dd56..ac2e6e59248394c3d7a70c4fa85b41982ca50aac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -41,3 +41,4 @@ int matchDomainName(const char *, const char *, uint) STUB_RETVAL(0)
 int urlCheckRequest(const HttpRequest *) STUB_RETVAL(0)
 char *urlHostname(const char *) STUB_RETVAL(nullptr)
 void urlExtMethodConfigure() STUB
+